summaryrefslogtreecommitdiffstats
path: root/sys/net/if_spppsubr.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/net/if_spppsubr.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/net/if_spppsubr.c')
-rw-r--r--sys/net/if_spppsubr.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c
index b3d1df5..875cb1c 100644
--- a/sys/net/if_spppsubr.c
+++ b/sys/net/if_spppsubr.c
@@ -839,8 +839,9 @@ sppp_output(struct ifnet *ifp, struct mbuf *m,
s = splimp();
SPPP_LOCK(sp);
- if ((ifp->if_flags & IFF_UP) == 0 ||
- (ifp->if_flags & (IFF_RUNNING | IFF_AUTO)) == 0) {
+ if (!(ifp->if_flags & IFF_UP) ||
+ (!(ifp->if_flags & IFF_AUTO) &&
+ !(ifp->if_drv_flags & IFF_DRV_RUNNING))) {
#ifdef INET6
drop:
#endif
@@ -850,7 +851,8 @@ sppp_output(struct ifnet *ifp, struct mbuf *m,
return (ENETDOWN);
}
- if ((ifp->if_flags & (IFF_RUNNING | IFF_AUTO)) == IFF_AUTO) {
+ if ((ifp->if_flags & IFF_AUTO) &&
+ !(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
#ifdef INET6
/*
* XXX
@@ -868,7 +870,7 @@ sppp_output(struct ifnet *ifp, struct mbuf *m,
* Interface is not yet running, but auto-dial. Need
* to start LCP for it.
*/
- ifp->if_flags |= IFF_RUNNING;
+ ifp->if_drv_flags |= IFF_DRV_RUNNING;
splx(s);
lcp.Open(sp);
s = splimp();
@@ -1268,9 +1270,9 @@ sppp_ioctl(struct ifnet *ifp, IOCTL_CMD_T cmd, void *data)
case SIOCSIFFLAGS:
going_up = ifp->if_flags & IFF_UP &&
- (ifp->if_flags & IFF_RUNNING) == 0;
+ (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0;
going_down = (ifp->if_flags & IFF_UP) == 0 &&
- ifp->if_flags & IFF_RUNNING;
+ ifp->if_drv_flags & IFF_DRV_RUNNING;
newmode = ifp->if_flags & IFF_PASSIVE;
if (!newmode)
@@ -1286,7 +1288,7 @@ sppp_ioctl(struct ifnet *ifp, IOCTL_CMD_T cmd, void *data)
if (newmode != sp->pp_mode) {
going_down = 1;
if (!going_up)
- going_up = ifp->if_flags & IFF_RUNNING;
+ going_up = ifp->if_drv_flags & IFF_DRV_RUNNING;
}
if (going_down) {
@@ -1296,7 +1298,7 @@ sppp_ioctl(struct ifnet *ifp, IOCTL_CMD_T cmd, void *data)
else if (sp->pp_tlf)
(sp->pp_tlf)(sp);
sppp_flush_unlocked(ifp);
- ifp->if_flags &= ~IFF_RUNNING;
+ ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
sp->pp_mode = newmode;
}
@@ -1306,14 +1308,14 @@ sppp_ioctl(struct ifnet *ifp, IOCTL_CMD_T cmd, void *data)
lcp.Close(sp);
sp->pp_mode = newmode;
if (sp->pp_mode == 0) {
- ifp->if_flags |= IFF_RUNNING;
+ ifp->if_drv_flags |= IFF_DRV_RUNNING;
lcp.Open(sp);
}
if ((sp->pp_mode == IFF_CISCO) ||
(sp->pp_mode == PP_FR)) {
if (sp->pp_tls)
(sp->pp_tls)(sp);
- ifp->if_flags |= IFF_RUNNING;
+ ifp->if_drv_flags |= IFF_DRV_RUNNING;
}
}
@@ -1428,7 +1430,7 @@ sppp_cisco_input(struct sppp *sp, struct mbuf *m)
}
sp->pp_loopcnt = 0;
if (! (ifp->if_flags & IFF_UP) &&
- (ifp->if_flags & IFF_RUNNING)) {
+ (ifp->if_drv_flags & IFF_DRV_RUNNING)) {
if_up(ifp);
printf (SPP_FMT "up\n", SPP_ARGS(ifp));
}
@@ -2268,7 +2270,7 @@ sppp_lcp_up(struct sppp *sp)
if (debug)
log(LOG_DEBUG,
SPP_FMT "Up event", SPP_ARGS(ifp));
- ifp->if_flags |= IFF_RUNNING;
+ ifp->if_drv_flags |= IFF_DRV_RUNNING;
if (sp->state[IDX_LCP] == STATE_INITIAL) {
if (debug)
log(-1, "(incoming call)\n");
@@ -2278,7 +2280,7 @@ sppp_lcp_up(struct sppp *sp)
log(-1, "\n");
} else if ((ifp->if_flags & (IFF_AUTO | IFF_PASSIVE)) == 0 &&
(sp->state[IDX_LCP] == STATE_INITIAL)) {
- ifp->if_flags |= IFF_RUNNING;
+ ifp->if_drv_flags |= IFF_DRV_RUNNING;
lcp.Open(sp);
}
@@ -2312,7 +2314,7 @@ sppp_lcp_down(struct sppp *sp)
sp->pp_flags &= ~PP_CALLIN;
if (sp->state[IDX_LCP] != STATE_INITIAL)
lcp.Close(sp);
- ifp->if_flags &= ~IFF_RUNNING;
+ ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
}
}
@@ -2718,7 +2720,7 @@ sppp_lcp_tlu(struct sppp *sp)
/* XXX ? */
if (! (ifp->if_flags & IFF_UP) &&
- (ifp->if_flags & IFF_RUNNING)) {
+ (ifp->if_drv_flags & IFF_DRV_RUNNING)) {
/* Coming out of loopback mode. */
if_up(ifp);
printf (SPP_FMT "up\n", SPP_ARGS(ifp));
@@ -4819,7 +4821,7 @@ sppp_keepalive(void *dummy)
SPPP_LOCK(sp);
/* Keepalive mode disabled or channel down? */
if (! (sp->pp_flags & PP_KEEPALIVE) ||
- ! (ifp->if_flags & IFF_RUNNING))
+ ! (ifp->if_drv_flags & IFF_DRV_RUNNING))
goto out;
if (sp->pp_mode == PP_FR) {
OpenPOWER on IntegriCloud