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

(-)sys/net/if_tapvar.h (+5 lines)
Lines 41-46 Link Here
41
#ifndef _NET_IF_TAPVAR_H_
41
#ifndef _NET_IF_TAPVAR_H_
42
#define _NET_IF_TAPVAR_H_
42
#define _NET_IF_TAPVAR_H_
43
43
44
#include <sys/sysctl.h>
45
44
/*
46
/*
45
 * tap_mtx locks tap_flags, tap_pid.  tap_next locked with global tapmtx.
47
 * tap_mtx locks tap_flags, tap_pid.  tap_next locked with global tapmtx.
46
 * Other fields locked by owning subsystems.
48
 * Other fields locked by owning subsystems.
Lines 64-69 struct tap_softc { Link Here
64
	SLIST_ENTRY(tap_softc)	tap_next;	/* next device in chain      */
66
	SLIST_ENTRY(tap_softc)	tap_next;	/* next device in chain      */
65
	struct cdev *tap_dev;
67
	struct cdev *tap_dev;
66
	struct mtx	 tap_mtx;		/* per-softc mutex */
68
	struct mtx	 tap_mtx;		/* per-softc mutex */
69
70
	struct sysctl_ctx_list	ctx;		/* sysctl variables */
71
	int		 keep_up;
67
};
72
};
68
73
69
#endif /* !_NET_IF_TAPVAR_H_ */
74
#endif /* !_NET_IF_TAPVAR_H_ */
(-)sys/net/if_tap.c (-1 / +15 lines)
Lines 229-234 tap_clone_destroy(struct ifnet *ifp) Link Here
229
{
229
{
230
	struct tap_softc *tp = ifp->if_softc;
230
	struct tap_softc *tp = ifp->if_softc;
231
231
232
	sysctl_ctx_free(&tp->ctx);
232
	mtx_lock(&tapmtx);
233
	mtx_lock(&tapmtx);
233
	SLIST_REMOVE(&taphead, tp, tap_softc, tap_next);
234
	SLIST_REMOVE(&taphead, tp, tap_softc, tap_next);
234
	mtx_unlock(&tapmtx);
235
	mtx_unlock(&tapmtx);
Lines 399-404 tapcreate(struct cdev *dev) Link Here
399
	int			 unit;
400
	int			 unit;
400
	char			*name = NULL;
401
	char			*name = NULL;
401
	u_char			eaddr[6];
402
	u_char			eaddr[6];
403
	char			 num[14];	/* sufficient for 32 bits */
404
	struct sysctl_oid	*oid;
402
405
403
	dev->si_flags &= ~SI_CHEAPCLONE;
406
	dev->si_flags &= ~SI_CHEAPCLONE;
404
407
Lines 433-438 tapcreate(struct cdev *dev) Link Here
433
	ifp = tp->tap_ifp = if_alloc(IFT_ETHER);
436
	ifp = tp->tap_ifp = if_alloc(IFT_ETHER);
434
	if (ifp == NULL)
437
	if (ifp == NULL)
435
		panic("%s%d: can not if_alloc()", name, unit);
438
		panic("%s%d: can not if_alloc()", name, unit);
439
		
440
	sysctl_ctx_init(&tp->ctx);
441
	snprintf(num, sizeof(num), "%u", unit);
442
	tp->keep_up = 0;
443
	oid = SYSCTL_ADD_NODE(&tp->ctx, &SYSCTL_NODE_CHILDREN(_net_link, tap),
444
		OID_AUTO, num, CTLFLAG_RD, NULL, "");
445
	SYSCTL_ADD_INT(&tp->ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
446
		"keep_up", CTLTYPE_INT|CTLFLAG_RW, &tp->keep_up, tp->keep_up,
447
		"Keep interface up on close");
448
436
	ifp->if_softc = tp;
449
	ifp->if_softc = tp;
437
	if_initname(ifp, name, unit);
450
	if_initname(ifp, name, unit);
438
	ifp->if_init = tapifinit;
451
	ifp->if_init = tapifinit;
Lines 528-534 tapclose(struct cdev *dev, int foo, int Link Here
528
	 * interface, if we are in VMnet mode. just close the device.
541
	 * interface, if we are in VMnet mode. just close the device.
529
	 */
542
	 */
530
543
531
	if (((tp->tap_flags & TAP_VMNET) == 0) && (ifp->if_flags & IFF_UP)) {
544
	if (!tp->keep_up &&
545
	    ((tp->tap_flags & TAP_VMNET) == 0) && (ifp->if_flags & IFF_UP)) {
532
		mtx_unlock(&tp->tap_mtx);
546
		mtx_unlock(&tp->tap_mtx);
533
		if_down(ifp);
547
		if_down(ifp);
534
		mtx_lock(&tp->tap_mtx);
548
		mtx_lock(&tp->tap_mtx);
(-)share/man/man4/tap.4 (-1 / +11 lines)
Lines 268-274 Link Here
268
.Dq ifconfig tap Ns Sy N No down )
268
.Dq ifconfig tap Ns Sy N No down )
269
unless the device is a
269
unless the device is a
270
.Em VMnet
270
.Em VMnet
271
device.
271
device (but see
272
.Sx SYSCTL VARIABLES
273
section below).
272
All queued frames are thrown away.
274
All queued frames are thrown away.
273
If the interface is up when the data
275
If the interface is up when the data
274
device is not open, output frames are thrown away rather than
276
device is not open, output frames are thrown away rather than
Lines 316-321 Link Here
316
VMware
318
VMware
317
.Dv SIOCSIFFLAGS .
319
.Dv SIOCSIFFLAGS .
318
.El
320
.El
321
.Sh SYSCTL VARIABLES
322
In addition to global sysctl variables described above, there are
323
per-interface variables:
324
.Bl -tag -width indent
325
.It Va net.link.tap.X.keep_up: No 0
326
Set this variable to 1 and interface tapX will stay up
327
and keep its address on close regardless of mode.
328
.El
319
.Sh SEE ALSO
329
.Sh SEE ALSO
320
.Xr inet 4 ,
330
.Xr inet 4 ,
321
.Xr intro 4
331
.Xr intro 4

Return to bug 165174