diff mbox

[v2,for,2.0] virtio-net: Do not filter VLANs without F_CTRL_VLAN

Message ID 1395829792-14301-1-git-send-email-akong@redhat.com
State New
Headers show

Commit Message

Amos Kong March 26, 2014, 10:29 a.m. UTC
From: Stefan Fritsch <sf@sfritsch.de>

If VIRTIO_NET_F_CTRL_VLAN is not negotiated, do not filter out all
VLAN-tagged packets but send them to the guest.

This fixes VLANs with OpenBSD guests (and probably NetBSD, too, because
the OpenBSD driver started as a port from NetBSD).

Signed-off-by: Stefan Fritsch <sf@sfritsch.de>
Signed-off-by: Amos Kong <akong@redhat.com>
---
V2: it's not good to check guest features at reset time,
    so reset vlan table in setting features
---
 hw/net/virtio-net.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Amos Kong March 26, 2014, 11:07 a.m. UTC | #1
On Wed, Mar 26, 2014 at 12:55:18PM +0200, Michael S. Tsirkin wrote:
> On Wed, Mar 26, 2014 at 06:29:52PM +0800, Amos Kong wrote:
> > From: Stefan Fritsch <sf@sfritsch.de>
> > 
> > If VIRTIO_NET_F_CTRL_VLAN is not negotiated, do not filter out all
> > VLAN-tagged packets but send them to the guest.
> > 
> > This fixes VLANs with OpenBSD guests (and probably NetBSD, too, because
> > the OpenBSD driver started as a port from NetBSD).
> > 
> > Signed-off-by: Stefan Fritsch <sf@sfritsch.de>
> > Signed-off-by: Amos Kong <akong@redhat.com>
> 
> I think this is also -stable material, isn't it?

Yes, it is.
 
> > ---
> > V2: it's not good to check guest features at reset time,
> >     so reset vlan table in setting features
> > ---
> >  hw/net/virtio-net.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> > index 43b4eda..439477b 100644
> > --- a/hw/net/virtio-net.c
> > +++ b/hw/net/virtio-net.c
> > @@ -530,6 +530,12 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint32_t features)
> >          }
> >          vhost_net_ack_features(tap_get_vhost_net(nc->peer), features);
> >      }
> > +
> > +    if ((1 << VIRTIO_NET_F_CTRL_VLAN) & features) {
> > +        memset(n->vlans, 0, MAX_VLAN >> 3);
> > +    } else {
> > +        memset(n->vlans, 0xff, MAX_VLAN >> 3);
> > +    }
> >  }
> >  
> >  static int virtio_net_handle_rx_mode(VirtIONet *n, uint8_t cmd,
> > -- 
> > 1.8.5.3
Vlad Yasevich March 26, 2014, 1:39 p.m. UTC | #2
On 03/26/2014 06:29 AM, Amos Kong wrote:
> From: Stefan Fritsch <sf@sfritsch.de>
> 
> If VIRTIO_NET_F_CTRL_VLAN is not negotiated, do not filter out all
> VLAN-tagged packets but send them to the guest.
> 
> This fixes VLANs with OpenBSD guests (and probably NetBSD, too, because
> the OpenBSD driver started as a port from NetBSD).
> 
> Signed-off-by: Stefan Fritsch <sf@sfritsch.de>
> Signed-off-by: Amos Kong <akong@redhat.com>
> ---
> V2: it's not good to check guest features at reset time,
>     so reset vlan table in setting features
> ---
>  hw/net/virtio-net.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index 43b4eda..439477b 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -530,6 +530,12 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint32_t features)
>          }
>          vhost_net_ack_features(tap_get_vhost_net(nc->peer), features);
>      }
> +
> +    if ((1 << VIRTIO_NET_F_CTRL_VLAN) & features) {
> +        memset(n->vlans, 0, MAX_VLAN >> 3);
> +    } else {
> +        memset(n->vlans, 0xff, MAX_VLAN >> 3);
> +    }
>  }
>  
>  static int virtio_net_handle_rx_mode(VirtIONet *n, uint8_t cmd,
> 

Reviewed-by: Vlad Yasevich <vyasevic@redhat.com>

-vlad
diff mbox

Patch

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 43b4eda..439477b 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -530,6 +530,12 @@  static void virtio_net_set_features(VirtIODevice *vdev, uint32_t features)
         }
         vhost_net_ack_features(tap_get_vhost_net(nc->peer), features);
     }
+
+    if ((1 << VIRTIO_NET_F_CTRL_VLAN) & features) {
+        memset(n->vlans, 0, MAX_VLAN >> 3);
+    } else {
+        memset(n->vlans, 0xff, MAX_VLAN >> 3);
+    }
 }
 
 static int virtio_net_handle_rx_mode(VirtIONet *n, uint8_t cmd,