diff options
author | Yang Hongyang <yanghy@cn.fujitsu.com> | 2015-10-07 11:52:14 +0800 |
---|---|---|
committer | Jason Wang <jasowang@redhat.com> | 2015-10-12 13:23:40 +0800 |
commit | fdccce4596218e49ca4d0f5d4b3f0c453bd99ba0 (patch) | |
tree | f08596389c826fae079e3644be2fc031119115cf /net/net.c | |
parent | 9abce56d7b319b0c78b487720d128706272e0a0c (diff) | |
download | qemu-fdccce4596218e49ca4d0f5d4b3f0c453bd99ba0.zip qemu-fdccce4596218e49ca4d0f5d4b3f0c453bd99ba0.tar.gz qemu-fdccce4596218e49ca4d0f5d4b3f0c453bd99ba0.tar.bz2 |
init/cleanup of netfilter object
Add a netfilter object based on QOM.
A netfilter is attached to a netdev, captures all network packets
that pass through the netdev. When we delete the netdev, we also
delete the netfilter object attached to it, because if the netdev is
removed, the filter which attached to it is useless.
Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'net/net.c')
-rw-r--r-- | net/net.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -44,6 +44,7 @@ #include "qapi/opts-visitor.h" #include "qapi/dealloc-visitor.h" #include "sysemu/sysemu.h" +#include "net/filter.h" /* Net bridge is currently not supported for W32. */ #if !defined(_WIN32) @@ -287,6 +288,7 @@ static void qemu_net_client_setup(NetClientState *nc, nc->incoming_queue = qemu_new_net_queue(nc); nc->destructor = destructor; + QTAILQ_INIT(&nc->filters); } NetClientState *qemu_new_net_client(NetClientInfo *info, @@ -384,6 +386,7 @@ void qemu_del_net_client(NetClientState *nc) { NetClientState *ncs[MAX_QUEUE_NUM]; int queues, i; + NetFilterState *nf, *next; assert(nc->info->type != NET_CLIENT_OPTIONS_KIND_NIC); @@ -395,6 +398,10 @@ void qemu_del_net_client(NetClientState *nc) MAX_QUEUE_NUM); assert(queues != 0); + QTAILQ_FOREACH_SAFE(nf, &nc->filters, next, next) { + object_unparent(OBJECT(nf)); + } + /* If there is a peer NIC, delete and cleanup client, but do not free. */ if (nc->peer && nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) { NICState *nic = qemu_get_nic(nc->peer); |