FreeBSD Bugzilla – Attachment 155148 Details for
Bug 199136
[if_tap] Added down_on_close sysctl variable to tap(4)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
patch-sys-net-if_tap-downonclose-2.patch (text/plain), 3.60 KB, created by
Yuri Victorovich
on 2015-04-03 06:52:03 UTC
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Yuri Victorovich
Created:
2015-04-03 06:52:03 UTC
Size:
3.60 KB
patch
obsolete
>Index: sys/net/if_tap.c >=================================================================== >--- sys/net/if_tap.c (revision 280976) >+++ sys/net/if_tap.c (working copy) >@@ -153,8 +153,9 @@ > static struct mtx tapmtx; > static int tapdebug = 0; /* debug flag */ > static int tapuopen = 0; /* allow user open() */ >-static int tapuponopen = 0; /* IFF_UP on open() */ >-static int tapdclone = 1; /* enable devfs cloning */ >+static int tapuponopen = 0; /* IFF_UP on open() */ >+static int tapdownonclose = 0; /* IFF_DOWN on close() */ >+static int tapdclone = 1; /* enable devfs cloning */ > static SLIST_HEAD(, tap_softc) taphead; /* first device */ > static struct clonedevs *tapclones; > >@@ -169,6 +170,8 @@ > "Allow user to open /dev/tap (based on node permissions)"); > SYSCTL_INT(_net_link_tap, OID_AUTO, up_on_open, CTLFLAG_RW, &tapuponopen, 0, > "Bring interface up when /dev/tap is opened"); >+SYSCTL_INT(_net_link_tap, OID_AUTO, down_on_close, CTLFLAG_RW, &tapdownonclose, 0, >+ "Bring interface down when /dev/tap is closed"); > SYSCTL_INT(_net_link_tap, OID_AUTO, devfs_cloning, CTLFLAG_RW, &tapdclone, 0, > "Enably legacy devfs interface creation"); > SYSCTL_INT(_net_link_tap, OID_AUTO, debug, CTLFLAG_RW, &tapdebug, 0, ""); >@@ -504,6 +507,8 @@ > > ifp->if_drv_flags |= IFF_DRV_RUNNING; > ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; >+ if (ifp->if_flags & IFF_UP) >+ tp->tap_flags |= TAP_IFWASUP; > if (tapuponopen) > ifp->if_flags |= IFF_UP; > if_link_state_change(ifp, LINK_STATE_UP); >@@ -526,6 +531,7 @@ > struct ifaddr *ifa; > struct tap_softc *tp = dev->si_drv1; > struct ifnet *ifp = tp->tap_ifp; >+ int keep_up; > > /* junk all pending output */ > mtx_lock(&tp->tap_mtx); >@@ -537,6 +543,8 @@ > * interface, if we are in VMnet mode. just close the device. > */ > >+ keep_up = !tapdownonclose && tp->tap_flags & TAP_IFWASUP; >+ > if (((tp->tap_flags & TAP_VMNET) == 0) && (ifp->if_flags & IFF_UP)) { > mtx_unlock(&tp->tap_mtx); > if_down(ifp); >@@ -543,16 +551,21 @@ > mtx_lock(&tp->tap_mtx); > if (ifp->if_drv_flags & IFF_DRV_RUNNING) { > ifp->if_drv_flags &= ~IFF_DRV_RUNNING; >- mtx_unlock(&tp->tap_mtx); >- TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { >- rtinit(ifa, (int)RTM_DELETE, 0); >+ if (!keep_up) { >+ mtx_unlock(&tp->tap_mtx); >+ TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { >+ rtinit(ifa, (int)RTM_DELETE, 0); >+ } >+ if_purgeaddrs(ifp); >+ mtx_lock(&tp->tap_mtx); > } >- if_purgeaddrs(ifp); >- mtx_lock(&tp->tap_mtx); > } > } > > if_link_state_change(ifp, LINK_STATE_DOWN); >+ if (keep_up) >+ ifp->if_flags |= IFF_UP; >+ tp->tap_flags &= ~TAP_IFWASUP; > CURVNET_RESTORE(); > > funsetown(&tp->tap_sigio); >Index: sys/net/if_tapvar.h >=================================================================== >--- sys/net/if_tapvar.h (revision 280976) >+++ sys/net/if_tapvar.h (working copy) >@@ -54,6 +54,7 @@ > #define TAP_ASYNC (1 << 3) > #define TAP_READY (TAP_OPEN|TAP_INITED) > #define TAP_VMNET (1 << 4) >+#define TAP_IFWASUP (1 << 5) > > u_int8_t ether_addr[ETHER_ADDR_LEN]; /* ether addr of the remote side */ > >Index: share/man/man4/tap.4 >=================================================================== >--- share/man/man4/tap.4 (revision 280964) >+++ share/man/man4/tap.4 (working copy) >@@ -131,6 +131,16 @@ > is non-zero, the tunnel device will be marked > .Dq up > when the control device is opened. >+If the >+.Xr sysctl 8 >+variable >+.Va net.link.tap.down_on_close >+is non-zero, the tunnel device will be marked >+.Dq down >+when the control device is closed, otherwise the interface >+state will be preserved if it was >+.Dq up >+when it was opened. > A > .Fn read > call will return an error
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 199136
:
155148
|
155152
|
155174