summaryrefslogtreecommitdiffstats
path: root/sys/netgraph
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2005-06-10 16:49:24 +0000
committerbrooks <brooks@FreeBSD.org>2005-06-10 16:49:24 +0000
commit567ba9b00a248431e7c1147c4e079fd7a11b9ecf (patch)
treef65b6d7834b40dfcd48534829a0a1e9529ab87ee /sys/netgraph
parent3eaa67c3ad947d85be5350e0e184cd6ee5b93a52 (diff)
downloadFreeBSD-src-567ba9b00a248431e7c1147c4e079fd7a11b9ecf.zip
FreeBSD-src-567ba9b00a248431e7c1147c4e079fd7a11b9ecf.tar.gz
Stop embedding struct ifnet at the top of driver softcs. Instead the
struct ifnet or the layer 2 common structure it was embedded in have been replaced with a struct ifnet pointer to be filled by a call to the new function, if_alloc(). The layer 2 common structure is also allocated via if_alloc() based on the interface type. It is hung off the new struct ifnet member, if_l2com. This change removes the size of these structures from the kernel ABI and will allow us to better manage them as interfaces come and go. Other changes of note: - Struct arpcom is no longer referenced in normal interface code. Instead the Ethernet address is accessed via the IFP2ENADDR() macro. To enforce this ac_enaddr has been renamed to _ac_enaddr. - The second argument to ether_ifattach is now always the mac address from driver private storage rather than sometimes being ac_enaddr. Reviewed by: sobomax, sam
Diffstat (limited to 'sys/netgraph')
-rw-r--r--sys/netgraph/atm/atmpif/ng_atmpif_harp.c10
-rw-r--r--sys/netgraph/atm/ng_atm.c4
-rw-r--r--sys/netgraph/ng_eiface.c28
-rw-r--r--sys/netgraph/ng_ether.c8
-rw-r--r--sys/netgraph/ng_fec.c44
-rw-r--r--sys/netgraph/ng_gif.c4
-rw-r--r--sys/netgraph/ng_iface.c4
-rw-r--r--sys/netgraph/ng_sppp.c61
8 files changed, 85 insertions, 78 deletions
diff --git a/sys/netgraph/atm/atmpif/ng_atmpif_harp.c b/sys/netgraph/atm/atmpif/ng_atmpif_harp.c
index 793d9a4..aa31365 100644
--- a/sys/netgraph/atm/atmpif/ng_atmpif_harp.c
+++ b/sys/netgraph/atm/atmpif/ng_atmpif_harp.c
@@ -677,7 +677,7 @@ vatmpif_harp_output(Cmn_unit *cup, Cmn_vcc *cvp, KBuffer *m)
vup->vu_pif.pif_oerrors++;
vcp->vc_oerrors++;
if (vcp->vc_nif)
- vcp->vc_nif->nif_if.if_oerrors++;
+ ANIF2IFP(vcp->vc_nif)->if_oerrors++;
} else {
/*
* Good transmission
@@ -709,8 +709,8 @@ vatmpif_harp_output(Cmn_unit *cup, Cmn_vcc *cvp, KBuffer *m)
vcp->vc_obytes += pdulen;
if (vcp->vc_nif) {
vcp->vc_nif->nif_obytes += pdulen;
- vcp->vc_nif->nif_if.if_opackets++;
- vcp->vc_nif->nif_if.if_obytes += pdulen;
+ ANIF2IFP(vcp->vc_nif)->if_opackets++;
+ ANIF2IFP(vcp->vc_nif)->if_obytes += pdulen;
}
}
}
@@ -888,8 +888,8 @@ vatmpif_harp_recv_drain(Vatmpif_unit *vup, KBuffer *m,
*/
if (vcp->vc_nif) {
vcp->vc_nif->nif_ibytes += pdulen;
- vcp->vc_nif->nif_if.if_ipackets++;
- vcp->vc_nif->nif_if.if_ibytes += pdulen;
+ ANIF2IFP(vcp->vc_nif)->if_ipackets++;
+ ANIF2IFP(vcp->vc_nif)->if_ibytes += pdulen;
}
}
diff --git a/sys/netgraph/atm/ng_atm.c b/sys/netgraph/atm/ng_atm.c
index 4f11ef2..65364cc 100644
--- a/sys/netgraph/atm/ng_atm.c
+++ b/sys/netgraph/atm/ng_atm.c
@@ -346,8 +346,8 @@ static const struct {
} atmmedia[] = IFM_SUBTYPE_ATM_DESCRIPTIONS;
-#define IFP2NG(IFP) ((node_p)((struct ifatm *)(IFP))->ngpriv)
-#define IFP2NG_SET(IFP, val) (((struct ifatm *)(IFP))->ngpriv = (val))
+#define IFP2NG(IFP) ((node_p)((struct ifatm *)(IFP)->if_softc)->ngpriv)
+#define IFP2NG_SET(IFP, val) (((struct ifatm *)(IFP)->if_softc)->ngpriv = (val))
#define IFFLAGS "\020\001UP\002BROADCAST\003DEBUG\004LOOPBACK" \
"\005POINTOPOINT\006SMART\007RUNNING\010NOARP" \
diff --git a/sys/netgraph/ng_eiface.c b/sys/netgraph/ng_eiface.c
index 0a0aad1..7ca104f 100644
--- a/sys/netgraph/ng_eiface.c
+++ b/sys/netgraph/ng_eiface.c
@@ -73,8 +73,7 @@ static const struct ng_cmdlist ng_eiface_cmdlist[] = {
/* Node private data */
struct ng_eiface_private {
- struct arpcom arpcom; /* per-interface network data */
-#define sc_ifp arpcom.ac_if
+ struct ifnet *ifp; /* per-interface network data */
int unit; /* Interface unit number */
node_p node; /* Our netgraph node */
hook_p ether; /* Hook for ethernet stream */
@@ -188,7 +187,7 @@ static void
ng_eiface_init(void *xsc)
{
priv_p sc = xsc;
- struct ifnet *ifp = &sc->sc_ifp;
+ struct ifnet *ifp = sc->ifp;
int s;
s = splimp();
@@ -329,13 +328,18 @@ ng_eiface_constructor(node_p node)
{
struct ifnet *ifp;
priv_p priv;
+ u_char eaddr[6] = {0,0,0,0,0,0};
/* Allocate node and interface private structures */
MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_NOWAIT | M_ZERO);
if (priv == NULL)
return (ENOMEM);
- ifp = &(priv->arpcom.ac_if);
+ ifp = priv->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ free(priv, M_NETGRAPH);
+ return (ENOSPC);
+ }
/* Link them together */
ifp->if_softc = priv;
@@ -365,7 +369,7 @@ ng_eiface_constructor(node_p node)
#endif
/* Attach the interface */
- ether_ifattach(ifp, priv->arpcom.ac_enaddr);
+ ether_ifattach(ifp, eaddr);
/* Done */
return (0);
@@ -378,7 +382,7 @@ static int
ng_eiface_newhook(node_p node, hook_p hook, const char *name)
{
priv_p priv = NG_NODE_PRIVATE(node);
- struct ifnet *ifp = &priv->sc_ifp;
+ struct ifnet *ifp = priv->ifp;
if (strcmp(name, NG_EIFACE_HOOK_ETHER))
return (EPFNOSUPPORT);
@@ -399,7 +403,7 @@ static int
ng_eiface_rcvmsg(node_p node, item_p item, hook_p lasthook)
{
const priv_p priv = NG_NODE_PRIVATE(node);
- struct ifnet *const ifp = &priv->sc_ifp;
+ struct ifnet *const ifp = priv->ifp;
struct ng_mesg *resp = NULL;
int error = 0;
struct ng_mesg *msg;
@@ -420,13 +424,14 @@ ng_eiface_rcvmsg(node_p node, item_p item, hook_p lasthook)
break;
}
eaddr = (struct ether_addr *)(msg->data);
- bcopy(eaddr, priv->arpcom.ac_enaddr, ETHER_ADDR_LEN);
+ bcopy(eaddr, IFP2ENADDR(priv->ifp),
+ ETHER_ADDR_LEN);
/* And put it in the ifaddr list */
TAILQ_FOREACH(ifa, &(ifp->if_addrhead), ifa_link) {
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
if (sdl->sdl_type == IFT_ETHER) {
- bcopy((IFP2AC(ifp))->ac_enaddr,
+ bcopy(IFP2ENADDR(ifp),
LLADDR(sdl), ifp->if_addrlen);
break;
}
@@ -512,7 +517,7 @@ static int
ng_eiface_rcvdata(hook_p hook, item_p item)
{
const priv_p priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
- struct ifnet *const ifp = &priv->sc_ifp;
+ struct ifnet *const ifp = priv->ifp;
struct mbuf *m;
NGI_GET_M(item, m);
@@ -549,9 +554,10 @@ static int
ng_eiface_rmnode(node_p node)
{
const priv_p priv = NG_NODE_PRIVATE(node);
- struct ifnet *const ifp = &priv->sc_ifp;
+ struct ifnet *const ifp = priv->ifp;
ether_ifdetach(ifp);
+ if_free(ifp);
free_unr(ng_eiface_unit, priv->unit);
FREE(priv, M_NETGRAPH);
NG_NODE_SET_PRIVATE(node, NULL);
diff --git a/sys/netgraph/ng_ether.c b/sys/netgraph/ng_ether.c
index f5dc793..21eb2d4 100644
--- a/sys/netgraph/ng_ether.c
+++ b/sys/netgraph/ng_ether.c
@@ -68,8 +68,8 @@
#include <netgraph/ng_parse.h>
#include <netgraph/ng_ether.h>
-#define IFP2NG(ifp) ((struct ng_node *)((struct arpcom *)(ifp))->ac_netgraph)
-#define IFP2NG_SET(ifp, val) (((struct arpcom *)(ifp))->ac_netgraph = (val))
+#define IFP2NG(ifp) ((struct ng_node *)IFP2AC((ifp))->ac_netgraph)
+#define IFP2NG_SET(ifp, val) (IFP2AC((ifp))->ac_netgraph = (val))
/* Per-node private data */
struct private {
@@ -462,7 +462,7 @@ ng_ether_rcvmsg(node_p node, item_p item, hook_p lasthook)
error = ENOMEM;
break;
}
- bcopy((IFP2AC(priv->ifp))->ac_enaddr,
+ bcopy(IFP2ENADDR(priv->ifp),
resp->data, ETHER_ADDR_LEN);
break;
case NGM_ETHER_SET_ENADDR:
@@ -624,7 +624,7 @@ ng_ether_rcv_lower(node_p node, struct mbuf *m)
return (ENOBUFS);
/* Overwrite source MAC address */
- bcopy((IFP2AC(ifp))->ac_enaddr,
+ bcopy(IFP2ENADDR(ifp),
mtod(m, struct ether_header *)->ether_shost,
ETHER_ADDR_LEN);
}
diff --git a/sys/netgraph/ng_fec.c b/sys/netgraph/ng_fec.c
index 0603f36..84b3e8f 100644
--- a/sys/netgraph/ng_fec.c
+++ b/sys/netgraph/ng_fec.c
@@ -171,7 +171,7 @@ struct ng_fec_bundle {
/* Node private data */
struct ng_fec_private {
- struct arpcom arpcom;
+ struct ifnet *ifp;
struct ifmedia ifmedia;
int if_flags;
int if_error; /* XXX */
@@ -345,7 +345,6 @@ ng_fec_addport(struct ng_fec_private *priv, char *iface)
{
struct ng_fec_bundle *b;
struct ifnet *ifp, *bifp;
- struct arpcom *ac;
struct ifaddr *ifa;
struct sockaddr_dl *sdl;
struct ng_fec_portlist *p, *new;
@@ -354,7 +353,7 @@ ng_fec_addport(struct ng_fec_private *priv, char *iface)
return(EINVAL);
b = &priv->fec_bundle;
- ifp = &priv->arpcom.ac_if;
+ ifp = priv->ifp;
/* Find the interface */
bifp = ifunit(iface);
@@ -400,8 +399,6 @@ ng_fec_addport(struct ng_fec_private *priv, char *iface)
if (new == NULL)
return(ENOMEM);
- ac = (struct arpcom *)bifp;
-
IF_AFDATA_LOCK(bifp);
bifp->if_afdata[AF_NETGRAPH] = priv->node;
IF_AFDATA_UNLOCK(bifp);
@@ -414,9 +411,9 @@ ng_fec_addport(struct ng_fec_private *priv, char *iface)
if (b->fec_ifcnt == 0) {
ifa = ifaddr_byindex(ifp->if_index);
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
- bcopy((char *)ac->ac_enaddr,
- priv->arpcom.ac_enaddr, ETHER_ADDR_LEN);
- bcopy((char *)ac->ac_enaddr,
+ bcopy(IFP2ENADDR(bifp),
+ IFP2ENADDR(priv->ifp), ETHER_ADDR_LEN);
+ bcopy(IFP2ENADDR(bifp),
LLADDR(sdl), ETHER_ADDR_LEN);
}
@@ -425,14 +422,14 @@ ng_fec_addport(struct ng_fec_private *priv, char *iface)
b->fec_ifcnt++;
/* Save the real MAC address. */
- bcopy((char *)ac->ac_enaddr,
+ bcopy(IFP2ENADDR(bifp),
(char *)&new->fec_mac, ETHER_ADDR_LEN);
/* Set up phony MAC address. */
ifa = ifaddr_byindex(bifp->if_index);
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
- bcopy(priv->arpcom.ac_enaddr, ac->ac_enaddr, ETHER_ADDR_LEN);
- bcopy(priv->arpcom.ac_enaddr, LLADDR(sdl), ETHER_ADDR_LEN);
+ bcopy(IFP2ENADDR(priv->ifp), IFP2ENADDR(bifp), ETHER_ADDR_LEN);
+ bcopy(IFP2ENADDR(priv->ifp), LLADDR(sdl), ETHER_ADDR_LEN);
/* Save original input vector */
new->fec_if_input = bifp->if_input;
@@ -456,7 +453,6 @@ ng_fec_delport(struct ng_fec_private *priv, char *iface)
{
struct ng_fec_bundle *b;
struct ifnet *ifp, *bifp;
- struct arpcom *ac;
struct ifaddr *ifa;
struct sockaddr_dl *sdl;
struct ng_fec_portlist *p;
@@ -465,7 +461,7 @@ ng_fec_delport(struct ng_fec_private *priv, char *iface)
return(EINVAL);
b = &priv->fec_bundle;
- ifp = &priv->arpcom.ac_if;
+ ifp = priv->ifp;
/* Find the interface */
bifp = ifunit(iface);
@@ -491,10 +487,9 @@ ng_fec_delport(struct ng_fec_private *priv, char *iface)
(*bifp->if_ioctl)(bifp, SIOCSIFFLAGS, NULL);
/* Restore MAC address. */
- ac = (struct arpcom *)bifp;
ifa = ifaddr_byindex(bifp->if_index);
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
- bcopy((char *)&p->fec_mac, ac->ac_enaddr, ETHER_ADDR_LEN);
+ bcopy((char *)&p->fec_mac, IFP2ENADDR(bifp), ETHER_ADDR_LEN);
bcopy((char *)&p->fec_mac, LLADDR(sdl), ETHER_ADDR_LEN);
/* Restore input vector */
@@ -641,7 +636,7 @@ ng_fec_tick(void *arg)
}
}
- ifp = &priv->arpcom.ac_if;
+ ifp = priv->ifp;
if (ifp->if_flags & IFF_RUNNING)
priv->fec_ch = timeout(ng_fec_tick, priv, hz);
@@ -792,7 +787,7 @@ ng_fec_input(struct ifnet *ifp, struct mbuf *m0)
priv = NG_NODE_PRIVATE(node);
b = &priv->fec_bundle;
- bifp = &priv->arpcom.ac_if;
+ bifp = priv->ifp;
TAILQ_FOREACH(p, &b->ng_fec_ports, fec_list) {
if (p->fec_if == m0->m_pkthdr.rcvif)
@@ -1106,7 +1101,11 @@ ng_fec_constructor(node_p node)
if (priv == NULL)
return (ENOMEM);
- ifp = &priv->arpcom.ac_if;
+ ifp = priv->ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ FREE(priv, M_NETGRAPH);
+ return (ENOSPC);
+ }
b = &priv->fec_bundle;
/* Link them together */
@@ -1114,7 +1113,7 @@ ng_fec_constructor(node_p node)
/* Get an interface unit number */
if ((error = ng_fec_get_unit(&priv->unit)) != 0) {
- FREE(ifp, M_NETGRAPH);
+ if_free(ifp);
FREE(priv, M_NETGRAPH);
return (error);
}
@@ -1145,7 +1144,7 @@ ng_fec_constructor(node_p node)
log(LOG_WARNING, "%s: can't acquire netgraph name\n", ifname);
/* Attach the interface */
- ether_ifattach(ifp, priv->arpcom.ac_enaddr);
+ ether_ifattach(ifp, IFP2ENADDR(priv->ifp));
callout_handle_init(&priv->fec_ch);
/* Override output method with our own */
@@ -1228,14 +1227,15 @@ ng_fec_shutdown(node_p node)
struct ng_fec_portlist *p;
b = &priv->fec_bundle;
- ng_fec_stop(&priv->arpcom.ac_if);
+ ng_fec_stop(priv->ifp);
while (!TAILQ_EMPTY(&b->ng_fec_ports)) {
p = TAILQ_FIRST(&b->ng_fec_ports);
ng_fec_delport(priv, p->fec_if->if_xname);
}
- ether_ifdetach(&priv->arpcom.ac_if);
+ ether_ifdetach(priv->ifp);
+ if_free_type(priv->ifp, IFT_ETHER);
ifmedia_removeall(&priv->ifmedia);
ng_fec_free_unit(priv->unit);
FREE(priv, M_NETGRAPH);
diff --git a/sys/netgraph/ng_gif.c b/sys/netgraph/ng_gif.c
index 135d66c..5d948bd 100644
--- a/sys/netgraph/ng_gif.c
+++ b/sys/netgraph/ng_gif.c
@@ -89,8 +89,8 @@
#include <netgraph/ng_parse.h>
#include <netgraph/ng_gif.h>
-#define IFP2NG(ifp) ((struct ng_node *)((struct gif_softc *)(ifp))->gif_netgraph)
-#define IFP2NG_SET(ifp, val) (((struct gif_softc *)(ifp))->gif_netgraph = (val))
+#define IFP2NG(ifp) ((struct ng_node *)((struct gif_softc *)(ifp->if_softc))->gif_netgraph)
+#define IFP2NG_SET(ifp, val) (((struct gif_softc *)(ifp->if_softc))->gif_netgraph = (val))
/* Per-node private data */
struct private {
diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c
index 21b0289..91b6a3d 100644
--- a/sys/netgraph/ng_iface.c
+++ b/sys/netgraph/ng_iface.c
@@ -470,7 +470,7 @@ ng_iface_constructor(node_p node)
MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH_IFACE, M_NOWAIT|M_ZERO);
if (priv == NULL)
return (ENOMEM);
- MALLOC(ifp, struct ifnet *, sizeof(*ifp), M_NETGRAPH_IFACE, M_NOWAIT|M_ZERO);
+ ifp = if_alloc(IFT_PROPVIRTUAL);
if (ifp == NULL) {
FREE(priv, M_NETGRAPH_IFACE);
return (ENOMEM);
@@ -724,7 +724,7 @@ ng_iface_shutdown(node_p node)
bpfdetach(priv->ifp);
if_detach(priv->ifp);
- FREE(priv->ifp, M_NETGRAPH_IFACE);
+ if_free(priv->ifp);
priv->ifp = NULL;
free_unr(ng_iface_unit, priv->unit);
FREE(priv, M_NETGRAPH_IFACE);
diff --git a/sys/netgraph/ng_sppp.c b/sys/netgraph/ng_sppp.c
index a53c956..b46acbb 100644
--- a/sys/netgraph/ng_sppp.c
+++ b/sys/netgraph/ng_sppp.c
@@ -51,7 +51,7 @@ MALLOC_DEFINE(M_NETGRAPH_SPPP, "netgraph_sppp", "netgraph sppp node ");
/* Node private data */
struct ng_sppp_private {
- struct sppp *pp; /* Our interface */
+ struct ifnet *ifp; /* Our interface */
int unit; /* Interface unit number */
node_p node; /* Our netgraph node */
hook_p hook; /* Hook */
@@ -243,6 +243,7 @@ static int
ng_sppp_constructor (node_p node)
{
struct sppp *pp;
+ struct ifnet *ifp;
priv_p priv;
int error = 0;
@@ -250,15 +251,16 @@ ng_sppp_constructor (node_p node)
MALLOC (priv, priv_p, sizeof(*priv), M_NETGRAPH_SPPP, M_NOWAIT|M_ZERO);
if (priv == NULL)
return (ENOMEM);
- MALLOC (pp, struct sppp *, sizeof(*pp), M_NETGRAPH_SPPP, M_NOWAIT|M_ZERO);
- if (pp == NULL) {
+
+ ifp = if_alloc(IFT_PPP);
+ if (ifp == NULL) {
FREE (priv, M_NETGRAPH_SPPP);
- return (ENOMEM);
+ return (ENOSPC);
}
+ pp = IFP2SP(ifp);
/* Link them together */
- pp->pp_if.if_softc = priv;
- priv->pp = pp;
+ ifp->if_softc = priv;
/* Get an interface unit number */
if ((error = ng_sppp_get_unit(&priv->unit)) != 0) {
@@ -273,21 +275,21 @@ ng_sppp_constructor (node_p node)
priv->node = node;
/* Initialize interface structure */
- if_initname (&pp->pp_if, NG_SPPP_IFACE_NAME, priv->unit);
- pp->pp_if.if_start = ng_sppp_start;
- pp->pp_if.if_ioctl = ng_sppp_ioctl;
- pp->pp_if.if_watchdog = NULL;
- pp->pp_if.if_flags = (IFF_POINTOPOINT|IFF_MULTICAST);
+ if_initname (SP2IFP(pp), NG_SPPP_IFACE_NAME, priv->unit);
+ ifp->if_start = ng_sppp_start;
+ ifp->if_ioctl = ng_sppp_ioctl;
+ ifp->if_watchdog = NULL;
+ ifp->if_flags = (IFF_POINTOPOINT|IFF_MULTICAST);
/* Give this node the same name as the interface (if possible) */
- if (ng_name_node(node, pp->pp_if.if_xname) != 0)
+ if (ng_name_node(node, SP2IFP(pp)->if_xname) != 0)
log (LOG_WARNING, "%s: can't acquire netgraph name\n",
- pp->pp_if.if_xname);
+ SP2IFP(pp)->if_xname);
/* Attach the interface */
- sppp_attach (&pp->pp_if);
- if_attach (&pp->pp_if);
- bpfattach (&pp->pp_if, DLT_NULL, sizeof(u_int));
+ sppp_attach (ifp);
+ if_attach (ifp);
+ bpfattach (ifp, DLT_NULL, sizeof(u_int));
/* Done */
return (0);
@@ -322,7 +324,7 @@ ng_sppp_rcvmsg (node_p node, item_p item, hook_p lasthook)
const priv_p priv = NG_NODE_PRIVATE (node);
struct ng_mesg *msg = NULL;
struct ng_mesg *resp = NULL;
- struct sppp *const pp = priv->pp;
+ struct sppp *const pp = IFP2SP(priv->ifp);
int error = 0;
NGI_GET_MSG (item, msg);
@@ -335,7 +337,7 @@ ng_sppp_rcvmsg (node_p node, item_p item, hook_p lasthook)
error = ENOMEM;
break;
}
- strlcpy(resp->data, pp->pp_if.if_xname, IFNAMSIZ);
+ strlcpy(resp->data, SP2IFP(pp)->if_xname, IFNAMSIZ);
break;
default:
@@ -360,29 +362,29 @@ ng_sppp_rcvdata (hook_p hook, item_p item)
{
struct mbuf *m;
const priv_p priv = NG_NODE_PRIVATE (NG_HOOK_NODE (hook));
- struct sppp *const pp = priv->pp;
+ struct sppp *const pp = IFP2SP(priv->ifp);
NGI_GET_M (item, m);
NG_FREE_ITEM (item);
/* Sanity checks */
KASSERT (m->m_flags & M_PKTHDR, ("%s: not pkthdr", __func__));
- if ((pp->pp_if.if_flags & IFF_UP) == 0) {
+ if ((SP2IFP(pp)->if_flags & IFF_UP) == 0) {
NG_FREE_M (m);
return (ENETDOWN);
}
/* Update interface stats */
- pp->pp_if.if_ipackets++;
+ SP2IFP(pp)->if_ipackets++;
/* Note receiving interface */
- m->m_pkthdr.rcvif = &pp->pp_if;
+ m->m_pkthdr.rcvif = SP2IFP(pp);
/* Berkeley packet filter */
- if (pp->pp_if.if_bpf)
- BPF_MTAP (&pp->pp_if, m);
+ if (SP2IFP(pp)->if_bpf)
+ BPF_MTAP (SP2IFP(pp), m);
/* Send packet */
- sppp_input (&pp->pp_if, m);
+ sppp_input (SP2IFP(pp), m);
return 0;
}
@@ -394,11 +396,10 @@ ng_sppp_shutdown (node_p node)
{
const priv_p priv = NG_NODE_PRIVATE(node);
/* Detach from the packet filter list of interfaces. */
- bpfdetach (&priv->pp->pp_if);
- sppp_detach (&priv->pp->pp_if);
- if_detach (&priv->pp->pp_if);
- FREE (priv->pp, M_NETGRAPH_SPPP);
- priv->pp = NULL;
+ bpfdetach (priv->ifp);
+ sppp_detach (priv->ifp);
+ if_detach (priv->ifp);
+ if_free(priv->ifp);
ng_sppp_free_unit (priv->unit);
FREE (priv, M_NETGRAPH_SPPP);
NG_NODE_SET_PRIVATE (node, NULL);
OpenPOWER on IntegriCloud