netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] vlan: Try to adjust lower device mtu when configuring 802.1AD vlans
@ 2014-04-01 21:17 Vlad Yasevich
  2014-04-01 21:34 ` Florian Fainelli
  2014-04-02 12:21 ` Patrick McHardy
  0 siblings, 2 replies; 11+ messages in thread
From: Vlad Yasevich @ 2014-04-01 21:17 UTC (permalink / raw)
  To: netdev; +Cc: Vlad Yasevich, Patrik McHardy

802.1AD vlans supposed to encapsulate 802.1Q vlans.  To
do this, we need an extra 4 bytes of header which are typically
not accounted for by lower devices.  Some devices can not
support frames longer then 1522 bytes at all.  Such devices
can not really support 802.1AD, even in software, without
the vlan reducing its mtu value.

This patch propses to increate the lower devices MTU to 1504
in case of 802.1AD configuration, and if device doesn't
support it, fail the creation of the vlan.  The user has an
option to configure older-style Q-in-Q vlans and manually
lower the mtu to support such encapsulation.

CC: Patrik McHardy <kaber@trash.net>
Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
---
 net/8021q/vlan.c         | 17 +++++++++++++++++
 net/8021q/vlan_netlink.c | 11 ++++++++---
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 175273f..0328d73 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -126,6 +126,7 @@ int vlan_check_real_dev(struct net_device *real_dev,
 			__be16 protocol, u16 vlan_id)
 {
 	const char *name = real_dev->name;
+	int err;
 
 	if (real_dev->features & NETIF_F_VLAN_CHALLENGED) {
 		pr_info("VLANs not supported on %s\n", name);
@@ -135,6 +136,21 @@ int vlan_check_real_dev(struct net_device *real_dev,
 	if (vlan_find_dev(real_dev, protocol, vlan_id) != NULL)
 		return -EEXIST;
 
+	if (protocol == htons(ETH_P_8021AD)) {
+		/* 8021AD vlan is meant to encapsulate 8021Q and thus we
+		 * need to make sure that lower device can handle a
+		 * larger mtu.
+		 * If the lower device still has a default ethernet mtu,
+		 * bump it up 4 bytes.  If not, it was set by user and
+		 * we'll trust the user knows what he is doing.
+		 */
+		if (real_dev->mtu == VLAN_ETH_DATA_LEN &&
+		    dev_set_mtu(real_dev, real_dev->mtu + VLAN_HLEN))
+			pr_warn("802.1AD mode is not supported on %s due to mtu limitations.\n", name);
+			return -EOPNOTSUPP
+		} 
+	}
+
 	return 0;
 }
 
@@ -259,6 +275,7 @@ static int register_vlan_device(struct net_device *real_dev, u16 vlan_id)
 	 * hope the underlying device can handle it.
 	 */
 	new_dev->mtu = real_dev->mtu;
+
 	new_dev->priv_flags |= (real_dev->priv_flags & IFF_UNICAST_FLT);
 
 	vlan = vlan_dev_priv(new_dev);
diff --git a/net/8021q/vlan_netlink.c b/net/8021q/vlan_netlink.c
index c7e634a..a925a8d 100644
--- a/net/8021q/vlan_netlink.c
+++ b/net/8021q/vlan_netlink.c
@@ -144,10 +144,15 @@ static int vlan_newlink(struct net *src_net, struct net_device *dev,
 	if (err < 0)
 		return err;
 
-	if (!tb[IFLA_MTU])
-		dev->mtu = real_dev->mtu;
-	else if (dev->mtu > real_dev->mtu)
+	if (!tb[IFLA_MTU]) {
+		if (vlan->vlan_proto == htons(ETH_P_8021AD) &&
+	    	    real_dev->mtu == VLAN_ETH_DATA_LEN + VLAN_HLEN)
+			dev->mtu = VLAN_ETH_DATA_LEN;
+		else
+			dev->mtu = real_dev->mtu;
+	} else if (dev->mtu > real_dev->mtu) {
 		return -EINVAL;
+	}
 
 	err = vlan_changelink(dev, tb, data);
 	if (err < 0)
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-04-06 15:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-01 21:17 [RFC PATCH] vlan: Try to adjust lower device mtu when configuring 802.1AD vlans Vlad Yasevich
2014-04-01 21:34 ` Florian Fainelli
2014-04-02 12:21 ` Patrick McHardy
2014-04-02 13:31   ` Vlad Yasevich
2014-04-02 16:37     ` Toshiaki Makita
2014-04-02 16:44       ` Vlad Yasevich
2014-04-03  8:32         ` Toshiaki Makita
2014-04-03 13:07           ` Vlad Yasevich
2014-04-04 15:08             ` Toshiaki Makita
2014-04-04 15:22               ` Vlad Yasevich
2014-04-06 15:21                 ` Toshiaki Makita

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