* [RESEND net v3] net: ip_tunnel: fix mtu calculation
@ 2021-01-29 22:27 Vadim Fedorenko
2021-01-30 0:28 ` Cong Wang
2021-02-02 4:10 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Vadim Fedorenko @ 2021-01-29 22:27 UTC (permalink / raw)
To: Jakub Kicinski, Willem de Bruijn, Slava Bacherikov
Cc: Vadim Fedorenko, netdev
dev->hard_header_len for tunnel interface is set only when header_ops
are set too and already contains full overhead of any tunnel encapsulation.
That's why there is not need to use this overhead twice in mtu calc.
Fixes: fdafed459998 ("ip_gre: set dev->hard_header_len and dev->needed_headroom properly")
Reported-by: Slava Bacherikov <mail@slava.cc>
Signed-off-by: Vadim Fedorenko <vfedorenko@novek.ru>
---
net/ipv4/ip_tunnel.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 64594aa..76a420c 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -317,7 +317,7 @@ static int ip_tunnel_bind_dev(struct net_device *dev)
}
dev->needed_headroom = t_hlen + hlen;
- mtu -= (dev->hard_header_len + t_hlen);
+ mtu -= t_hlen;
if (mtu < IPV4_MIN_MTU)
mtu = IPV4_MIN_MTU;
@@ -347,7 +347,7 @@ static struct ip_tunnel *ip_tunnel_create(struct net *net,
nt = netdev_priv(dev);
t_hlen = nt->hlen + sizeof(struct iphdr);
dev->min_mtu = ETH_MIN_MTU;
- dev->max_mtu = IP_MAX_MTU - dev->hard_header_len - t_hlen;
+ dev->max_mtu = IP_MAX_MTU - t_hlen;
ip_tunnel_add(itn, nt);
return nt;
@@ -488,11 +488,10 @@ static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb,
int mtu;
tunnel_hlen = md ? tunnel_hlen : tunnel->hlen;
- pkt_size = skb->len - tunnel_hlen - dev->hard_header_len;
+ pkt_size = skb->len - tunnel_hlen;
if (df)
- mtu = dst_mtu(&rt->dst) - dev->hard_header_len
- - sizeof(struct iphdr) - tunnel_hlen;
+ mtu = dst_mtu(&rt->dst) - (sizeof(struct iphdr) + tunnel_hlen);
else
mtu = skb_valid_dst(skb) ? dst_mtu(skb_dst(skb)) : dev->mtu;
@@ -972,7 +971,7 @@ int __ip_tunnel_change_mtu(struct net_device *dev, int new_mtu, bool strict)
{
struct ip_tunnel *tunnel = netdev_priv(dev);
int t_hlen = tunnel->hlen + sizeof(struct iphdr);
- int max_mtu = IP_MAX_MTU - dev->hard_header_len - t_hlen;
+ int max_mtu = IP_MAX_MTU - t_hlen;
if (new_mtu < ETH_MIN_MTU)
return -EINVAL;
@@ -1149,10 +1148,9 @@ int ip_tunnel_newlink(struct net_device *dev, struct nlattr *tb[],
mtu = ip_tunnel_bind_dev(dev);
if (tb[IFLA_MTU]) {
- unsigned int max = IP_MAX_MTU - dev->hard_header_len - nt->hlen;
+ unsigned int max = IP_MAX_MTU - (nt->hlen + sizeof(struct iphdr));
- mtu = clamp(dev->mtu, (unsigned int)ETH_MIN_MTU,
- (unsigned int)(max - sizeof(struct iphdr)));
+ mtu = clamp(dev->mtu, (unsigned int)ETH_MIN_MTU, max);
}
err = dev_set_mtu(dev, mtu);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RESEND net v3] net: ip_tunnel: fix mtu calculation
2021-01-29 22:27 [RESEND net v3] net: ip_tunnel: fix mtu calculation Vadim Fedorenko
@ 2021-01-30 0:28 ` Cong Wang
2021-02-02 4:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Cong Wang @ 2021-01-30 0:28 UTC (permalink / raw)
To: Vadim Fedorenko
Cc: Jakub Kicinski, Willem de Bruijn, Slava Bacherikov,
Linux Kernel Network Developers
On Fri, Jan 29, 2021 at 2:30 PM Vadim Fedorenko <vfedorenko@novek.ru> wrote:
>
> dev->hard_header_len for tunnel interface is set only when header_ops
> are set too and already contains full overhead of any tunnel encapsulation.
> That's why there is not need to use this overhead twice in mtu calc.
>
> Fixes: fdafed459998 ("ip_gre: set dev->hard_header_len and dev->needed_headroom properly")
> Reported-by: Slava Bacherikov <mail@slava.cc>
> Signed-off-by: Vadim Fedorenko <vfedorenko@novek.ru>
I have no objection, just please double check this does not break
other IP tunnels as you touch the core ip tunnel code, especially
those using ip_tunnel_header_ops.
Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RESEND net v3] net: ip_tunnel: fix mtu calculation
2021-01-29 22:27 [RESEND net v3] net: ip_tunnel: fix mtu calculation Vadim Fedorenko
2021-01-30 0:28 ` Cong Wang
@ 2021-02-02 4:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-02-02 4:10 UTC (permalink / raw)
To: Vadim Fedorenko; +Cc: kuba, willemdebruijn.kernel, mail, netdev
Hello:
This patch was applied to netdev/net.git (refs/heads/master):
On Sat, 30 Jan 2021 01:27:47 +0300 you wrote:
> dev->hard_header_len for tunnel interface is set only when header_ops
> are set too and already contains full overhead of any tunnel encapsulation.
> That's why there is not need to use this overhead twice in mtu calc.
>
> Fixes: fdafed459998 ("ip_gre: set dev->hard_header_len and dev->needed_headroom properly")
> Reported-by: Slava Bacherikov <mail@slava.cc>
> Signed-off-by: Vadim Fedorenko <vfedorenko@novek.ru>
>
> [...]
Here is the summary with links:
- [RESEND,net,v3] net: ip_tunnel: fix mtu calculation
https://git.kernel.org/netdev/net/c/28e104d00281
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-02 4:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-29 22:27 [RESEND net v3] net: ip_tunnel: fix mtu calculation Vadim Fedorenko
2021-01-30 0:28 ` Cong Wang
2021-02-02 4:10 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.