Set TUN/TAP devices to ONE_QUEUE mode, which is more stable.
authorClaudio-Daniel Freire <claudio-daniel.freire@inria.fr>
Wed, 3 Aug 2011 10:31:22 +0000 (12:31 +0200)
committerClaudio-Daniel Freire <claudio-daniel.freire@inria.fr>
Wed, 3 Aug 2011 10:31:22 +0000 (12:31 +0200)
Otherwise, heavily-loaded tunnels can destabilize PlanetLab kernels.

src/nepi/testbeds/planetlab/scripts/tunalloc.c

index 6adcf24..9101392 100644 (file)
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
+#include <unistd.h>
 #include <sys/socket.h>
+#include <sys/fcntl.h>
+#include <sys/ioctl.h>
+#include <linux/ioctl.h>
 #include <linux/if.h>
 #include <linux/if_tun.h>
 
@@ -91,5 +95,13 @@ int tun_alloc(int iftype, char *if_name)
     }
 
     remotefd = receive_vif_fd(control_fd, if_name);
+    
+    /* set "safe" (non-breaking) queueing mode IFF_ONE_QUEUE */
+    struct ifreq ifr;
+    if (0 == fcntl(remotefd, TUNGETIFF, &ifr)) {
+        ifr.ifr_flags |= IFF_ONE_QUEUE;
+        fcntl(remotefd, TUNSETIFF, &ifr);
+    }
+    
     return remotefd;
 }