* [Patch net v2] sit: update dev->needed_headroom in ipip6_tunnel_bind_dev()
@ 2023-04-27 6:00 Cong Wang
2023-04-27 6:45 ` Eric Dumazet
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Cong Wang @ 2023-04-27 6:00 UTC (permalink / raw)
To: netdev; +Cc: Cong Wang, Palash Oswal, Kuniyuki Iwashima, Eric Dumazet
From: Cong Wang <cong.wang@bytedance.com>
When a tunnel device is bound with the underlying device, its
dev->needed_headroom needs to be updated properly. IPv4 tunnels
already do the same in ip_tunnel_bind_dev(). Otherwise we may
not have enough header room for skb, especially after commit
b17f709a2401 ("gue: TX support for using remote checksum offload option").
Fixes: 32b8a8e59c9c ("sit: add IPv4 over IPv4 support")
Reported-by: Palash Oswal <oswalpalash@gmail.com>
Link: https://lore.kernel.org/netdev/CAGyP=7fDcSPKu6nttbGwt7RXzE3uyYxLjCSE97J64pRxJP8jPA@mail.gmail.com/
Cc: Kuniyuki Iwashima <kuniyu@amazon.com>
Cc: Eric Dumazet <edumazet@google.com>
Signed-off-by: Cong Wang <cong.wang@bytedance.com>
---
v2: follow reverse Christmas tree style
Note, this is targeting for -net and -table, so I'd keep the fix
small. We can refactor and reuse ip_tunnel_bind_dev() for -net-next.
net/ipv6/sit.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 70d81bba5093..3ffb6a5b1f82 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -1095,12 +1095,13 @@ static netdev_tx_t sit_tunnel_xmit(struct sk_buff *skb,
static void ipip6_tunnel_bind_dev(struct net_device *dev)
{
+ struct ip_tunnel *tunnel = netdev_priv(dev);
+ int t_hlen = tunnel->hlen + sizeof(struct iphdr);
struct net_device *tdev = NULL;
- struct ip_tunnel *tunnel;
+ int hlen = LL_MAX_HEADER;
const struct iphdr *iph;
struct flowi4 fl4;
- tunnel = netdev_priv(dev);
iph = &tunnel->parms.iph;
if (iph->daddr) {
@@ -1123,14 +1124,15 @@ static void ipip6_tunnel_bind_dev(struct net_device *dev)
tdev = __dev_get_by_index(tunnel->net, tunnel->parms.link);
if (tdev && !netif_is_l3_master(tdev)) {
- int t_hlen = tunnel->hlen + sizeof(struct iphdr);
int mtu;
mtu = tdev->mtu - t_hlen;
if (mtu < IPV6_MIN_MTU)
mtu = IPV6_MIN_MTU;
WRITE_ONCE(dev->mtu, mtu);
+ hlen = tdev->hard_header_len + tdev->needed_headroom;
}
+ dev->needed_headroom = t_hlen + hlen;
}
static void ipip6_tunnel_update(struct ip_tunnel *t, struct ip_tunnel_parm *p,
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Patch net v2] sit: update dev->needed_headroom in ipip6_tunnel_bind_dev()
2023-04-27 6:00 [Patch net v2] sit: update dev->needed_headroom in ipip6_tunnel_bind_dev() Cong Wang
@ 2023-04-27 6:45 ` Eric Dumazet
2023-04-27 17:10 ` Kuniyuki Iwashima
2023-04-28 8:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2023-04-27 6:45 UTC (permalink / raw)
To: Cong Wang; +Cc: netdev, Cong Wang, Palash Oswal, Kuniyuki Iwashima
On Thu, Apr 27, 2023 at 8:00 AM Cong Wang <xiyou.wangcong@gmail.com> wrote:
>
> From: Cong Wang <cong.wang@bytedance.com>
>
> When a tunnel device is bound with the underlying device, its
> dev->needed_headroom needs to be updated properly. IPv4 tunnels
> already do the same in ip_tunnel_bind_dev(). Otherwise we may
> not have enough header room for skb, especially after commit
> b17f709a2401 ("gue: TX support for using remote checksum offload option").
>
> Fixes: 32b8a8e59c9c ("sit: add IPv4 over IPv4 support")
> Reported-by: Palash Oswal <oswalpalash@gmail.com>
> Link: https://lore.kernel.org/netdev/CAGyP=7fDcSPKu6nttbGwt7RXzE3uyYxLjCSE97J64pRxJP8jPA@mail.gmail.com/
> Cc: Kuniyuki Iwashima <kuniyu@amazon.com>
> Cc: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Cong Wang <cong.wang@bytedance.com>
> ---
> v2: follow reverse Christmas tree style
>
> Note, this is targeting for -net and -table, so I'd keep the fix
> small. We can refactor and reuse ip_tunnel_bind_dev() for -net-next.
>
> net/ipv6/sit.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch net v2] sit: update dev->needed_headroom in ipip6_tunnel_bind_dev()
2023-04-27 6:00 [Patch net v2] sit: update dev->needed_headroom in ipip6_tunnel_bind_dev() Cong Wang
2023-04-27 6:45 ` Eric Dumazet
@ 2023-04-27 17:10 ` Kuniyuki Iwashima
2023-04-28 8:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Kuniyuki Iwashima @ 2023-04-27 17:10 UTC (permalink / raw)
To: xiyou.wangcong; +Cc: cong.wang, edumazet, kuniyu, netdev, oswalpalash
From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Wed, 26 Apr 2023 23:00:06 -0700
> From: Cong Wang <cong.wang@bytedance.com>
>
> When a tunnel device is bound with the underlying device, its
> dev->needed_headroom needs to be updated properly. IPv4 tunnels
> already do the same in ip_tunnel_bind_dev(). Otherwise we may
> not have enough header room for skb, especially after commit
> b17f709a2401 ("gue: TX support for using remote checksum offload option").
>
> Fixes: 32b8a8e59c9c ("sit: add IPv4 over IPv4 support")
> Reported-by: Palash Oswal <oswalpalash@gmail.com>
> Link: https://lore.kernel.org/netdev/CAGyP=7fDcSPKu6nttbGwt7RXzE3uyYxLjCSE97J64pRxJP8jPA@mail.gmail.com/
> Cc: Kuniyuki Iwashima <kuniyu@amazon.com>
> Cc: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Cong Wang <cong.wang@bytedance.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
> ---
> v2: follow reverse Christmas tree style
nit: less changes needed if we put t_hlen init down.
---8<---
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 70d81bba5093..dce9efba24a9 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -1095,6 +1095,7 @@ static netdev_tx_t sit_tunnel_xmit(struct sk_buff *skb,
static void ipip6_tunnel_bind_dev(struct net_device *dev)
{
+ int t_hlen, hlen = LL_MAX_HEADER;
struct net_device *tdev = NULL;
struct ip_tunnel *tunnel;
const struct iphdr *iph;
@@ -1122,15 +1123,18 @@ static void ipip6_tunnel_bind_dev(struct net_device *dev)
if (!tdev && tunnel->parms.link)
tdev = __dev_get_by_index(tunnel->net, tunnel->parms.link);
+ t_hlen = tunnel->hlen + sizeof(struct iphdr);
+
if (tdev && !netif_is_l3_master(tdev)) {
- int t_hlen = tunnel->hlen + sizeof(struct iphdr);
int mtu;
mtu = tdev->mtu - t_hlen;
if (mtu < IPV6_MIN_MTU)
mtu = IPV6_MIN_MTU;
WRITE_ONCE(dev->mtu, mtu);
+ hlen = tdev->hard_header_len + tdev->needed_headroom;
}
+ dev->needed_headroom = hlen + t_hlen;
}
static void ipip6_tunnel_update(struct ip_tunnel *t, struct ip_tunnel_parm *p,
---8<---
Thanks,
Kuniyuki
>
> Note, this is targeting for -net and -table, so I'd keep the fix
> small. We can refactor and reuse ip_tunnel_bind_dev() for -net-next.
>
> net/ipv6/sit.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
> index 70d81bba5093..3ffb6a5b1f82 100644
> --- a/net/ipv6/sit.c
> +++ b/net/ipv6/sit.c
> @@ -1095,12 +1095,13 @@ static netdev_tx_t sit_tunnel_xmit(struct sk_buff *skb,
>
> static void ipip6_tunnel_bind_dev(struct net_device *dev)
> {
> + struct ip_tunnel *tunnel = netdev_priv(dev);
> + int t_hlen = tunnel->hlen + sizeof(struct iphdr);
> struct net_device *tdev = NULL;
> - struct ip_tunnel *tunnel;
> + int hlen = LL_MAX_HEADER;
> const struct iphdr *iph;
> struct flowi4 fl4;
>
> - tunnel = netdev_priv(dev);
> iph = &tunnel->parms.iph;
>
> if (iph->daddr) {
> @@ -1123,14 +1124,15 @@ static void ipip6_tunnel_bind_dev(struct net_device *dev)
> tdev = __dev_get_by_index(tunnel->net, tunnel->parms.link);
>
> if (tdev && !netif_is_l3_master(tdev)) {
> - int t_hlen = tunnel->hlen + sizeof(struct iphdr);
> int mtu;
>
> mtu = tdev->mtu - t_hlen;
> if (mtu < IPV6_MIN_MTU)
> mtu = IPV6_MIN_MTU;
> WRITE_ONCE(dev->mtu, mtu);
> + hlen = tdev->hard_header_len + tdev->needed_headroom;
> }
> + dev->needed_headroom = t_hlen + hlen;
> }
>
> static void ipip6_tunnel_update(struct ip_tunnel *t, struct ip_tunnel_parm *p,
> --
> 2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Patch net v2] sit: update dev->needed_headroom in ipip6_tunnel_bind_dev()
2023-04-27 6:00 [Patch net v2] sit: update dev->needed_headroom in ipip6_tunnel_bind_dev() Cong Wang
2023-04-27 6:45 ` Eric Dumazet
2023-04-27 17:10 ` Kuniyuki Iwashima
@ 2023-04-28 8:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-04-28 8:50 UTC (permalink / raw)
To: Cong Wang; +Cc: netdev, cong.wang, oswalpalash, kuniyu, edumazet
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:
On Wed, 26 Apr 2023 23:00:06 -0700 you wrote:
> From: Cong Wang <cong.wang@bytedance.com>
>
> When a tunnel device is bound with the underlying device, its
> dev->needed_headroom needs to be updated properly. IPv4 tunnels
> already do the same in ip_tunnel_bind_dev(). Otherwise we may
> not have enough header room for skb, especially after commit
> b17f709a2401 ("gue: TX support for using remote checksum offload option").
>
> [...]
Here is the summary with links:
- [net,v2] sit: update dev->needed_headroom in ipip6_tunnel_bind_dev()
https://git.kernel.org/netdev/net/c/c88f8d5cd95f
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] 4+ messages in thread
end of thread, other threads:[~2023-04-28 8:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-27 6:00 [Patch net v2] sit: update dev->needed_headroom in ipip6_tunnel_bind_dev() Cong Wang
2023-04-27 6:45 ` Eric Dumazet
2023-04-27 17:10 ` Kuniyuki Iwashima
2023-04-28 8:50 ` 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.