* [PATCH net] veth: Fix vlan_features so as to be able to use stacked vlan interfaces
@ 2014-02-18 12:20 Toshiaki Makita
2014-02-18 12:20 ` [PATCH net] tun: remove bogus hardware vlan acceleration flags from vlan_features Toshiaki Makita
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Toshiaki Makita @ 2014-02-18 12:20 UTC (permalink / raw)
To: David S . Miller; +Cc: Toshiaki Makita, Flavio Leitner, netdev
Even if we create a stacked vlan interface such as veth0.10.20, it sends
single tagged frames (tagged with only vid 10).
Because vlan_features of a veth interface has the
NETIF_F_HW_VLAN_[CTAG/STAG]_TX bits, veth0.10 also has that feature, so
dev_hard_start_xmit(veth0.10) doesn't call __vlan_put_tag() and
vlan_dev_hard_start_xmit(veth0.10) overwrites vlan_tci.
This prevents us from using a combination of 802.1ad and 802.1Q
in containers, etc.
Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
---
drivers/net/veth.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 2ec2041..5b37437 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -285,7 +285,8 @@ static void veth_setup(struct net_device *dev)
dev->ethtool_ops = &veth_ethtool_ops;
dev->features |= NETIF_F_LLTX;
dev->features |= VETH_FEATURES;
- dev->vlan_features = dev->features;
+ dev->vlan_features = dev->features &
+ ~(NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX);
dev->destructor = veth_dev_free;
dev->hw_features = VETH_FEATURES;
--
1.8.1.2
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH net] tun: remove bogus hardware vlan acceleration flags from vlan_features 2014-02-18 12:20 [PATCH net] veth: Fix vlan_features so as to be able to use stacked vlan interfaces Toshiaki Makita @ 2014-02-18 12:20 ` Toshiaki Makita 2014-02-20 7:16 ` David Miller 2014-02-19 4:13 ` [PATCH net] veth: Fix vlan_features so as to be able to use stacked vlan interfaces Flavio Leitner 2014-02-20 7:16 ` David Miller 2 siblings, 1 reply; 7+ messages in thread From: Toshiaki Makita @ 2014-02-18 12:20 UTC (permalink / raw) To: David S . Miller Cc: Fernando Luis Vazquez Cao, Maxim Krasnyansky, netdev, Toshiaki Makita From: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp> Even though only the outer vlan tag can be HW accelerated in the transmission path, in the TUN/TAP driver vlan_features mirrors hw_features, which happens to have the NETIF_F_HW_VLAN_?TAG_TX flags set. Because of this, during packet tranmisssion through a stacked vlan device dev_hard_start_xmit, (incorrectly) assuming that the vlan device supports hardware vlan acceleration, does not add the vlan header to the skb payload and the inner vlan tags are lost (vlan_tci contains the outer vlan tag when userspace reads the packet from the tap device). Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp> Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp> --- diff -urNp linux-3.13.3-orig/drivers/net/tun.c linux-3.13.3/drivers/net/tun.c --- linux-3.13.3-orig/drivers/net/tun.c 2014-01-20 11:40:07.000000000 +0900 +++ linux-3.13.3/drivers/net/tun.c 2014-02-18 16:23:04.461078629 +0900 @@ -1651,7 +1651,9 @@ static int tun_set_iff(struct net *net, TUN_USER_FEATURES | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX; dev->features = dev->hw_features; - dev->vlan_features = dev->features; + dev->vlan_features = dev->features & + ~(NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_STAG_TX); INIT_LIST_HEAD(&tun->disabled); err = tun_attach(tun, file, false); ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] tun: remove bogus hardware vlan acceleration flags from vlan_features 2014-02-18 12:20 ` [PATCH net] tun: remove bogus hardware vlan acceleration flags from vlan_features Toshiaki Makita @ 2014-02-20 7:16 ` David Miller 0 siblings, 0 replies; 7+ messages in thread From: David Miller @ 2014-02-20 7:16 UTC (permalink / raw) To: makita.toshiaki; +Cc: fernando, maxk, netdev From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp> Date: Tue, 18 Feb 2014 21:20:09 +0900 > From: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp> > > Even though only the outer vlan tag can be HW accelerated in the transmission > path, in the TUN/TAP driver vlan_features mirrors hw_features, which happens > to have the NETIF_F_HW_VLAN_?TAG_TX flags set. Because of this, during packet > tranmisssion through a stacked vlan device dev_hard_start_xmit, (incorrectly) > assuming that the vlan device supports hardware vlan acceleration, does not > add the vlan header to the skb payload and the inner vlan tags are lost > (vlan_tci contains the outer vlan tag when userspace reads the packet from > the tap device). > > Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp> > Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp> Applied and queued up for -stable. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] veth: Fix vlan_features so as to be able to use stacked vlan interfaces 2014-02-18 12:20 [PATCH net] veth: Fix vlan_features so as to be able to use stacked vlan interfaces Toshiaki Makita 2014-02-18 12:20 ` [PATCH net] tun: remove bogus hardware vlan acceleration flags from vlan_features Toshiaki Makita @ 2014-02-19 4:13 ` Flavio Leitner 2014-02-19 5:22 ` Toshiaki Makita 2014-02-20 7:16 ` David Miller 2 siblings, 1 reply; 7+ messages in thread From: Flavio Leitner @ 2014-02-19 4:13 UTC (permalink / raw) To: Toshiaki Makita; +Cc: David S . Miller, netdev On Tue, Feb 18, 2014 at 09:20:08PM +0900, Toshiaki Makita wrote: > Even if we create a stacked vlan interface such as veth0.10.20, it sends > single tagged frames (tagged with only vid 10). > Because vlan_features of a veth interface has the > NETIF_F_HW_VLAN_[CTAG/STAG]_TX bits, veth0.10 also has that feature, so > dev_hard_start_xmit(veth0.10) doesn't call __vlan_put_tag() and > vlan_dev_hard_start_xmit(veth0.10) overwrites vlan_tci. > This prevents us from using a combination of 802.1ad and 802.1Q > in containers, etc. > > Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp> > --- > drivers/net/veth.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/veth.c b/drivers/net/veth.c > index 2ec2041..5b37437 100644 > --- a/drivers/net/veth.c > +++ b/drivers/net/veth.c > @@ -285,7 +285,8 @@ static void veth_setup(struct net_device *dev) > dev->ethtool_ops = &veth_ethtool_ops; > dev->features |= NETIF_F_LLTX; > dev->features |= VETH_FEATURES; > - dev->vlan_features = dev->features; > + dev->vlan_features = dev->features & > + ~(NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX); > dev->destructor = veth_dev_free; > > dev->hw_features = VETH_FEATURES; > -- > 1.8.1.2 > Why that isn't a problem with another software device? Although this patch might fix the issue, it seems to me that the middle devices shouldn't use the same feature flags. I mean, vlan.20 should add the header, then vlan.10 should offload the tag to veth. Otherwise, for any vlan on top of veth there will be an unneeded memmove(). fbl ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] veth: Fix vlan_features so as to be able to use stacked vlan interfaces 2014-02-19 4:13 ` [PATCH net] veth: Fix vlan_features so as to be able to use stacked vlan interfaces Flavio Leitner @ 2014-02-19 5:22 ` Toshiaki Makita 2014-02-20 1:02 ` Flavio Leitner 0 siblings, 1 reply; 7+ messages in thread From: Toshiaki Makita @ 2014-02-19 5:22 UTC (permalink / raw) To: fbl; +Cc: David S . Miller, netdev (2014/02/19 13:13), Flavio Leitner wrote: > On Tue, Feb 18, 2014 at 09:20:08PM +0900, Toshiaki Makita wrote: >> Even if we create a stacked vlan interface such as veth0.10.20, it sends >> single tagged frames (tagged with only vid 10). >> Because vlan_features of a veth interface has the >> NETIF_F_HW_VLAN_[CTAG/STAG]_TX bits, veth0.10 also has that feature, so >> dev_hard_start_xmit(veth0.10) doesn't call __vlan_put_tag() and >> vlan_dev_hard_start_xmit(veth0.10) overwrites vlan_tci. >> This prevents us from using a combination of 802.1ad and 802.1Q >> in containers, etc. >> >> Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp> >> --- >> drivers/net/veth.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/net/veth.c b/drivers/net/veth.c >> index 2ec2041..5b37437 100644 >> --- a/drivers/net/veth.c >> +++ b/drivers/net/veth.c >> @@ -285,7 +285,8 @@ static void veth_setup(struct net_device *dev) >> dev->ethtool_ops = &veth_ethtool_ops; >> dev->features |= NETIF_F_LLTX; >> dev->features |= VETH_FEATURES; >> - dev->vlan_features = dev->features; >> + dev->vlan_features = dev->features & >> + ~(NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX); >> dev->destructor = veth_dev_free; >> >> dev->hw_features = VETH_FEATURES; >> -- >> 1.8.1.2 >> > > Why that isn't a problem with another software device? > Although this patch might fix the issue, it seems to me that > the middle devices shouldn't use the same feature flags. > I mean, vlan.20 should add the header, then vlan.10 should > offload the tag to veth. Otherwise, for any vlan on top of > veth there will be an unneeded memmove(). In this case with this patch, vlan_dev_hard_start_xmit(veth0.10.20) set vlan_tci, dev_hard_start_xmit(veth0.10) put it into skb->data, and vlan_dev_hard_start_xmit(veth0.10) set vlan_tci again. dev_hard_start_xmit(veth0) doesn't put it into skb->data because veth0 has NETIF_F_HW_VLAN_*TAG_TX feature. Similarly, in not stacked vlan case, for example if veth0.10 has no vlan intarface on it, vlan_dev_hard_start_xmit(veth0.10) set vlan_tci and dev_hard_start_xmit(veth0) doesn't put it into skb->data. There will be no unnecessary memmove(). Although I haven't looked over all, other drivers don't seem to have NETIF_F_HW_VLAN_*TAG_TX in vlan_features (at least, bridge, vxlan, e1000e, and bnx2x don't). Thanks, Toshiaki Makita ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] veth: Fix vlan_features so as to be able to use stacked vlan interfaces 2014-02-19 5:22 ` Toshiaki Makita @ 2014-02-20 1:02 ` Flavio Leitner 0 siblings, 0 replies; 7+ messages in thread From: Flavio Leitner @ 2014-02-20 1:02 UTC (permalink / raw) To: Toshiaki Makita; +Cc: David S . Miller, netdev On Wed, Feb 19, 2014 at 02:22:06PM +0900, Toshiaki Makita wrote: > (2014/02/19 13:13), Flavio Leitner wrote: > > On Tue, Feb 18, 2014 at 09:20:08PM +0900, Toshiaki Makita wrote: > >> Even if we create a stacked vlan interface such as veth0.10.20, it sends > >> single tagged frames (tagged with only vid 10). > >> Because vlan_features of a veth interface has the > >> NETIF_F_HW_VLAN_[CTAG/STAG]_TX bits, veth0.10 also has that feature, so > >> dev_hard_start_xmit(veth0.10) doesn't call __vlan_put_tag() and > >> vlan_dev_hard_start_xmit(veth0.10) overwrites vlan_tci. > >> This prevents us from using a combination of 802.1ad and 802.1Q > >> in containers, etc. > >> > >> Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp> > >> --- > >> drivers/net/veth.c | 3 ++- > >> 1 file changed, 2 insertions(+), 1 deletion(-) > >> > >> diff --git a/drivers/net/veth.c b/drivers/net/veth.c > >> index 2ec2041..5b37437 100644 > >> --- a/drivers/net/veth.c > >> +++ b/drivers/net/veth.c > >> @@ -285,7 +285,8 @@ static void veth_setup(struct net_device *dev) > >> dev->ethtool_ops = &veth_ethtool_ops; > >> dev->features |= NETIF_F_LLTX; > >> dev->features |= VETH_FEATURES; > >> - dev->vlan_features = dev->features; > >> + dev->vlan_features = dev->features & > >> + ~(NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX); > >> dev->destructor = veth_dev_free; > >> > >> dev->hw_features = VETH_FEATURES; > >> -- > >> 1.8.1.2 > >> > > > > Why that isn't a problem with another software device? > > Although this patch might fix the issue, it seems to me that > > the middle devices shouldn't use the same feature flags. > > I mean, vlan.20 should add the header, then vlan.10 should > > offload the tag to veth. Otherwise, for any vlan on top of > > veth there will be an unneeded memmove(). > > In this case with this patch, vlan_dev_hard_start_xmit(veth0.10.20) set > vlan_tci, dev_hard_start_xmit(veth0.10) put it into skb->data, and > vlan_dev_hard_start_xmit(veth0.10) set vlan_tci again. > dev_hard_start_xmit(veth0) doesn't put it into skb->data because veth0 > has NETIF_F_HW_VLAN_*TAG_TX feature. > > Similarly, in not stacked vlan case, for example if veth0.10 has no vlan > intarface on it, vlan_dev_hard_start_xmit(veth0.10) set vlan_tci and > dev_hard_start_xmit(veth0) doesn't put it into skb->data. > There will be no unnecessary memmove(). > > Although I haven't looked over all, other drivers don't seem to have > NETIF_F_HW_VLAN_*TAG_TX in vlan_features (at least, bridge, vxlan, > e1000e, and bnx2x don't). > > Thanks, > Toshiaki Makita > Alright, the code looks good and I didn't notice anything different on my testing env. Acked-by: Flavio Leitner <fbl@redhat.com> Thanks! fbl ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] veth: Fix vlan_features so as to be able to use stacked vlan interfaces 2014-02-18 12:20 [PATCH net] veth: Fix vlan_features so as to be able to use stacked vlan interfaces Toshiaki Makita 2014-02-18 12:20 ` [PATCH net] tun: remove bogus hardware vlan acceleration flags from vlan_features Toshiaki Makita 2014-02-19 4:13 ` [PATCH net] veth: Fix vlan_features so as to be able to use stacked vlan interfaces Flavio Leitner @ 2014-02-20 7:16 ` David Miller 2 siblings, 0 replies; 7+ messages in thread From: David Miller @ 2014-02-20 7:16 UTC (permalink / raw) To: makita.toshiaki; +Cc: fbl, netdev From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp> Date: Tue, 18 Feb 2014 21:20:08 +0900 > Even if we create a stacked vlan interface such as veth0.10.20, it sends > single tagged frames (tagged with only vid 10). > Because vlan_features of a veth interface has the > NETIF_F_HW_VLAN_[CTAG/STAG]_TX bits, veth0.10 also has that feature, so > dev_hard_start_xmit(veth0.10) doesn't call __vlan_put_tag() and > vlan_dev_hard_start_xmit(veth0.10) overwrites vlan_tci. > This prevents us from using a combination of 802.1ad and 802.1Q > in containers, etc. > > Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp> Applied and queued up for -stable. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-02-20 7:16 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-02-18 12:20 [PATCH net] veth: Fix vlan_features so as to be able to use stacked vlan interfaces Toshiaki Makita 2014-02-18 12:20 ` [PATCH net] tun: remove bogus hardware vlan acceleration flags from vlan_features Toshiaki Makita 2014-02-20 7:16 ` David Miller 2014-02-19 4:13 ` [PATCH net] veth: Fix vlan_features so as to be able to use stacked vlan interfaces Flavio Leitner 2014-02-19 5:22 ` Toshiaki Makita 2014-02-20 1:02 ` Flavio Leitner 2014-02-20 7:16 ` David Miller
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).