From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtbUl-0006KE-8o for qemu-devel@nongnu.org; Tue, 03 Nov 2015 08:19:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZtbUj-0007f2-Mk for qemu-devel@nongnu.org; Tue, 03 Nov 2015 08:19:27 -0500 Received: from m199-177.yeah.net ([123.58.177.199]:60515) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtbUh-0007dB-JN for qemu-devel@nongnu.org; Tue, 03 Nov 2015 08:19:25 -0500 References: <1446551816-15768-1-git-send-email-zhang.zhanghailiang@huawei.com> <1446551816-15768-33-git-send-email-zhang.zhanghailiang@huawei.com> From: Yang Hongyang Message-ID: <5638AB11.80607@easystack.cn> Date: Tue, 3 Nov 2015 20:39:45 +0800 MIME-Version: 1.0 In-Reply-To: <1446551816-15768-33-git-send-email-zhang.zhanghailiang@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH COLO-Frame v10 32/38] netfilter: Add a public API to release all the buffered packets List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: zhanghailiang , qemu-devel@nongnu.org Cc: lizhijian@cn.fujitsu.com, quintela@redhat.com, Jason Wang , yunhong.jiang@intel.com, eddie.dong@intel.com, peter.huangpeng@huawei.com, dgilbert@redhat.com, arei.gonglei@huawei.com, stefanha@redhat.com, amit.shah@redhat.com On 2015=E5=B9=B411=E6=9C=8803=E6=97=A5 19:56, zhanghailiang wrote: > For COLO or MC FT, We need a function to release all the buffered packe= ts > actively. > > Signed-off-by: zhanghailiang > Cc: Jason Wang > --- > v10: new patch > --- > include/net/filter.h | 1 + > include/net/net.h | 4 ++++ > net/filter-buffer.c | 15 +++++++++++++++ > net/net.c | 24 ++++++++++++++++++++++++ > 4 files changed, 44 insertions(+) > > diff --git a/include/net/filter.h b/include/net/filter.h > index 2deda36..5a09607 100644 > --- a/include/net/filter.h > +++ b/include/net/filter.h > @@ -73,5 +73,6 @@ ssize_t qemu_netfilter_pass_to_next(NetClientState *s= ender, > const struct iovec *iov, > int iovcnt, > void *opaque); > +void filter_buffer_release_all(void); > > #endif /* QEMU_NET_FILTER_H */ > diff --git a/include/net/net.h b/include/net/net.h > index 7af3e15..5c65c45 100644 > --- a/include/net/net.h > +++ b/include/net/net.h > @@ -125,6 +125,10 @@ NetClientState *qemu_find_vlan_client_by_name(Moni= tor *mon, int vlan_id, > const char *client_str)= ; > typedef void (*qemu_nic_foreach)(NICState *nic, void *opaque); > void qemu_foreach_nic(qemu_nic_foreach func, void *opaque); > +typedef void (*qemu_netfilter_foreach)(NetFilterState *nf, void *opaqu= e, > + Error **errp); > +void qemu_foreach_netfilter(qemu_netfilter_foreach func, void *opaque, > + Error **errp); > int qemu_can_send_packet(NetClientState *nc); > ssize_t qemu_sendv_packet(NetClientState *nc, const struct iovec *iov= , > int iovcnt); > diff --git a/net/filter-buffer.c b/net/filter-buffer.c > index 57be149..b344901 100644 > --- a/net/filter-buffer.c > +++ b/net/filter-buffer.c > @@ -14,6 +14,7 @@ > #include "qapi/qmp/qerror.h" > #include "qapi-visit.h" > #include "qom/object.h" > +#include "net/net.h" > > #define TYPE_FILTER_BUFFER "filter-buffer" > > @@ -163,6 +164,20 @@ out: > error_propagate(errp, local_err); > } > > +static void filter_buffer_release_packets(NetFilterState *nf, void *op= aque, > + Error **errp) > +{ > + if (!strcmp(object_get_typename(OBJECT(nf)), TYPE_FILTER_BUFFER)) = { > + filter_buffer_flush(nf); > + } > +} > + > +/* public APIs */ > +void filter_buffer_release_all(void) > +{ > + qemu_foreach_netfilter(filter_buffer_release_packets, NULL, NULL); > +} > + > static void filter_buffer_init(Object *obj) > { > object_property_add(obj, "interval", "int", > diff --git a/net/net.c b/net/net.c > index a3e9d1a..a333b01 100644 > --- a/net/net.c > +++ b/net/net.c > @@ -259,6 +259,30 @@ static char *assign_name(NetClientState *nc1, cons= t char *model) > return g_strdup_printf("%s.%d", model, id); > } > > +void qemu_foreach_netfilter(qemu_netfilter_foreach func, void *opaque, > + Error **errp) > +{ > + NetClientState *nc; > + NetFilterState *nf; > + > + QTAILQ_FOREACH(nc, &net_clients, next) { Going through every filters this way might cause problem under multiqueue case. IIRC, Jason suggested that we implement multiqueue by this way: attach the same filter to all queues instead of attach the clone of the filter obj to other queues. So if we attach the same filter to all queues, going through filters this way will cause the func been called multiple(=3Dnum of queues) times= . > + if (nc->info->type =3D=3D NET_CLIENT_OPTIONS_KIND_NIC) { > + continue; > + } > + QTAILQ_FOREACH(nf, &nc->filters, next) { > + if (func) { > + Error *local_err =3D NULL; > + > + func(nf, opaque, &local_err); > + if (local_err) { > + error_propagate(errp, local_err); > + return; > + } > + } > + } > + } > +} > + > static void qemu_net_client_destructor(NetClientState *nc) > { > g_free(nc); > --=20 Thanks, Yang