View | Details | Raw Unified | Return to bug 185023
Collapse All | Expand All

(-)/sys/net/if_tun.c (-16 / +17 lines)
Lines 454-483 Link Here
454
	CURVNET_SET(ifp->if_vnet);
454
	CURVNET_SET(ifp->if_vnet);
455
	IFQ_PURGE(&ifp->if_snd);
455
	IFQ_PURGE(&ifp->if_snd);
456
456
457
	if (ifp->if_flags & IFF_UP) {
457
	if ((ifp->if_flags & (IFF_UP | IFF_LINK0)) == IFF_UP) {
458
		mtx_unlock(&tp->tun_mtx);
458
		mtx_unlock(&tp->tun_mtx);
459
		if_down(ifp);
459
		if_down(ifp);
460
		mtx_lock(&tp->tun_mtx);
460
		mtx_lock(&tp->tun_mtx);
461
	}
462
461
463
	/* Delete all addresses and routes which reference this interface. */
462
		/* Delete all addresses and routes which reference this interface. */
464
	if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
463
		if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
465
		struct ifaddr *ifa;
464
			struct ifaddr *ifa;
466
465
467
		ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
466
			ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
468
		mtx_unlock(&tp->tun_mtx);
467
			mtx_unlock(&tp->tun_mtx);
469
		CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
468
			CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
470
			/* deal w/IPv4 PtP destination; unlocked read */
469
				/* deal w/IPv4 PtP destination; unlocked read */
471
			if (ifa->ifa_addr->sa_family == AF_INET) {
470
				if (ifa->ifa_addr->sa_family == AF_INET) {
472
				rtinit(ifa, (int)RTM_DELETE,
471
					rtinit(ifa, (int)RTM_DELETE,
473
				    tp->tun_flags & TUN_DSTADDR ? RTF_HOST : 0);
472
					    tp->tun_flags & TUN_DSTADDR ? RTF_HOST : 0);
474
			} else {
473
				} else {
475
				rtinit(ifa, (int)RTM_DELETE, 0);
474
					rtinit(ifa, (int)RTM_DELETE, 0);
475
				}
476
			}
476
			}
477
			if_purgeaddrs(ifp);
478
			mtx_lock(&tp->tun_mtx);
477
		}
479
		}
478
		if_purgeaddrs(ifp);
479
		mtx_lock(&tp->tun_mtx);
480
	}
480
	}
481
481
	if_link_state_change(ifp, LINK_STATE_DOWN);
482
	if_link_state_change(ifp, LINK_STATE_DOWN);
482
	CURVNET_RESTORE();
483
	CURVNET_RESTORE();
483
484
(-)/usr/share/man/man4/tun.4 (-2 / +5 lines)
Lines 308-317 Link Here
308
for read; selecting for write is pointless, and always succeeds, since
308
for read; selecting for write is pointless, and always succeeds, since
309
writes are always non-blocking.
309
writes are always non-blocking.
310
.Pp
310
.Pp
311
On the last close of the data device, by default, the interface is
311
On the last close of the data device, the interface is
312
brought down
312
brought down
313
(as if with
313
(as if with
314
.Nm ifconfig Ar tunN Cm down ) .
314
.Nm ifconfig Ar tunN Cm down ) ,
315
unless the
316
.Dv IFF_LINK0
317
flag is set.
315
All queued packets are thrown away.
318
All queued packets are thrown away.
316
If the interface is up when the data device is not open
319
If the interface is up when the data device is not open
317
output packets are always thrown away rather than letting
320
output packets are always thrown away rather than letting

Return to bug 185023