Only reviewing the QAPI part. Yang Hongyang <yan...@cn.fujitsu.com> writes:
> QTAILQ_ENTRY global_list but used by filter layer, so that we can > manage all filters together. > QTAILQ_ENTRY next used by netdev, filter belongs to the specific netdev is > in this queue. > This is mostly the same with init/cleanup of netdev object. > > Signed-off-by: Yang Hongyang <yan...@cn.fujitsu.com> > --- [...] > diff --git a/qapi-schema.json b/qapi-schema.json > index 4342a08..d7fb578 100644 > --- a/qapi-schema.json > +++ b/qapi-schema.json > @@ -2537,6 +2537,43 @@ > 'opts': 'NetClientOptions' } } > > ## > +# @NetFilterOptions > +# > +# A discriminated record of network filters. > +# > +# Since 2.5 > +# > +## > +{ 'union': 'NetFilterOptions', > + 'data': { } } > + > +## > +# @NetFilter > +# > +# Captures the packets of a network backend. > +# > +# @id: identifier for monitor commands > +# > +# @netdev: the network backend it attached to > +# > +# @chain: #optional accept "in","out","all", if not specified, default is > "all" > +# "in" means this filter will receive packets sent to the @netdev > +# "out" means this filter will receive packets sent from the @netdev > +# "all" means this filter will receive packets both sent to/from > +# the @netdev > +# > +# @opts: filter type specific properties > +# > +# Since 2.5 > +## > +{ 'struct': 'NetFilter', > + 'data': { > + 'id': 'str', > + 'netdev': 'str', > + '*chain': 'str', > + 'opts': 'NetFilterOptions' } } > + > +## > # @InetSocketAddress > # > # Captures a socket address or address range in the Internet namespace. Let's make this a flat union instead, to reduce nesting, and therefore memory allocations and indirections. Something like { 'enum': 'NetFilterType', 'data': [] } { 'struct': NetFilterBase', 'data': { 'id': 'str', 'netdev': 'str', '*chain': 'str', 'type': 'NetFilterType' { 'union': 'NetFilter', 'base': 'NetFilterBase', 'discriminator': 'type', 'data': { } } I hope to reduce the notational overhead of such flat unions in the near future. Not sure empty unions actually work. If they don't, you can either squash adding members into this patch, or add a dummy member, and drop it when you add the real ones.