* [PATCHv2 net] ipvs: Always clear ipvs_property flag in skb_scrub_packet()
@ 2025-02-22 3:35 Philo Lu
2025-02-25 10:55 ` Julian Anastasov
2025-02-25 12:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Philo Lu @ 2025-02-22 3:35 UTC (permalink / raw)
To: netdev
Cc: davem, edumazet, kuba, pabeni, horms, asml.silence, willemb,
almasrymina, chopps, aleksander.lobakin, nicolas.dichtel,
dust.li, hustcat, ja, horms, bpf, linux-kernel
We found an issue when using bpf_redirect with ipvs NAT mode after
commit ff70202b2d1a ("dev_forward_skb: do not scrub skb mark within
the same name space"). Particularly, we use bpf_redirect to return
the skb directly back to the netif it comes from, i.e., xnet is
false in skb_scrub_packet(), and then ipvs_property is preserved
and SNAT is skipped in the rx path.
ipvs_property has been already cleared when netns is changed in
commit 2b5ec1a5f973 ("netfilter/ipvs: clear ipvs_property flag when
SKB net namespace changed"). This patch just clears it in spite of
netns.
Fixes: 2b5ec1a5f973 ("netfilter/ipvs: clear ipvs_property flag when SKB net namespace changed")
Signed-off-by: Philo Lu <lulie@linux.alibaba.com>
---
v1 -> v2:
- Add Fixes tag as suggested by Julian Anastasov
---
net/core/skbuff.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 7b03b64fdcb2..b1c81687e9d8 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -6033,11 +6033,11 @@ void skb_scrub_packet(struct sk_buff *skb, bool xnet)
skb->offload_fwd_mark = 0;
skb->offload_l3_fwd_mark = 0;
#endif
+ ipvs_reset(skb);
if (!xnet)
return;
- ipvs_reset(skb);
skb->mark = 0;
skb_clear_tstamp(skb);
}
--
2.32.0.3.g01195cf9f
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCHv2 net] ipvs: Always clear ipvs_property flag in skb_scrub_packet()
2025-02-22 3:35 [PATCHv2 net] ipvs: Always clear ipvs_property flag in skb_scrub_packet() Philo Lu
@ 2025-02-25 10:55 ` Julian Anastasov
2025-02-25 12:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Julian Anastasov @ 2025-02-25 10:55 UTC (permalink / raw)
To: Philo Lu
Cc: netdev, davem, edumazet, kuba, pabeni, horms, asml.silence,
willemb, almasrymina, chopps, aleksander.lobakin,
nicolas.dichtel, dust.li, hustcat, horms, bpf, linux-kernel
Hello,
On Sat, 22 Feb 2025, Philo Lu wrote:
> We found an issue when using bpf_redirect with ipvs NAT mode after
> commit ff70202b2d1a ("dev_forward_skb: do not scrub skb mark within
> the same name space"). Particularly, we use bpf_redirect to return
> the skb directly back to the netif it comes from, i.e., xnet is
> false in skb_scrub_packet(), and then ipvs_property is preserved
> and SNAT is skipped in the rx path.
>
> ipvs_property has been already cleared when netns is changed in
> commit 2b5ec1a5f973 ("netfilter/ipvs: clear ipvs_property flag when
> SKB net namespace changed"). This patch just clears it in spite of
> netns.
>
> Fixes: 2b5ec1a5f973 ("netfilter/ipvs: clear ipvs_property flag when SKB net namespace changed")
> Signed-off-by: Philo Lu <lulie@linux.alibaba.com>
Looks good to me, thanks!
Acked-by: Julian Anastasov <ja@ssi.bg>
It was safer to reset the flag when netns changes but
it has role only before output device is reached or while
packet is looped over lo device. New tunnel headers should
be safe to reset it because nf ct and dst are dropped too.
> ---
> v1 -> v2:
> - Add Fixes tag as suggested by Julian Anastasov
> ---
> net/core/skbuff.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 7b03b64fdcb2..b1c81687e9d8 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -6033,11 +6033,11 @@ void skb_scrub_packet(struct sk_buff *skb, bool xnet)
> skb->offload_fwd_mark = 0;
> skb->offload_l3_fwd_mark = 0;
> #endif
> + ipvs_reset(skb);
>
> if (!xnet)
> return;
>
> - ipvs_reset(skb);
> skb->mark = 0;
> skb_clear_tstamp(skb);
> }
> --
> 2.32.0.3.g01195cf9f
Regards
--
Julian Anastasov <ja@ssi.bg>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCHv2 net] ipvs: Always clear ipvs_property flag in skb_scrub_packet()
2025-02-22 3:35 [PATCHv2 net] ipvs: Always clear ipvs_property flag in skb_scrub_packet() Philo Lu
2025-02-25 10:55 ` Julian Anastasov
@ 2025-02-25 12:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-02-25 12:30 UTC (permalink / raw)
To: Philo Lu
Cc: netdev, davem, edumazet, kuba, pabeni, horms, asml.silence,
willemb, almasrymina, chopps, aleksander.lobakin,
nicolas.dichtel, dust.li, hustcat, ja, horms, bpf, linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Sat, 22 Feb 2025 11:35:18 +0800 you wrote:
> We found an issue when using bpf_redirect with ipvs NAT mode after
> commit ff70202b2d1a ("dev_forward_skb: do not scrub skb mark within
> the same name space"). Particularly, we use bpf_redirect to return
> the skb directly back to the netif it comes from, i.e., xnet is
> false in skb_scrub_packet(), and then ipvs_property is preserved
> and SNAT is skipped in the rx path.
>
> [...]
Here is the summary with links:
- [PATCHv2,net] ipvs: Always clear ipvs_property flag in skb_scrub_packet()
https://git.kernel.org/netdev/net/c/de2c211868b9
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:[~2025-02-25 12:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-22 3:35 [PATCHv2 net] ipvs: Always clear ipvs_property flag in skb_scrub_packet() Philo Lu
2025-02-25 10:55 ` Julian Anastasov
2025-02-25 12:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®