summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/ng_eiface.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2005-08-09 10:20:02 +0000
committerrwatson <rwatson@FreeBSD.org>2005-08-09 10:20:02 +0000
commit5d770a09e85126b8b3e9fe302c36350a90210cbe (patch)
treebb70e59641e2310a3c26ec449af5ab0cb7420d9d /sys/netgraph/ng_eiface.c
parent74759aaa78777146f23aa05c856f574efdfb41d9 (diff)
downloadFreeBSD-src-5d770a09e85126b8b3e9fe302c36350a90210cbe.zip
FreeBSD-src-5d770a09e85126b8b3e9fe302c36350a90210cbe.tar.gz
Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to ifnet.if_drv_flags. Device drivers are now responsible for synchronizing access to these flags, as they are in if_drv_flags. This helps prevent races between the network stack and device driver in maintaining the interface flags field. Many __FreeBSD__ and __FreeBSD_version checks maintained and continued; some less so. Reviewed by: pjd, bz MFC after: 7 days
Diffstat (limited to 'sys/netgraph/ng_eiface.c')
-rw-r--r--sys/netgraph/ng_eiface.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/sys/netgraph/ng_eiface.c b/sys/netgraph/ng_eiface.c
index 7ca104f..6a21cba 100644
--- a/sys/netgraph/ng_eiface.c
+++ b/sys/netgraph/ng_eiface.c
@@ -147,13 +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 (ifr->ifr_flags & IFF_UP) {
- if (!(ifp->if_flags & IFF_RUNNING)) {
- ifp->if_flags &= ~(IFF_OACTIVE);
- ifp->if_flags |= IFF_RUNNING;
+ if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
+ ifp->if_drv_flags &= ~(IFF_DRV_OACTIVE);
+ ifp->if_drv_flags |= IFF_DRV_RUNNING;
}
} else {
- if (ifp->if_flags & IFF_RUNNING)
- ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
+ if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+ ifp->if_drv_flags &= ~(IFF_DRV_RUNNING |
+ IFF_DRV_OACTIVE);
}
break;
@@ -192,8 +193,8 @@ ng_eiface_init(void *xsc)
s = splimp();
- ifp->if_flags |= IFF_RUNNING;
- ifp->if_flags &= ~IFF_OACTIVE;
+ ifp->if_drv_flags |= IFF_DRV_RUNNING;
+ ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
splx(s);
}
@@ -212,14 +213,16 @@ ng_eiface_start2(node_p node, hook_p hook, void *arg1, int arg2)
struct mbuf *m;
/* Check interface flags */
- if ((ifp->if_flags & (IFF_UP | IFF_RUNNING)) != (IFF_UP | IFF_RUNNING))
+
+ if (!((ifp->if_flags & IFF_UP) &&
+ (ifp->if_drv_flags & IFF_DRV_RUNNING)))
return;
/* Don't do anything if output is active */
- if (ifp->if_flags & IFF_OACTIVE)
+ if (ifp->if_drv_flags & IFF_DRV_OACTIVE)
return;
- ifp->if_flags |= IFF_OACTIVE;
+ ifp->if_drv_flags |= IFF_DRV_OACTIVE;
/*
* Grab a packet to transmit.
@@ -228,7 +231,7 @@ ng_eiface_start2(node_p node, hook_p hook, void *arg1, int arg2)
/* If there's nothing to send, return. */
if (m == NULL) {
- ifp->if_flags &= ~IFF_OACTIVE;
+ ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
return;
}
@@ -254,7 +257,7 @@ ng_eiface_start2(node_p node, hook_p hook, void *arg1, int arg2)
ifp->if_opackets++;
}
- ifp->if_flags &= ~IFF_OACTIVE;
+ ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
return;
}
@@ -523,8 +526,8 @@ ng_eiface_rcvdata(hook_p hook, item_p item)
NGI_GET_M(item, m);
NG_FREE_ITEM(item);
- if ((ifp->if_flags & (IFF_UP | IFF_RUNNING)) !=
- (IFF_UP | IFF_RUNNING)) {
+ if (!((ifp->if_flags & IFF_UP) &&
+ (ifp->if_drv_flags & IFF_DRV_RUNNING))) {
NG_FREE_M(m);
return (ENETDOWN);
}
OpenPOWER on IntegriCloud