Skip to content

Commit ff70202

Browse files
NicolasDichteldavem330
authored andcommitted
dev_forward_skb: do not scrub skb mark within the same name space
The goal is to keep the mark during a bpf_redirect(), like it is done for legacy encapsulation / decapsulation, when there is no x-netns. This was initially done in commit 213dd74 ("skbuff: Do not scrub skb mark within the same name space"). When the call to skb_scrub_packet() was added in dev_forward_skb() (commit 8b27f27 ("skb: allow skb_scrub_packet() to be used by tunnels")), the second argument (xnet) was set to true to force a call to skb_orphan(). At this time, the mark was always cleanned up by skb_scrub_packet(), whatever xnet value was. This call to skb_orphan() was removed later in commit 9c4c325 ("skbuff: preserve sock reference when scrubbing the skb."). But this 'true' stayed here without any real reason. Let's correctly set xnet in ____dev_forward_skb(), this function has access to the previous interface and to the new interface. Signed-off-by: Nicolas Dichtel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent be7f62e commit ff70202

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/linux/netdevice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4114,7 +4114,7 @@ static __always_inline int ____dev_forward_skb(struct net_device *dev,
41144114
return NET_RX_DROP;
41154115
}
41164116

4117-
skb_scrub_packet(skb, true);
4117+
skb_scrub_packet(skb, !net_eq(dev_net(dev), dev_net(skb->dev)));
41184118
skb->priority = 0;
41194119
return 0;
41204120
}

0 commit comments

Comments
 (0)