summaryrefslogtreecommitdiff
path: root/sys/net/if_tun.c
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2022-02-15 04:16:11 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2022-02-15 04:16:11 +0000
commite581c1ddf11284f89c48573146389c774195416f (patch)
treec087aa7e00c618945e2ea7aeed8b80dd7cd94c13 /sys/net/if_tun.c
parent4793b52348693deb6a876390d47b70c418d1d68d (diff)
make tun_link_state take the ifnet pointer instead of tun_softc.
it only works on struct ifnet data, so passing ifp makes it clearer what's actually being manipulated. also fix tun_dev_open so tun_link_state is called before if_put instead of immediately after.
Diffstat (limited to 'sys/net/if_tun.c')
-rw-r--r--sys/net/if_tun.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index 46a0a2d4735..ee42263899d 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_tun.c,v 1.231 2021/03/09 20:05:14 anton Exp $ */
+/* $OpenBSD: if_tun.c,v 1.232 2022/02/15 04:16:10 dlg Exp $ */
/* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */
/*
@@ -130,7 +130,7 @@ int filt_tunread(struct knote *, long);
int filt_tunwrite(struct knote *, long);
void filt_tunrdetach(struct knote *);
void filt_tunwdetach(struct knote *);
-void tun_link_state(struct tun_softc *, int);
+void tun_link_state(struct ifnet *, int);
const struct filterops tunread_filtops = {
.f_flags = FILTEROP_ISFD,
@@ -416,8 +416,8 @@ tun_dev_open(dev_t dev, const struct if_clone *ifc, int mode, struct proc *p)
/* automatically mark the interface running on open */
SET(ifp->if_flags, IFF_UP | IFF_RUNNING);
+ tun_link_state(ifp, LINK_STATE_FULL_DUPLEX);
if_put(ifp);
- tun_link_state(sc, LINK_STATE_FULL_DUPLEX);
return (0);
}
@@ -470,7 +470,7 @@ tun_dev_close(dev_t dev, struct proc *p)
strlcpy(name, ifp->if_xname, sizeof(name));
} else {
CLR(ifp->if_flags, IFF_UP | IFF_RUNNING);
- tun_link_state(sc, LINK_STATE_DOWN);
+ tun_link_state(ifp, LINK_STATE_DOWN);
}
}
@@ -1066,10 +1066,8 @@ tun_start(struct ifnet *ifp)
}
void
-tun_link_state(struct tun_softc *sc, int link_state)
+tun_link_state(struct ifnet *ifp, int link_state)
{
- struct ifnet *ifp = &sc->sc_if;
-
if (ifp->if_link_state != link_state) {
ifp->if_link_state = link_state;
if_link_state_change(ifp);