From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56619) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfUPc-0006ly-JN for qemu-devel@nongnu.org; Thu, 23 May 2013 08:14:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfUPW-0001Ti-Dn for qemu-devel@nongnu.org; Thu, 23 May 2013 08:14:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11836) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfUPW-0001TJ-4r for qemu-devel@nongnu.org; Thu, 23 May 2013 08:14:22 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4NCELIw024794 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 23 May 2013 08:14:21 -0400 Message-ID: <519E081B.3090000@redhat.com> Date: Thu, 23 May 2013 06:14:19 -0600 From: Eric Blake MIME-Version: 1.0 References: <1369300080-31377-1-git-send-email-akong@redhat.com> <1369300080-31377-3-git-send-email-akong@redhat.com> In-Reply-To: <1369300080-31377-3-git-send-email-akong@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2HMPGMLEVCRUSQIFVOSKW" Subject: Re: [Qemu-devel] [PATCH v3 2/2] net: introduce command to query rx-filter information List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amos Kong Cc: mst@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2HMPGMLEVCRUSQIFVOSKW Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 05/23/2013 03:08 AM, Amos Kong wrote: > We want to implement mac programming over macvtap through Libvirt, > related rx-filter configuration contains main mac, some of rx-mode > and mac-table. >=20 > The previous patch adds QMP event to notify management of rx-filter > change. This patch adds a monitor command to query rx-filter > information. >=20 > A flag is used to avoid events flooding, if user don't query s/don't/doesn't/ > rx-filter after receives one event, new events won't be sent s/after/after it/ > to qmp monitor. >=20 > +++ b/net/net.c > @@ -961,6 +961,53 @@ void print_net_client(Monitor *mon, NetClientState= *nc) > nc->info_str); > } > =20 > +RxFilterInfoList *qmp_query_rx_filter(bool has_name, const char *name,= > + Error **errp) > +{ > + NetClientState *nc; > + RxFilterInfoList *filter_list =3D NULL, *last_entry =3D NULL; > + > + QTAILQ_FOREACH(nc, &net_clients, next) { > + RxFilterInfoList *entry; > + RxFilterInfo *info; > + > + if (nc->info->type !=3D NET_CLIENT_OPTIONS_KIND_NIC) { > + continue; > + } > + if (has_name && strcmp(nc->name, name) !=3D 0) { Do you need the has_name argument here, or can you ensure that the caller passes NULL when the caller's has_name was false, for one less parameter and the same amount of information? > +++ b/qapi-schema.json > @@ -3619,3 +3619,76 @@ > '*cpuid-input-ecx': 'int', > 'cpuid-register': 'X86CPURegister32', > 'features': 'int' } } > + > +## > +# @RxState: > +# > +# Packets receiving state > +# > +# @normal: filter assigned packets according to the mac-table > +# > +# @no: don't receive any assigned packet > +# > +# @all: receive all assigned packets > +# > +## > +{ 'enum': 'RxState', 'data': [ 'normal', 'no', 'all' ] } I think s/no/none/ would make slightly more sense (usually, you pair no/yes and none/all, not no/all). > + > +## > +# @RxFilterInfo: > +# > +# Rx-filter information for a net client, it contains main mac, some > +# of rx-mode items and mac-table. > +# > +# @name: net client name > +# > +# @promiscuous: whether to ether promiscuous mode s/to ether//; s/$/is enabled/ > +# > +# @multicast: multicast receive state > +# > +# @unicast: unicast receive state > +# > +# @broadcast-allowed: whether to receive broadcast > +# > +# @multicast-overflow: multicast table is overflow or not > +# > +# @unicast-overflow: unicast table is overflow or not > +# > +# @main-mac: the main macaddr string > +# > +# @unicast-table: a list of unicast macaddr string > +# > +# @multicast-table: a list of multicast macaddr string Naming is reasonable; thanks for improving things from v1. > +# > +# Since 1.6 > +## > + > +{ 'type': 'RxFilterInfo', > + 'data': { > + 'name': 'str', > + 'promiscuous': 'bool', > + 'multicast': 'RxState', > + 'unicast': 'RxState', > + 'broadcast-allowed': 'bool', > + 'multicast-overflow': 'bool', > + 'unicast-overflow': 'bool', > + 'main-mac': 'str', > + 'unicast-table': ['str'], > + 'multicast-table': ['str'] }} > + > +## > +# @query-rx-filter: > +# > +# Return rx-filter information for all nics (or for the given nic). > +# > +# @name: #optional net client name > +# > +# Returns: list of @RxFilterInfo for all nics (or for the given nic). > +# Returns an error if the given @name doesn't exist, or given= > +# nic doesn't support rx-filter querying, or no net client > +# supports rx-filter querying > +# > +# Since: 1.6 > +## > +{ 'command': 'query-rx-filter', 'data': { '*name': 'str' }, > + 'returns': ['RxFilterInfo'] } Interface looks reasonable. I didn't check the code closely, but agree with Michael's assessment that the event-suppression flag has to be per-device, not global. > + > +Each array entry contains the following: > + > +- "name": net client name (jaso-string) > +- "promiscuous": enter promiscuous mode (json-bool) > +- "multicast": multicast receive state (one of 'normal', 'no', 'all') > +- "unicast": unicast receive state (one of 'normal', 'no', 'all') > +- "broadcast-allowed": allow to receive broadcast (json-bool) > +- "multicast-overflow": multicast table is overflow (json-bool) s/is overflow/overflowed/ > +- "unicast-overflow": unicast table is overflow (json-bool) and again --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2HMPGMLEVCRUSQIFVOSKW Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJRnggbAAoJEKeha0olJ0NqZ7AH/A+UoaGUa8Ahjsgmq1u/sJFc Tl6MP9hUvnoeYpfXERSRZVbi8OoylNTqhh4d2WQo9EZ9pEPTwcTN4KqIJ+AdDXOR Q75rEHd7lIRyoPjuAkQUseccw5d8o6YNaCCEuWPa0KZKLOgJg22d9YZPX3vQincJ eY1ODnisSyQnUK+jZx+lCVDJLaxgxUmG9CoQnaw7PTpC90uHJOr4tj6grDlGMWlG fWk28L1htdN36CIMRT95XodvuXYmwuBF/bwoUVyA/sLhiuXfU8KMbHlHPpaqTWqT waGCngOIh8m4k1nclYbUoXmdtmJdlwR8A+eJlu9qEQjXgQmjA3+jZKVoiE99580= =mfka -----END PGP SIGNATURE----- ------enig2HMPGMLEVCRUSQIFVOSKW--