Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net tap: Report link state based on if the interface has...



details:   https://anonhg.NetBSD.org/src/rev/d6b127b985dd
branches:  trunk
changeset: 939664:d6b127b985dd
user:      roy <roy%NetBSD.org@localhost>
date:      Sun Sep 27 13:44:47 2020 +0000

description:
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.

diffstat:

 share/man/man4/tap.4 |  16 ++++++++++++++--
 sys/net/if_tap.c     |  12 ++++++++----
 2 files changed, 22 insertions(+), 6 deletions(-)

diffs (95 lines):

diff -r d58f09053e14 -r d6b127b985dd share/man/man4/tap.4
--- a/share/man/man4/tap.4      Sun Sep 27 13:31:04 2020 +0000
+++ b/share/man/man4/tap.4      Sun Sep 27 13:44:47 2020 +0000
@@ -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 @@
 .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.
diff -r d58f09053e14 -r d6b127b985dd sys/net/if_tap.c
--- a/sys/net/if_tap.c  Sun Sep 27 13:31:04 2020 +0000
+++ b/sys/net/if_tap.c  Sun Sep 27 13:44:47 2020 +0000
@@ -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 @@
        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 @@
        }
        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 @@
        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 @@
                sc->sc_sih = NULL;
        }
        sc->sc_flags &= ~(TAP_INUSE | TAP_ASYNCIO);
+       if_link_state_change(ifp, LINK_STATE_DOWN);
 
        return 0;
 }



Home | Main Index | Thread Index | Old Index