From: Edwin Peer <edwin.peer@broadcom.com>
To: netdev@vger.kernel.org
Cc: Edwin Peer <edwin.peer@broadcom.com>,
edumazet@google.com, linville@tuxdriver.com,
shemminger@vyatta.com, mirq-linux@rere.qmqm.pl,
jesse.brandeburg@intel.com, jchapman@katalix.com,
david@weave.works, j.vosburgh@gmail.com, vfalico@gmail.com,
andy@greyhouse.net, sridhar.samudrala@intel.com,
jiri@mellanox.com, geoff@infradead.org, mokuno@sm.sony.co.jp,
msink@permonline.ru, mporter@kernel.crashing.org,
inaky.perez-gonzalez@intel.com, jwi@linux.ibm.com,
kgraul@linux.ibm.com, ubraun@linux.ibm.com,
grant.likely@secretlab.ca, hadi@cyberus.ca, dsahern@kernel.org,
shrijeet@gmail.com, jon.mason@intel.com, dave.jiang@intel.com,
saeedm@mellanox.com, hadarh@mellanox.com, ogerlitz@mellanox.com,
allenbh@gmail.com, michael.chan@broadcom.com
Subject: [RFC PATCH net-next 04/11] net: geneve: constrain upper VLAN MTU using IFF_NO_VLAN_ROOM
Date: Wed, 27 May 2020 14:25:05 -0700 [thread overview]
Message-ID: <20200527212512.17901-5-edwin.peer@broadcom.com> (raw)
In-Reply-To: <20200527212512.17901-1-edwin.peer@broadcom.com>
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@broadcom.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
next prev parent reply other threads:[~2020-05-27 21:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-27 21:25 [RFC PATCH net-next 00/11] Nested VLANs - decimate flags and add another Edwin Peer
2020-05-27 21:25 ` [RFC PATCH net-next 01/11] net: geneve: enable vlan offloads Edwin Peer
2020-05-27 21:25 ` [RFC PATCH net-next 02/11] net: do away with the IFF_XMIT_DST_RELEASE_PERM flag Edwin Peer
2020-05-27 21:25 ` [RFC PATCH net-next 03/11] net: vlan: add IFF_NO_VLAN_ROOM to constrain MTU Edwin Peer
2020-05-27 21:25 ` Edwin Peer [this message]
2020-05-27 21:25 ` [RFC PATCH net-next 05/11] net: vxlan: constrain upper VLAN MTU using IFF_NO_VLAN_ROOM Edwin Peer
2020-05-27 21:25 ` [RFC PATCH net-next 06/11] net: l2tp_eth: " Edwin Peer
2020-05-27 21:25 ` [RFC PATCH net-next 07/11] net: gre: " Edwin Peer
2020-05-27 21:25 ` [RFC PATCH net-next 08/11] net: distribute IFF_NO_VLAN_ROOM into aggregate devs Edwin Peer
2020-05-27 21:25 ` [RFC PATCH net-next 09/11] net: ntb_netdev: support VLAN using IFF_NO_VLAN_ROOM Edwin Peer
2020-05-27 21:25 ` [RFC PATCH net-next 10/11] net: vlan: disallow non-Ethernet devices Edwin Peer
2020-05-27 21:25 ` [RFC PATCH net-next 11/11] net: leverage IFF_NO_VLAN_ROOM to limit NETIF_F_VLAN_CHALLENGED Edwin Peer
2020-05-28 0:15 ` [RFC PATCH net-next 00/11] Nested VLANs - decimate flags and add another Michał Mirosław
2020-05-28 0:39 ` Edwin Peer
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=20200527212512.17901-5-edwin.peer@broadcom.com \
--to=edwin.peer@broadcom.com \
--cc=allenbh@gmail.com \
--cc=andy@greyhouse.net \
--cc=dave.jiang@intel.com \
--cc=david@weave.works \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=geoff@infradead.org \
--cc=grant.likely@secretlab.ca \
--cc=hadarh@mellanox.com \
--cc=hadi@cyberus.ca \
--cc=inaky.perez-gonzalez@intel.com \
--cc=j.vosburgh@gmail.com \
--cc=jchapman@katalix.com \
--cc=jesse.brandeburg@intel.com \
--cc=jiri@mellanox.com \
--cc=jon.mason@intel.com \
--cc=jwi@linux.ibm.com \
--cc=kgraul@linux.ibm.com \
--cc=linville@tuxdriver.com \
--cc=michael.chan@broadcom.com \
--cc=mirq-linux@rere.qmqm.pl \
--cc=mokuno@sm.sony.co.jp \
--cc=mporter@kernel.crashing.org \
--cc=msink@permonline.ru \
--cc=netdev@vger.kernel.org \
--cc=ogerlitz@mellanox.com \
--cc=saeedm@mellanox.com \
--cc=shemminger@vyatta.com \
--cc=shrijeet@gmail.com \
--cc=sridhar.samudrala@intel.com \
--cc=ubraun@linux.ibm.com \
--cc=vfalico@gmail.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).