netdev-linux: Fix tap device using wrong FD.
authorJesse Gross <jesse@nicira.com>
Mon, 3 Aug 2009 23:11:43 +0000 (16:11 -0700)
committerJesse Gross <jesse@nicira.com>
Wed, 30 Sep 2009 19:43:05 +0000 (12:43 -0700)
Tap devices were doing ioctls on the AF_INET socket, instead of the
FD opened on the tap device.

lib/netdev-linux.c

index 5abf6e16b7d13d467b3e49647f0bf6803413439a..50a0d2da718cf968558d3eeb279a296c36cc3911 100644 (file)
@@ -239,9 +239,11 @@ netdev_linux_open(const char *name, char *suffix, int ethertype,
 
         /* Create tap device. */
         ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
-        error = netdev_linux_do_ioctl(&netdev->netdev, &ifr,
-                                      TUNSETIFF, "TUNSETIFF");
-        if (error) {
+        strncpy(ifr.ifr_name, suffix, sizeof ifr.ifr_name);
+        if (ioctl(netdev->tap_fd, TUNSETIFF, &ifr) == -1) {
+            VLOG_WARN("%s: creating tap device failed: %s", suffix,
+                      strerror(errno));
+            error = errno;
             goto error;
         }