qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vlad Yasevich <vyasevic@redhat.com>
To: Amos Kong <akong@redhat.com>, qemu-devel@nongnu.org
Cc: lcapitulino@redhat.com, sf@sfritsch.de, mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH] virtio-net: only output the vlan table when VIRTIO_NET_F_CTRL_VLAN is negotiated
Date: Mon, 17 Feb 2014 10:27:55 -0500	[thread overview]
Message-ID: <53022A7B.2070602@redhat.com> (raw)
In-Reply-To: <1392604023-20142-1-git-send-email-akong@redhat.com>

On 02/16/2014 09:27 PM, Amos Kong wrote:
> Stefan Fritsch just fixed a virtio-net driver bug [1], virtio-net won't
> filter out VLAN-tagged packets if VIRTIO_NET_F_CTRL_VLAN isn't negotiated.
> 
> We should also not send the vlan table to management, this patch makes
> the vlan-talbe optional.
      ^^^^^^^^^^
       table.

One question I have from the API perspective is can we suddenly change
something to be optional?  If there are any users of this ,
wouldn't they have to change now to check the existence of this
list?

Thanks
-vlad

> [1] http://lists.nongnu.org/archive/html/qemu-devel/2014-02/msg02604.html
> 
> Signed-off-by: Amos Kong <akong@redhat.com>
> ---
>  hw/net/virtio-net.c | 38 +++++++++++++++++++++++++-------------
>  qapi-schema.json    |  4 ++--
>  qmp-commands.hx     |  2 +-
>  3 files changed, 28 insertions(+), 16 deletions(-)
> 
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index 3626608..0b32e6a 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -222,13 +222,33 @@ static char *mac_strdup_printf(const uint8_t *mac)
>                              mac[1], mac[2], mac[3], mac[4], mac[5]);
>  }
>  
> +static intList *get_vlan_table(VirtIONet *n)
> +{
> +    intList *list, *entry;
> +    int i, j;
> +
> +    list = NULL;
> +    for (i = 0; i < MAX_VLAN >> 5; i++) {
> +        for (j = 0; n->vlans[i] && j < 0x1f; j++) {
> +            if (n->vlans[i] & (1U << j)) {
> +                entry = g_malloc0(sizeof(*entry));
> +                entry->value = (i << 5) + j;
> +                entry->next = list;
> +                list = entry;
> +            }
> +        }
> +    }
> +
> +    return list;
> +}
> +
>  static RxFilterInfo *virtio_net_query_rxfilter(NetClientState *nc)
>  {
>      VirtIONet *n = qemu_get_nic_opaque(nc);
> +    VirtIODevice *vdev = VIRTIO_DEVICE(n);
>      RxFilterInfo *info;
>      strList *str_list, *entry;
> -    intList *int_list, *int_entry;
> -    int i, j;
> +    int i;
>  
>      info = g_malloc0(sizeof(*info));
>      info->name = g_strdup(nc->name);
> @@ -274,18 +294,10 @@ static RxFilterInfo *virtio_net_query_rxfilter(NetClientState *nc)
>      }
>      info->multicast_table = str_list;
>  
> -    int_list = NULL;
> -    for (i = 0; i < MAX_VLAN >> 5; i++) {
> -        for (j = 0; n->vlans[i] && j < 0x1f; j++) {
> -            if (n->vlans[i] & (1U << j)) {
> -                int_entry = g_malloc0(sizeof(*int_entry));
> -                int_entry->value = (i << 5) + j;
> -                int_entry->next = int_list;
> -                int_list = int_entry;
> -            }
> -        }
> +    if ((1 << VIRTIO_NET_F_CTRL_VLAN) & vdev->guest_features) {
> +        info->has_vlan_table = true;
> +        info->vlan_table = get_vlan_table(n);
>      }
> -    info->vlan_table = int_list;

>  
>      /* enable event notification after query */
>      nc->rxfilter_notify_enabled = 1;
> diff --git a/qapi-schema.json b/qapi-schema.json
> index 7cfb5e5..5d48fa9 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -4034,7 +4034,7 @@
>  #
>  # @main-mac: the main macaddr string
>  #
> -# @vlan-table: a list of active vlan id
> +# @vlan-table: #optional a list of active vlan id
>  #
>  # @unicast-table: a list of unicast macaddr string
>  #
> @@ -4053,7 +4053,7 @@
>      'multicast-overflow': 'bool',
>      'unicast-overflow':   'bool',
>      'main-mac':           'str',
> -    'vlan-table':         ['int'],
> +    '*vlan-table':         ['int'],
>      'unicast-table':      ['str'],
>      'multicast-table':    ['str'] }}
>  
> diff --git a/qmp-commands.hx b/qmp-commands.hx
> index cce6b81..a1c1dfa 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -3308,7 +3308,7 @@ Each array entry contains the following:
>  - "multicast-overflow": multicast table is overflowed (json-bool)
>  - "unicast-overflow": unicast table is overflowed (json-bool)
>  - "main-mac": main macaddr string (json-string)
> -- "vlan-table": a json-array of active vlan id
> +- "vlan-table": a json-array of active vlan id (optoinal)
>  - "unicast-table": a json-array of unicast macaddr string
>  - "multicast-table": a json-array of multicast macaddr string
>  
> 

  reply	other threads:[~2014-02-17 15:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-17  2:27 [Qemu-devel] [PATCH] virtio-net: only output the vlan table when VIRTIO_NET_F_CTRL_VLAN is negotiated Amos Kong
2014-02-17 15:27 ` Vlad Yasevich [this message]
2014-02-17 16:52 ` Eric Blake
2014-02-17 16:56   ` Eric Blake
2014-02-17 16:58     ` Vlad Yasevich
2014-02-18 10:06       ` Michael S. Tsirkin
2014-02-18 14:04         ` Vlad Yasevich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53022A7B.2070602@redhat.com \
    --to=vyasevic@redhat.com \
    --cc=akong@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sf@sfritsch.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).