summary refs log tree commit diff stats
path: root/net/tap-linux.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2010-09-08 14:26:14 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2010-09-08 14:26:14 -0500
commitdccbe6fbab47c9a2589f436e0592933b47cbe40b (patch)
treee5a851b48a3801dd28282eb17533975cade7ac23 /net/tap-linux.c
parent630c26893d6dc7713c0fcfc3c09d6bfe536a6ce3 (diff)
parenta697a334b3c4d3250e6420f5d38550ea10eb5319 (diff)
downloadfocaccia-qemu-dccbe6fbab47c9a2589f436e0592933b47cbe40b.tar.gz
focaccia-qemu-dccbe6fbab47c9a2589f436e0592933b47cbe40b.zip
Merge remote branch 'mst/for_anthony' into staging
Diffstat (limited to 'net/tap-linux.c')
-rw-r--r--net/tap-linux.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/net/tap-linux.c b/net/tap-linux.c
index c92983cb53..f7aa9041b8 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -129,6 +129,35 @@ int tap_probe_has_ufo(int fd)
     return 1;
 }
 
+/* Verify that we can assign given length */
+int tap_probe_vnet_hdr_len(int fd, int len)
+{
+    int orig;
+    if (ioctl(fd, TUNGETVNETHDRSZ, &orig) == -1) {
+        return 0;
+    }
+    if (ioctl(fd, TUNSETVNETHDRSZ, &len) == -1) {
+        return 0;
+    }
+    /* Restore original length: we can't handle failure. */
+    if (ioctl(fd, TUNSETVNETHDRSZ, &orig) == -1) {
+        fprintf(stderr, "TUNGETVNETHDRSZ ioctl() failed: %s. Exiting.\n",
+                strerror(errno));
+        assert(0);
+        return -errno;
+    }
+    return 1;
+}
+
+void tap_fd_set_vnet_hdr_len(int fd, int len)
+{
+    if (ioctl(fd, TUNSETVNETHDRSZ, &len) == -1) {
+        fprintf(stderr, "TUNSETVNETHDRSZ ioctl() failed: %s. Exiting.\n",
+                strerror(errno));
+        assert(0);
+    }
+}
+
 void tap_fd_set_offload(int fd, int csum, int tso4,
                         int tso6, int ecn, int ufo)
 {