X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fnetdev-linux.c;h=2fa05b66e3e2162f346a0369d1e2c641a3a15c76;hb=1e82e503c5358f8dce9eb2105448f0ec894d57bc;hp=c8d463aeedc1a7a49318537e88f17a04156a046b;hpb=92df599cb2bc5b04a5c9da3e7002f4c729ba480c;p=openvswitch diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index c8d463ae..2fa05b66 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -88,6 +88,7 @@ enum { struct tap_state { int fd; + bool opened; }; struct netdev_dev_linux { @@ -371,8 +372,15 @@ netdev_linux_open(struct netdev_dev *netdev_dev_, int ethertype, goto error; } - if (!strcmp(netdev_dev_get_type(netdev_dev_), "tap")) { + if (!strcmp(netdev_dev_get_type(netdev_dev_), "tap") && + !netdev_dev->state.tap.opened) { + + /* We assume that the first user of the tap device is the primary user + * and give them the tap FD. Subsequent users probably just expect + * this to be a system device so open it normally to avoid send/receive + * directions appearing to be reversed. */ netdev->fd = netdev_dev->state.tap.fd; + netdev_dev->state.tap.opened = true; } else if (ethertype != NETDEV_ETH_TYPE_NONE) { struct sockaddr_ll sll; int protocol;