Module Name: src Committed By: roy Date: Sun Sep 27 19:25:54 UTC 2020
Modified Files: src/sys/net: if_tun.c Log Message: tun: Report link state based on if the interface has been opened or not This mirrors tap(4). To generate a diff of this commit: cvs rdiff -u -r1.160 -r1.161 src/sys/net/if_tun.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/net/if_tun.c diff -u src/sys/net/if_tun.c:1.160 src/sys/net/if_tun.c:1.161 --- src/sys/net/if_tun.c:1.160 Sat Aug 29 07:14:50 2020 +++ src/sys/net/if_tun.c Sun Sep 27 19:25:54 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_tun.c,v 1.160 2020/08/29 07:14:50 maxv Exp $ */ +/* $NetBSD: if_tun.c,v 1.161 2020/09/27 19:25:54 roy Exp $ */ /* * Copyright (c) 1988, Julian Onions <j...@cs.nott.ac.uk> @@ -19,7 +19,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.160 2020/08/29 07:14:50 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.161 2020/09/27 19:25:54 roy Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -256,12 +256,12 @@ tunattach0(struct tun_softc *tp) ifp->if_start = tunstart; #endif ifp->if_flags = IFF_POINTOPOINT; - ifp->if_extflags = IFEF_NO_LINK_STATE_CHANGE; ifp->if_type = IFT_TUNNEL; ifp->if_snd.ifq_maxlen = ifqmaxlen; ifp->if_dlt = DLT_NULL; IFQ_SET_READY(&ifp->if_snd); if_attach(ifp); + ifp->if_link_state = LINK_STATE_DOWN; if_alloc_sadl(ifp); bpf_attach(ifp, DLT_NULL, sizeof(uint32_t)); } @@ -347,6 +347,7 @@ tunopen(dev_t dev, int flag, int mode, s ifp = &tp->tun_if; tp->tun_flags |= TUN_OPEN; TUNDEBUG("%s: open\n", ifp->if_xname); + if_link_state_change(ifp, LINK_STATE_UP); mutex_exit(&tp->tun_lock); @@ -411,6 +412,9 @@ tunclose(dev_t dev, int flag, int mode, } } } + + if_link_state_change(ifp, LINK_STATE_DOWN); + out_nolock: return 0; }