summaryrefslogtreecommitdiff
path: root/net/tap-linux.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2010-07-16 11:16:06 +0300
committerMichael S. Tsirkin <mst@redhat.com>2010-09-07 20:27:33 +0300
commit445d892f43e6a6031cd1aac292df433f821aa830 (patch)
tree3ebf888277076f28b8a5bf5adf9ef5eae1efcbaa /net/tap-linux.c
parentef4252b149cf238480c45c06dcbd567d41ee7d76 (diff)
downloadqemu-445d892f43e6a6031cd1aac292df433f821aa830.tar.gz
tap: add APIs for vnet header length
Add APIs to control host header length. First user will be vhost-net. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
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)
{