netgraph7: Welcome ng_eiface.
authorNuno Antunes <nuno.antunes@gmail.com>
Sat, 7 Jul 2012 15:47:24 +0000 (16:47 +0100)
committerNuno Antunes <nuno.antunes@gmail.com>
Thu, 4 Oct 2012 13:01:35 +0000 (14:01 +0100)
Makefile_upgrade.inc
etc/mtree/BSD.include.dist
include/Makefile
lib/libnetgraph7/debug.c
sys/conf/files
sys/netgraph7/Makefile
sys/netgraph7/eiface/Makefile [new file with mode: 0644]
sys/netgraph7/eiface/ng_eiface.c [moved from sys/netgraph7/ng_eiface.c with 89% similarity]
sys/netgraph7/eiface/ng_eiface.h [moved from sys/netgraph7/ng_eiface.h with 100% similarity]

index d49a462..8042db1 100644 (file)
@@ -2050,6 +2050,7 @@ TO_REMOVE+=/usr/share/man/man1/g++41.1.gz
 TO_REMOVE+=/usr/share/man/man1/gcc41.1.gz
 TO_REMOVE+=/usr/share/man/man1/gcov41.1.gz
 TO_REMOVE+=/usr/share/mk/bsd.cpu.gcc41.mk
+TO_REMOVE+=/usr/include/netgraph7/ng_eiface.h
 
 .if ${MACHINE_ARCH} == "x86_64"
 TO_REMOVE+=/usr/libdata/stallion/2681.sys
index bdb18e6..e5c3d4e 100644 (file)
         ..
         echo
         ..
+        eiface
+        ..
         etf
         ..
         ether
index 91eedbd..2cdd27b 100644 (file)
@@ -69,8 +69,8 @@ LSUBDIRS=     bus/cam bus/cam/scsi \
        netgraph/tee netgraph/tty netgraph/vjc \
        netgraph7/UI netgraph7/async netgraph7/atmllc netgraph7/bpf \
        netgraph7/bridge netgraph7/cisco netgraph7/deflate netgraph7/echo \
-       netgraph7/etf netgraph7/ether netgraph7/frame_relay netgraph7/hole \
-       netgraph7/hub \
+       netgraph7/eiface netgraph7/etf netgraph7/ether \
+       netgraph7/frame_relay netgraph7/hole netgraph7/hub \
        netgraph7/iface netgraph7/ksocket netgraph7/l2tp netgraph7/lmi \
        netgraph7/mppc netgraph7/one2many netgraph7/ppp netgraph7/pppoe \
        netgraph7/pptpgre netgraph7/rfc1490 netgraph7/socket \
index b57e18c..3463254 100644 (file)
@@ -64,9 +64,7 @@
 #include <netgraph7/cisco/ng_cisco.h>
 #include <netgraph7/deflate/ng_deflate.h>
 #include <netgraph7/echo/ng_echo.h>
-/*
 #include <netgraph7/eiface/ng_eiface.h>
-*/
 #include <netgraph7/etf/ng_etf.h>
 #include <netgraph7/ether/ng_ether.h>
 /*
index 838848f..fedbfb6 100644 (file)
@@ -1263,7 +1263,7 @@ netgraph7/cisco/ng_cisco.c        optional netgraph7_cisco
 netgraph7/deflate/ng_deflate.c optional netgraph7_deflate
 netgraph7/ng_device.c          optional netgraph7_device
 netgraph7/echo/ng_echo.c       optional netgraph7_echo
-netgraph7/ng_eiface.c          optional netgraph7_eiface
+netgraph7/eiface/ng_eiface.c   optional netgraph7_eiface
 netgraph7/etf/ng_etf.c         optional netgraph7_etf
 netgraph7/ether/ng_ether.c     optional netgraph7_ether
 netgraph7/ng_fec.c             optional netgraph7_fec
index 99e2135..2fa8b37 100644 (file)
@@ -9,6 +9,7 @@ SUBDIR= UI \
        cisco \
        deflate \
        echo \
+       eiface \
        etf \
        ether \
        frame_relay \
@@ -30,7 +31,6 @@ SUBDIR=       UI \
        tee \
        tty \
        vjc
-#      eiface \
 #      fec \
 #      sync_ar \
 #      sync_sr \
diff --git a/sys/netgraph7/eiface/Makefile b/sys/netgraph7/eiface/Makefile
new file mode 100644 (file)
index 0000000..0d89f49
--- /dev/null
@@ -0,0 +1,7 @@
+# $FreeBSD: src/sys/modules/netgraph/eiface/Makefile,v 1.2.2.1 2002/04/15 00:12:57 julian Exp $
+
+KMOD=          ng_eiface
+SRCS=          ng_eiface.c
+KMODDEPS=      netgraph
+
+.include <bsd.kmod.mk>
similarity index 89%
rename from sys/netgraph7/ng_eiface.c
rename to sys/netgraph7/eiface/ng_eiface.c
index 6c9289d..296f7d5 100644 (file)
@@ -26,7 +26,6 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/netgraph/ng_eiface.c,v 1.39 2007/07/26 10:54:33 glebius Exp $
- * $DragonFly: src/sys/netgraph7/ng_eiface.c,v 1.2 2008/06/26 23:05:35 dillon Exp $
  */
 
 #include <sys/param.h>
