Skip to contentSkip to conversation

virtio-net: Do not filter VLANs without F_CTRL_VLAN

PATCH In review Amos Kong 3 participants 5 messages Mar 26, 2014

lore
Share & tools
lore

Amos Kong

author
#0 lore raw

PATCH v2 1/1 virtio-net: Do not filter VLANs without F_CTRL_VLAN

From: Stefan Fritsch <[email protected]>

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).

---
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(+)
hw/net/virtio-net.c +6 -0
index 43b4eda..439477b 100644
@@ -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,
Signature · 1 line
1.8.5.3
#1 lore raw
Quoted 10 lines · Amos Kong

From: Stefan Fritsch <[email protected]>

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).

I think this is also -stable material.

Quoted 26 lines

---
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(+)
hw/net/virtio-net.c +6 -0
index 43b4eda..439477b 100644
@@ -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,
Signature · 1 line
1.8.5.3
#2 lore raw
In reply to Amos Kong
Quoted 10 lines · Amos Kong

From: Stefan Fritsch <[email protected]>

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).

I think this is also -stable material, isn't it?

Quoted 26 lines

---
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(+)
hw/net/virtio-net.c +6 -0
index 43b4eda..439477b 100644
@@ -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,
Signature · 1 line
1.8.5.3
author
#3 lore raw
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Amos Kong

From: Stefan Fritsch <[email protected]>

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

Quoted 7 lines
Quoted 5 lines

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

I think this is also -stable material, isn't it?

Yes, it is.

Quoted 26 lines
Quoted 26 lines

---
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(+)
hw/net/virtio-net.c +6 -0
index 43b4eda..439477b 100644
@@ -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,
Signature · 1 line
1.8.5.3
Signature · 1 line
			Amos.
Reviewed-by on v2 1/1
#4 lore raw
In reply to Amos Kong
Quoted 25 lines · Amos Kong

From: Stefan Fritsch <[email protected]>

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).

---
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(+)
hw/net/virtio-net.c +0 -0
index 43b4eda..439477b 100644
@@ -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);

hw/net/virtio-net.c static void virtio_net_set_features(VirtIODevice *vdev, uint32_t features) · line 541

Quoted 10 lines
hw/net/virtio-net.c +6 -0
     }
+
+    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,

-vlad