Date: Tue, 07 Jan 2003 17:20:45 -0800 From: Maksim Yevmenkin <myevmenk@exodus.net> To: Doug Ambrisko <ambrisko@ambrisko.com> Cc: net@freebsd.org Subject: Re: if_tap.c interaction bug with netgraph?? Message-ID: <3E1B7CED.8020907@exodus.net> References: <200301072316.h07NGuEJ047694@www.ambrisko.com>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
Doug,
>| >I've run into this bug since about 4.6-stable of some time. I use netgraph
>| >to connect to a tap device in vmnet mode since in vmnet mode it is
>| >persistan. In tap mode if comes and goes depending on whether or not I
>| >have the device open. Anyways I couldn't get data to come in the vmnet
>| >node through netgraph with only the interface up, auto source off and
>| >promicious on (ie. bridge mode). This patches fixes it by doing
>| >and init to get the interface going. Any objections to this change?
>| >If you give the interface an IP then it works okay except you shouldn't
>| >have to do that.
>|
>| "vmnet" mode is special. It has been introduced when if_tap and
>| vmnet were merged into one driver. I tried to be compatible with old
>| vmnet driver (note XXX comment). Just need to make sure this does
>| not break VMWare (will try later today).
>
>Doesn't break vmware for me. I've been running this patch for a long time.
>Also I've been doing it under -stable and not -current. I will need to
>test this under -current to see what happens before checking it in.
>
Thank you.
>Currently vmware would be broken if you didn't ifconfig tap1 and then
>connected it to a physical NIC on the host so you could plumb the
>vmware session to a real ethernet port. Something I have done in the
>past. Vmware as normaly used wouldn't see this problem since it would
>have an IP assigned to it.
>
>| Another possible solution is to introduce "persistent" mode for tap, i.e.
>| a couple of new ioctl()'s for tap device to set/get persistent mode and
>| to init tap interface.
>
>I guess that would work. Since I do most of this from shell scripts
>using netgraph to connect things together in strange ways for testing
>it's nice not having to use any ioctl's.
>
I have attached the patch (untested) that implements three new ioctl() for
tap device. You might want to try it. I agree ioctl() is not very shell
friendly,
but you always can write a five lines of C code and call it tapcontrol :)
thanks,
max
[-- Attachment #2 --]
diff -u /sys/net/if_tap.c ./if_tap.c
--- /sys/net/if_tap.c Mon Nov 25 15:23:38 2002
+++ ./if_tap.c Tue Jan 7 16:25:06 2003
@@ -464,7 +464,8 @@
* interface, if we are in VMnet mode. just close the device.
*/
- if (((tp->tap_flags & TAP_VMNET) == 0) && (ifp->if_flags & IFF_UP)) {
+ if (((tp->tap_flags & TAP_VMNET) == 0) &&
+ ((tp->tap_flags & TAP_PERSIST) == 0) && (ifp->if_flags & IFF_UP)) {
s = splimp();
if_down(ifp);
if (ifp->if_flags & IFF_RUNNING) {
@@ -739,6 +740,21 @@
case SIOCSIFADDR: /* set MAC address of the remote side */
bcopy(data, tp->ether_addr, sizeof(tp->ether_addr));
+ break;
+
+ case TAPINIT:
+ tapifinit(tp);
+ break;
+
+ case TAPSPERSIST:
+ if (*(int *)data)
+ tp->tap_flags |= TAP_PERSIST;
+ else
+ tp->tap_flags &= ~TAP_PERSIST;
+ break;
+
+ case TAPGPERSIST:
+ *(int *)data = (tp->tap_flags & TAP_PERSIST)? 1 : 0;
break;
default:
diff -u /sys/net/if_tap.h ./if_tap.h
--- /sys/net/if_tap.h Fri Apr 5 21:15:29 2002
+++ ./if_tap.h Tue Jan 7 16:22:29 2003
@@ -55,6 +55,9 @@
#define TAPGDEBUG _IOR('t', 89, int)
#define TAPSIFINFO _IOW('t', 91, struct tapinfo)
#define TAPGIFINFO _IOR('t', 92, struct tapinfo)
+#define TAPINIT _IO ('t', 93)
+#define TAPSPERSIST _IOW('t', 94, int)
+#define TAPGPERSIST _IOW('t', 95, int)
/* VMware ioctl's */
#define VMIO_SIOCSIFFLAGS _IO('V', 0)
diff -u /sys/net/if_tapvar.h ./if_tapvar.h
--- /sys/net/if_tapvar.h Fri Apr 5 21:15:29 2002
+++ ./if_tapvar.h Tue Jan 7 16:20:09 2003
@@ -53,6 +53,7 @@
#define TAP_ASYNC (1 << 3)
#define TAP_READY (TAP_OPEN|TAP_INITED)
#define TAP_VMNET (1 << 4)
+#define TAP_PERSIST (1 << 5)
u_int8_t ether_addr[ETHER_ADDR_LEN]; /* ether addr of the remote side */
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3E1B7CED.8020907>
