lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 27 May 2020 14:25:05 -0700
From:   Edwin Peer <edwin.peer@...adcom.com>
To:     netdev@...r.kernel.org
Cc:     Edwin Peer <edwin.peer@...adcom.com>, edumazet@...gle.com,
        linville@...driver.com, shemminger@...tta.com,
        mirq-linux@...e.qmqm.pl, jesse.brandeburg@...el.com,
        jchapman@...alix.com, david@...ve.works, j.vosburgh@...il.com,
        vfalico@...il.com, andy@...yhouse.net, sridhar.samudrala@...el.com,
        jiri@...lanox.com, geoff@...radead.org, mokuno@...sony.co.jp,
        msink@...monline.ru, mporter@...nel.crashing.org,
        inaky.perez-gonzalez@...el.com, jwi@...ux.ibm.com,
        kgraul@...ux.ibm.com, ubraun@...ux.ibm.com,
        grant.likely@...retlab.ca, hadi@...erus.ca, dsahern@...nel.org,
        shrijeet@...il.com, jon.mason@...el.com, dave.jiang@...el.com,
        saeedm@...lanox.com, hadarh@...lanox.com, ogerlitz@...lanox.com,
        allenbh@...il.com, michael.chan@...adcom.com
Subject: [RFC PATCH net-next 04/11] net: geneve: constrain upper VLAN MTU using IFF_NO_VLAN_ROOM

Constrain the MTU of upper VLAN devices if the MTU of the Geneve device
is configured to its default optimal size, which does not leave space
for a nested VLAN tag without causing fragmentation. If the underlying
best MTU is not known, then the worst case is assumed and any upper VLAN
devices will always be adjusted to accommodate the VLAN tag.

Signed-off-by: Edwin Peer <edwin.peer@...adcom.com>
---
 drivers/net/geneve.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 8d790cf85b21..9c8e6f242f77 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -67,6 +67,7 @@ struct geneve_dev {
 	bool		   use_udp6_rx_checksums;
 	bool		   ttl_inherit;
 	enum ifla_geneve_df df;
+	int		   best_mtu;
 };
 
 struct geneve_sock {
@@ -1020,12 +1021,15 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, struct net_device *dev)
 
 static int geneve_change_mtu(struct net_device *dev, int new_mtu)
 {
+	struct geneve_dev *geneve = netdev_priv(dev);
+
 	if (new_mtu > dev->max_mtu)
 		new_mtu = dev->max_mtu;
 	else if (new_mtu < dev->min_mtu)
 		new_mtu = dev->min_mtu;
 
 	dev->mtu = new_mtu;
+	__vlan_constrain_mtu(dev, geneve->best_mtu);
 	return 0;
 }
 
@@ -1497,7 +1501,6 @@ static void geneve_link_config(struct net_device *dev,
 			       struct ip_tunnel_info *info, struct nlattr *tb[])
 {
 	struct geneve_dev *geneve = netdev_priv(dev);
-	int ldev_mtu = 0;
 
 	if (tb[IFLA_MTU]) {
 		geneve_change_mtu(dev, nla_get_u32(tb[IFLA_MTU]));
@@ -1510,7 +1513,7 @@ static void geneve_link_config(struct net_device *dev,
 		struct rtable *rt = ip_route_output_key(geneve->net, &fl4);
 
 		if (!IS_ERR(rt) && rt->dst.dev) {
-			ldev_mtu = rt->dst.dev->mtu - GENEVE_IPV4_HLEN;
+			geneve->best_mtu = rt->dst.dev->mtu - GENEVE_IPV4_HLEN;
 			ip_rt_put(rt);
 		}
 		break;
@@ -1526,17 +1529,19 @@ static void geneve_link_config(struct net_device *dev,
 				NULL, 0);
 
 		if (rt && rt->dst.dev)
-			ldev_mtu = rt->dst.dev->mtu - GENEVE_IPV6_HLEN;
+			geneve->best_mtu = rt->dst.dev->mtu - GENEVE_IPV6_HLEN;
 		ip6_rt_put(rt);
 		break;
 	}
 #endif
 	}
 
-	if (ldev_mtu <= 0)
+	geneve->best_mtu -= info->options_len;
+
+	if (geneve->best_mtu <= 0)
 		return;
 
-	geneve_change_mtu(dev, ldev_mtu - info->options_len);
+	geneve_change_mtu(dev, geneve->best_mtu);
 }
 
 static int geneve_newlink(struct net *net, struct net_device *dev,
-- 
2.26.2

Powered by blists - more mailing lists