Received: from eggs.gnu.org ([2001:4830:134:3::10]:42963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZIaeN-00012d-7C for qemu-devel@nongnu.org; Fri, 24 Jul 2015 06:56:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZIaeK-0008WA-BH for qemu-devel@nongnu.org; Fri, 24 Jul 2015 06:56:23 -0400 Received: from [59.151.112.132] (port=27135 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZIaeJ-0008U7-Ap for qemu-devel@nongnu.org; Fri, 24 Jul 2015 06:56:20 -0400 From: Yang Hongyang Date: Fri, 24 Jul 2015 18:55:52 +0800 Message-ID: <1437735359-17415-3-git-send-email-yanghy@cn.fujitsu.com> In-Reply-To: <1437735359-17415-1-git-send-email-yanghy@cn.fujitsu.com> References: <1437735359-17415-1-git-send-email-yanghy@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH 2/9] virtio-net: add filter support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: jasowang@redhat.com, mrhines@linux.vnet.ibm.com, thuth@redhat.com, stefanha@redhat.com, Yang Hongyang virtio-net explicity check for tap device, aupport for tap with filter attached. Signed-off-by: Yang Hongyang --- hw/net/virtio-net.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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) -- 1.9.1