From a77f3284dd2453f8882c8a10d89ed66859e61ee5 Mon Sep 17 00:00:00 2001 From: Nuno Antunes Date: Mon, 13 May 2013 17:33:29 +0100 Subject: [PATCH] netgraph7: Bring in ng_eiface. --- Makefile_upgrade.inc | 1 + etc/mtree/BSD.include.dist | 2 + include/Makefile | 4 +- lib/libnetgraph7/debug.c | 2 - sys/conf/files | 2 +- sys/netgraph7/Makefile | 2 +- sys/netgraph7/eiface/Makefile | 7 +++ sys/netgraph7/{ => eiface}/ng_eiface.c | 84 ++++++++++++++------------ sys/netgraph7/{ => eiface}/ng_eiface.h | 0 9 files changed, 59 insertions(+), 45 deletions(-) create mode 100644 sys/netgraph7/eiface/Makefile rename sys/netgraph7/{ => eiface}/ng_eiface.c (89%) rename sys/netgraph7/{ => eiface}/ng_eiface.h (100%) diff --git a/Makefile_upgrade.inc b/Makefile_upgrade.inc index 4b51edd31d..5636aa4260 100644 --- a/Makefile_upgrade.inc +++ b/Makefile_upgrade.inc @@ -1971,6 +1971,7 @@ TO_REMOVE+=/usr/include/objc TO_REMOVE+=/usr/include/machine/pc/msdos.h TO_REMOVE+=/usr/share/man/cat4/i386/stli.4.gz TO_REMOVE+=/usr/share/man/man4/i386/stli.4.gz +TO_REMOVE+=/usr/include/netgraph7/ng_eiface.h TO_REMOVE+=/usr/sbin/stlload TO_REMOVE+=/usr/share/man/cat8/i386/stlload.8.gz TO_REMOVE+=/usr/share/man/man8/i386/stlload.8.gz diff --git a/etc/mtree/BSD.include.dist b/etc/mtree/BSD.include.dist index 00ad4695ce..e71f62feef 100644 --- a/etc/mtree/BSD.include.dist +++ b/etc/mtree/BSD.include.dist @@ -278,6 +278,8 @@ .. echo .. + eiface + .. etf .. ether diff --git a/include/Makefile b/include/Makefile index 675ec5c08d..962bdd2430 100644 --- a/include/Makefile +++ b/include/Makefile @@ -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 \ diff --git a/lib/libnetgraph7/debug.c b/lib/libnetgraph7/debug.c index b57e18cf87..34632540d7 100644 --- a/lib/libnetgraph7/debug.c +++ b/lib/libnetgraph7/debug.c @@ -64,9 +64,7 @@ #include #include #include -/* #include -*/ #include #include /* diff --git a/sys/conf/files b/sys/conf/files index c66ffcd82c..c3f6e3874b 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -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 diff --git a/sys/netgraph7/Makefile b/sys/netgraph7/Makefile index 99e2135b8f..2fa8b37eb3 100644 --- a/sys/netgraph7/Makefile +++ b/sys/netgraph7/Makefile @@ -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 index 0000000000..0d89f49ef1 --- /dev/null +++ b/sys/netgraph7/eiface/Makefile @@ -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 diff --git a/sys/netgraph7/ng_eiface.c b/sys/netgraph7/eiface/ng_eiface.c similarity index 89% rename from sys/netgraph7/ng_eiface.c rename to sys/netgraph7/eiface/ng_eiface.c index dbc2a4ab73..ff308061ab 100644 --- a/sys/netgraph7/ng_eiface.c +++ b/sys/netgraph7/eiface/ng_eiface.c @@ -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 @@ -42,11 +41,12 @@ #include #include +#include #include -#include "ng_message.h" -#include "netgraph.h" -#include "ng_parse.h" +#include +#include +#include #include "ng_eiface.h" #include @@ -83,7 +83,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, struct ifaltq_subque *); -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 +113,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 +123,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 +148,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)) { + ifq_clr_oactive(&ifp->if_snd); + 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) + ifq_clr_oactive(&ifp->if_snd); + ifp->if_flags &= ~(IFF_RUNNING); } break; @@ -180,7 +181,7 @@ ng_eiface_ioctl(struct ifnet *ifp, u_long command, caddr_t data) error = EINVAL; break; } - splx(s); + crit_exit(); return (error); } @@ -189,14 +190,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; + ifq_clr_oactive(&ifp->if_snd); - ifp->if_drv_flags |= IFF_DRV_RUNNING; - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + crit_exit(); - splx(s); } /* @@ -215,7 +216,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 +255,7 @@ ng_eiface_start2(node_p node, hook_p hook, void *arg1, int arg2) ifp->if_oerrors++; } - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + ifq_clr_oactive(&ifp->if_snd); return; } @@ -279,13 +280,13 @@ ng_eiface_start(struct ifnet *ifp, struct ifaltq_subque *ifsq __unused) 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 (ifq_is_oactive(&ifp->if_snd)) return; - ifp->if_drv_flags |= IFF_DRV_OACTIVE; + ifq_set_oactive(&ifp->if_snd); if (ng_send_fn(priv->node, NULL, &ng_eiface_start2, ifp, 0) != 0) - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + ifq_clr_oactive(&ifp->if_snd); } #ifdef DEBUG @@ -353,7 +354,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 +363,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 +380,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 +402,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 +447,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 +455,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 +466,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 +492,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 +526,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 +560,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 +588,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; diff --git a/sys/netgraph7/ng_eiface.h b/sys/netgraph7/eiface/ng_eiface.h similarity index 100% rename from sys/netgraph7/ng_eiface.h rename to sys/netgraph7/eiface/ng_eiface.h -- 2.41.0