From: Daniel Axtens <dja@axtens.net>
To: netdev@vger.kernel.org
Cc: Daniel Axtens <dja@axtens.net>,
Shannon Nelson <shannon.nelson@oracle.com>
Subject: [PATCH] macvlan: verify MTU before lowerdev xmit
Date: Tue, 14 Nov 2017 21:32:51 +1100 [thread overview]
Message-ID: <20171114103251.5495-1-dja@axtens.net> (raw)
If a macvlan device which is not in bridge mode receives a packet,
it is sent straight to the lowerdev without checking against the
device's MTU. This also happens for multicast traffic.
Add an is_skb_forwardable() check against the lowerdev before
sending the packet out through it. I think this is the simplest
and best way to do it, and is consistent with the use of
dev_forward_skb() in the bridge path.
This is easy to replicate:
- create a VM with a macvtap connection in private mode
- set the lowerdev MTU to something low in the host (e.g. 1480)
- do not set the MTU lower in the guest (e.g. keep at 1500)
- netperf to a different host with the same high MTU
- observe that currently, the driver will forward too-big packets
- observe that with this patch the packets are dropped
Cc: Shannon Nelson <shannon.nelson@oracle.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
---
After hearing Shannon's lightning talk on macvlan at netdev I
figured I'd strike while the iron is hot and get this out of my
patch queue where it has been languishing.
---
drivers/net/macvlan.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index a178c5efd33e..8adcad6798c5 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -534,6 +534,10 @@ static int macvlan_queue_xmit(struct sk_buff *skb, struct net_device *dev)
}
xmit_world:
+ /* verify MTU */
+ if (!is_skb_forwardable(vlan->lowerdev, skb))
+ return NET_XMIT_DROP;
+
skb->dev = vlan->lowerdev;
return dev_queue_xmit(skb);
}
--
2.11.0
next reply other threads:[~2017-11-14 10:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-14 10:32 Daniel Axtens [this message]
2017-11-14 17:03 ` [PATCH] macvlan: verify MTU before lowerdev xmit Shannon Nelson
2017-11-14 19:06 ` Shannon Nelson
2017-11-15 3:27 ` Daniel Axtens
2017-11-17 5:54 ` David Miller
2017-11-17 8:34 ` Daniel Axtens
2017-11-17 8:41 ` David Miller
2017-11-17 12:18 ` Daniel Axtens
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=20171114103251.5495-1-dja@axtens.net \
--to=dja@axtens.net \
--cc=netdev@vger.kernel.org \
--cc=shannon.nelson@oracle.com \
/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).