@@ -44,9 +43,9 @@
 #include <net/if_types.h>
 #include <net/netisr.h>
 
-#include "ng_message.h"
-#include "netgraph.h"
-#include "ng_parse.h"
+#include <netgraph7/netgraph.h>
+#include <netgraph7/ng_message.h>
+#include <netgraph7/ng_parse.h>
 #include "ng_eiface.h"
 
 #include <net/bpf.h>
@@ -83,7 +82,8 @@ typedef struct ng_eiface_private *priv_p;
 /* Interface methods */
 static void    ng_eiface_init(void *xsc);
 static void    ng_eiface_start(struct ifnet *ifp);
-static int     ng_eiface_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
+static int     ng_eiface_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data,
+                               struct ucred *cr);
 #ifdef DEBUG
 static void    ng_eiface_print_ioctl(struct ifnet *ifp, int cmd, caddr_t data);
 #endif
@@ -112,7 +112,7 @@ static struct ng_type typestruct = {
 };
 NETGRAPH_INIT(eiface, &typestruct);
 
-static struct unrhdr   *ng_eiface_unit;
+static int ng_eiface_next_unit;
 
 /************************************************************************
                        INTERFACE STUFF
@@ -122,15 +122,15 @@ static struct unrhdr      *ng_eiface_unit;
  * Process an ioctl for the virtual interface
  */
 static int
-ng_eiface_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
+ng_eiface_ioctl(struct ifnet *ifp, u_long command, caddr_t data, struct ucred *cr)
 {
        struct ifreq *const ifr = (struct ifreq *)data;
-       int s, error = 0;
+       int error = 0;
 
 #ifdef DEBUG
        ng_eiface_print_ioctl(ifp, command, data);
 #endif
-       s = splimp();
+       crit_enter();
        switch (command) {
 
        /* These two are mostly handled at a higher layer */
@@ -147,14 +147,14 @@ ng_eiface_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
                 * If it is marked down and running, then stop it.
                 */
                if (ifp->if_flags & IFF_UP) {
-                       if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
-                               ifp->if_drv_flags &= ~(IFF_DRV_OACTIVE);
-                               ifp->if_drv_flags |= IFF_DRV_RUNNING;
+                       if (!(ifp->if_flags & IFF_RUNNING)) {
+                               ifp->if_flags &= ~(IFF_OACTIVE);
+                               ifp->if_flags |= IFF_RUNNING;
                        }
                } else {
-                       if (ifp->if_drv_flags & IFF_DRV_RUNNING)
-                               ifp->if_drv_flags &= ~(IFF_DRV_RUNNING |
-                                   IFF_DRV_OACTIVE);
+                       if (ifp->if_flags & IFF_RUNNING)
+                               ifp->if_flags &= ~(IFF_RUNNING |
+                                   IFF_OACTIVE);
                }
                break;
 
@@ -180,7 +180,7 @@ ng_eiface_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
                error = EINVAL;
                break;
        }
-       splx(s);
+       crit_exit();
        return (error);
 }
 
@@ -189,14 +189,14 @@ ng_eiface_init(void *xsc)
 {
        priv_p sc = xsc;
        struct ifnet *ifp = sc->ifp;
-       int s;
 
-       s = splimp();
+       crit_enter();
+
+       ifp->if_flags |= IFF_RUNNING;
+       ifp->if_flags &= ~IFF_OACTIVE;
 
-       ifp->if_drv_flags |= IFF_DRV_RUNNING;
-       ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+       crit_exit();
 
-       splx(s);
 }
 
 /*
@@ -215,7 +215,7 @@ ng_eiface_start2(node_p node, hook_p hook, void *arg1, int arg2)
        /* Check interface flags */
 
        if (!((ifp->if_flags & IFF_UP) &&
-           (ifp->if_drv_flags & IFF_DRV_RUNNING)))
+           (ifp->if_flags & IFF_RUNNING)))
                return;
 
        for (;;) {
@@ -254,7 +254,7 @@ ng_eiface_start2(node_p node, hook_p hook, void *arg1, int arg2)
                        ifp->if_oerrors++;
        }
 
-       ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+       ifp->if_flags &= ~IFF_OACTIVE;
 
        return;
 }
@@ -279,13 +279,13 @@ ng_eiface_start(struct ifnet *ifp)
        const priv_p priv = (priv_p)ifp->if_softc;
 
        /* Don't do anything if output is active */
-       if (ifp->if_drv_flags & IFF_DRV_OACTIVE)
+       if (ifp->if_flags & IFF_OACTIVE)
                return;
 
-       ifp->if_drv_flags |= IFF_DRV_OACTIVE;
+       ifp->if_flags |= IFF_OACTIVE;
 
        if (ng_send_fn(priv->node, NULL, &ng_eiface_start2, ifp, 0) != 0)
