diff mbox

[2/9] virtio-net: add filter support

Message ID 1437735359-17415-3-git-send-email-yanghy@cn.fujitsu.com
State New
Headers show

Commit Message

Yang Hongyang July 24, 2015, 10:55 a.m. UTC
virtio-net explicity check for tap device, aupport for tap
with filter attached.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
---
 hw/net/virtio-net.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 304d3dd..59e9707 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -16,6 +16,7 @@ 
 #include "net/net.h"
 #include "net/checksum.h"
 #include "net/tap.h"
+#include "net/filter.h"
 #include "qemu/error-report.h"
 #include "qemu/timer.h"
 #include "hw/virtio/virtio-net.h"
@@ -406,11 +407,15 @@  static int peer_attach(VirtIONet *n, int index)
         return 0;
     }
 
-    if (nc->peer->info->type != NET_CLIENT_OPTIONS_KIND_TAP) {
+    if (nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_FILTER) {
+        nc = filter_backend(nc->peer);
+    }
+
+    if (nc->info->type != NET_CLIENT_OPTIONS_KIND_TAP) {
         return 0;
     }
 
-    return tap_enable(nc->peer);
+    return tap_enable(nc);
 }
 
 static int peer_detach(VirtIONet *n, int index)
@@ -421,11 +426,15 @@  static int peer_detach(VirtIONet *n, int index)
         return 0;
     }
 
-    if (nc->peer->info->type !=  NET_CLIENT_OPTIONS_KIND_TAP) {
+    if (nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_FILTER) {
+        nc = filter_backend(nc->peer);
+    }
+
+    if (nc->info->type !=  NET_CLIENT_OPTIONS_KIND_TAP) {
         return 0;
     }
 
-    return tap_disable(nc->peer);
+    return tap_disable(nc);
 }
 
 static void virtio_net_set_queues(VirtIONet *n)