]> www.infradead.org Git - users/hch/misc.git/commitdiff
ipvs: Always clear ipvs_property flag in skb_scrub_packet()
authorPhilo Lu <lulie@linux.alibaba.com>
Sat, 22 Feb 2025 03:35:18 +0000 (11:35 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 25 Feb 2025 12:15:17 +0000 (13:15 +0100)
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>
Acked-by: Julian Anastasov <ja@ssi.bg>
Link: https://patch.msgid.link/20250222033518.126087-1-lulie@linux.alibaba.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/core/skbuff.c

index 7b03b64fdcb276f68ce881d1d8da8e4c6b897efc..b1c81687e9d825111bd0a68b2b6ccb423d9db35e 100644 (file)
@@ -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);
 }