-               ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+               ifp->if_flags &= ~IFF_OACTIVE;
 }
 
 #ifdef DEBUG
@@ -353,7 +353,7 @@ ng_eiface_constructor(node_p node)
        ifp->if_softc = priv;
 
        /* Get an interface unit number */
-       priv->unit = alloc_unr(ng_eiface_unit);
+       priv->unit = ng_eiface_next_unit++;
 
        /* Link together node and private info */
        NG_NODE_SET_PRIVATE(node, priv);
@@ -362,7 +362,9 @@ ng_eiface_constructor(node_p node)
        /* Initialize interface structure */
        if_initname(ifp, NG_EIFACE_EIFACE_NAME, priv->unit);
        ifp->if_init = ng_eiface_init;
+/*
        ifp->if_output = ether_output;
+*/
        ifp->if_start = ng_eiface_start;
        ifp->if_ioctl = ng_eiface_ioctl;
        ifp->if_watchdog = NULL;
@@ -377,7 +379,7 @@ ng_eiface_constructor(node_p node)
 #endif
 
        /* Attach the interface */
-       ether_ifattach(ifp, eaddr);
+       ether_ifattach(ifp, eaddr, NULL);
 
        /* Done */
        return (0);
@@ -399,7 +401,8 @@ ng_eiface_newhook(node_p node, hook_p hook, const char *name)
        priv->ether = hook;
        NG_HOOK_SET_PRIVATE(hook, &priv->ether);
 
-       if_link_state_change(ifp, LINK_STATE_UP);
+       ifp->if_link_state = LINK_STATE_UP;
+       if_link_state_change(ifp);
 
        return (0);
 }
@@ -443,7 +446,7 @@ ng_eiface_rcvmsg(node_p node, item_p item, hook_p lasthook)
 
                case NGM_EIFACE_GET_IFADDRS:
                    {
-                       struct ifaddr *ifa;
+                       struct ifaddr_container *ifac;
                        caddr_t ptr;
                        int buflen;
 
@@ -451,8 +454,9 @@ ng_eiface_rcvmsg(node_p node, item_p item, hook_p lasthook)
 
                        /* Determine size of response and allocate it */
                        buflen = 0;
-                       TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
-                               buflen += SA_SIZE(ifa->ifa_addr);
+                       TAILQ_FOREACH(ifac, &ifp->if_addrheads[mycpuid],
+                                     ifa_link)
+                               buflen += SA_SIZE(ifac->ifa->ifa_addr);
                        NG_MKRESPONSE(resp, msg, buflen, M_WAITOK | M_NULLOK);
                        if (resp == NULL) {
                                error = ENOMEM;
@@ -461,7 +465,9 @@ ng_eiface_rcvmsg(node_p node, item_p item, hook_p lasthook)
 
                        /* Add addresses */
                        ptr = resp->data;
-                       TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
+                       TAILQ_FOREACH(ifac, &ifp->if_addrheads[mycpuid],
+                                     ifa_link) {
+                               struct ifaddr *ifa = ifac->ifa;
                                const int len = SA_SIZE(ifa->ifa_addr);
 
                                if (buflen < len) {
@@ -485,10 +491,12 @@ ng_eiface_rcvmsg(node_p node, item_p item, hook_p lasthook)
        case NGM_FLOW_COOKIE:
                switch (msg->header.cmd) {
                case NGM_LINK_IS_UP:
-                       if_link_state_change(ifp, LINK_STATE_UP);
+                       ifp->if_link_state = LINK_STATE_UP;
+                       if_link_state_change(ifp);
                        break;
                case NGM_LINK_IS_DOWN:
-                       if_link_state_change(ifp, LINK_STATE_DOWN);
+                       ifp->if_link_state = LINK_STATE_DOWN;
+                       if_link_state_change(ifp);
                        break;
                default:
                        break;
@@ -517,7 +525,7 @@ ng_eiface_rcvdata(hook_p hook, item_p item)
        NG_FREE_ITEM(item);
 
        if (!((ifp->if_flags & IFF_UP) &&
-           (ifp->if_drv_flags & IFF_DRV_RUNNING))) {
+           (ifp->if_flags & IFF_RUNNING))) {
                NG_FREE_M(m);
                return (ENETDOWN);
        }
@@ -551,7 +559,6 @@ ng_eiface_rmnode(node_p node)
 
        ether_ifdetach(ifp);
        if_free(ifp);
-       free_unr(ng_eiface_unit, priv->unit);
        kfree(priv, M_NETGRAPH);
        NG_NODE_SET_PRIVATE(node, NULL);
        NG_NODE_UNREF(node);
@@ -580,10 +587,8 @@ ng_eiface_mod_event(module_t mod, int event, void *data)
 
        switch (event) {
        case MOD_LOAD:
-               ng_eiface_unit = new_unrhdr(0, 0xffff, NULL);
                break;
        case MOD_UNLOAD:
-               delete_unrhdr(ng_eiface_unit);
                break;
        default:
                error = EOPNOTSUPP;