From: Vlad Yasevich <vyasevic@redhat.com>
To: netdev@vger.kernel.org
Cc: Vlad Yasevich <vyasevic@redhat.com>, Patrik McHardy <kaber@trash.net>
Subject: [RFC PATCH] vlan: Try to adjust lower device mtu when configuring 802.1AD vlans
Date: Tue, 1 Apr 2014 17:17:34 -0400 [thread overview]
Message-ID: <1396387054-4510-1-git-send-email-vyasevic@redhat.com> (raw)
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
next reply other threads:[~2014-04-01 21:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-01 21:17 Vlad Yasevich [this message]
2014-04-01 21:34 ` [RFC PATCH] vlan: Try to adjust lower device mtu when configuring 802.1AD vlans 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
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=1396387054-4510-1-git-send-email-vyasevic@redhat.com \
--to=vyasevic@redhat.com \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
/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).