Module Name: src Committed By: roy Date: Sun Sep 27 13:44:47 UTC 2020
Modified Files: src/share/man/man4: tap.4 src/sys/net: if_tap.c Log Message: tap: Report link state based on if the interface has been opened or not While a nice addition, it does render tap(4) useless as a bridge(4) endpoint. We now have vether(4) for use as bridge endpoint. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/share/man/man4/tap.4 cvs rdiff -u -r1.118 -r1.119 src/sys/net/if_tap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/share/man/man4/tap.4 diff -u src/share/man/man4/tap.4:1.12 src/share/man/man4/tap.4:1.13 --- src/share/man/man4/tap.4:1.12 Tue Aug 14 06:21:36 2018 +++ src/share/man/man4/tap.4 Sun Sep 27 13:44:47 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: tap.4,v 1.12 2018/08/14 06:21:36 maxv Exp $ +.\" $NetBSD: tap.4,v 1.13 2020/09/27 13:44:47 roy Exp $ .\" .\" Copyright (c) 2004, 2005 The NetBSD Foundation. .\" All rights reserved. @@ -24,7 +24,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd August 14, 2018 +.Dd September 27, 2020 .Dt TAP 4 .Os .Sh NAME @@ -170,9 +170,21 @@ individual character device nodes .Xr bridge 4 , .Xr l2tp 4 , .Xr tun 4 , +.Xr vether 4 , .Xr ifconfig 8 .Sh HISTORY The .Nm driver first appeared in .Nx 3.0 . +.Sh CAVEATS +Starting from +.Nx 10.0 , +the +.Nm +driver can no longer be used as a +.Xr bridge 4 +endpoint because it supports a link state based on if it has been opened or not. +Use the +.Xr vether 4 +driver instead as it's been explicitly designed for this purpose. Index: src/sys/net/if_tap.c diff -u src/sys/net/if_tap.c:1.118 src/sys/net/if_tap.c:1.119 --- src/sys/net/if_tap.c:1.118 Sat Sep 26 19:38:45 2020 +++ src/sys/net/if_tap.c Sun Sep 27 13:44:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_tap.c,v 1.118 2020/09/26 19:38:45 roy Exp $ */ +/* $NetBSD: if_tap.c,v 1.119 2020/09/27 13:44:47 roy Exp $ */ /* * Copyright (c) 2003, 2004, 2008, 2009 The NetBSD Foundation. @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.118 2020/09/26 19:38:45 roy Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.119 2020/09/27 13:44:47 roy Exp $"); #if defined(_KERNEL_OPT) @@ -334,9 +334,8 @@ tap_attach(device_t parent, device_t sel strcpy(ifp->if_xname, device_xname(self)); ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - ifp->if_extflags = IFEF_NO_LINK_STATE_CHANGE; #ifdef NET_MPSAFE - ifp->if_extflags |= IFEF_MPSAFE; + ifp->if_extflags = IFEF_MPSAFE; #endif ifp->if_ioctl = tap_ioctl; ifp->if_start = tap_start; @@ -358,6 +357,8 @@ tap_attach(device_t parent, device_t sel } ifp->if_percpuq = if_percpuq_create(ifp); ether_ifattach(ifp, enaddr); + /* Opening the device will bring the link state up. */ + ifp->if_link_state = LINK_STATE_DOWN; if_register(ifp); /* @@ -708,6 +709,8 @@ tap_cdev_open(dev_t dev, int flags, int if (sc->sc_flags & TAP_INUSE) return EBUSY; sc->sc_flags |= TAP_INUSE; + if_link_state_change(&sc->sc_ec.ec_if, LINK_STATE_UP); + return 0; } @@ -844,6 +847,7 @@ tap_dev_close(struct tap_softc *sc) sc->sc_sih = NULL; } sc->sc_flags &= ~(TAP_INUSE | TAP_ASYNCIO); + if_link_state_change(ifp, LINK_STATE_DOWN); return 0; }