Skip to contentSkip to conversation

ipv6: fix typos in __ip6_finish_output()

PATCH Applied Eric Dumazet 4 participants 4 messages Nov 19, 2021 – Nov 22, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv6: fix typos in __ip6_finish_output()

From: Eric Dumazet <[email protected]>

We deal with IPv6 packets, so we need to use IP6CB(skb)->flags and IP6SKB_REROUTED, instead of IPCB(skb)->flags and IPSKB_REROUTED

Found by code inspection, please double check that fixing this bug does not surface other bugs.

Fixes 09ee9dba9611 ("ipv6: Reinject IPv6 packets if IPsec policy matches after SNAT")
Cc Tobias Brunner <[email protected]>
Cc Steffen Klassert <[email protected]>
Cc David Ahern <[email protected]>
---
 net/ipv6/ip6_output.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/ip6_output.c +1 -1
index 2f044a49afa8cf3586c36607c34073edecafc69c..ff4e83e2a5068322bb93391c7c5e2a8cb932730b 100644
@@ -174,7 +174,7 @@ static int __ip6_finish_output(struct net *net, struct sock *sk, struct sk_buff
 #if defined(CONFIG_NETFILTER) && defined(CONFIG_XFRM)
 	/* Policy lookup after SNAT yielded a new policy */
 	if (skb_dst(skb)->xfrm) {
-		IPCB(skb)->flags |= IPSKB_REROUTED;
+		IP6CB(skb)->flags |= IP6SKB_REROUTED;
 		return dst_output(net, sk, skb);
 	}
 #endif
Signature · 1 line
2.34.0.rc2.393.gf8c9666880-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · Eric Dumazet

From: Eric Dumazet <[email protected]>

We deal with IPv6 packets, so we need to use IP6CB(skb)->flags and IP6SKB_REROUTED, instead of IPCB(skb)->flags and IPSKB_REROUTED

Found by code inspection, please double check that fixing this bug does not surface other bugs.

Fixes 09ee9dba9611 ("ipv6: Reinject IPv6 packets if IPsec policy matches after SNAT")
Cc Tobias Brunner <[email protected]>
Cc Steffen Klassert <[email protected]>
Cc David Ahern <[email protected]>
---
 net/ipv6/ip6_output.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/ip6_output.c +0 -0
index 2f044a49afa8cf3586c36607c34073edecafc69c..ff4e83e2a5068322bb93391c7c5e2a8cb932730b 100644

net/ipv6/ip6_output.c static int __ip6_finish_output(struct net *net, struct sock *sk, struct sk_buff · line 180

Quoted 8 lines
net/ipv6/ip6_output.c +1 -1
@@ -174,7 +174,7 @@ static int __ip6_finish_output(struct net *net, struct sock *sk, struct sk_buff
 #if defined(CONFIG_NETFILTER) && defined(CONFIG_XFRM)
 	/* Policy lookup after SNAT yielded a new policy */
 	if (skb_dst(skb)->xfrm) {
-		IPCB(skb)->flags |= IPSKB_REROUTED;
+		IP6CB(skb)->flags |= IP6SKB_REROUTED;
 		return dst_output(net, sk, skb);
 	}
 #endif

How did that even work - the flags are at different offsets.

VRF driver has the same mistake in vrf_output6_direct (I followed ipv6 code back when and did not pick up on the mistake). prepare_ipv6_hdr in rxe_net.c has a similar style mistake.

Tested-by Acked-by on v1 1/1
#2 lore raw
In reply to Eric Dumazet
Quoted 23 lines · Eric Dumazet

From: Eric Dumazet <[email protected]>

We deal with IPv6 packets, so we need to use IP6CB(skb)->flags and IP6SKB_REROUTED, instead of IPCB(skb)->flags and IPSKB_REROUTED

Found by code inspection, please double check that fixing this bug does not surface other bugs.

Fixes 09ee9dba9611 ("ipv6: Reinject IPv6 packets if IPsec policy matches after SNAT")
Cc Tobias Brunner <[email protected]>
Cc Steffen Klassert <[email protected]>
Cc David Ahern <[email protected]>
---
  net/ipv6/ip6_output.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/ip6_output.c +0 -0
index 2f044a49afa8cf3586c36607c34073edecafc69c..ff4e83e2a5068322bb93391c7c5e2a8cb932730b 100644

net/ipv6/ip6_output.c static int __ip6_finish_output(struct net *net, struct sock *sk, struct sk_buff · line 180

Quoted 8 lines
net/ipv6/ip6_output.c +1 -1
@@ -174,7 +174,7 @@ static int __ip6_finish_output(struct net *net, struct sock *sk, struct sk_buff
  #if defined(CONFIG_NETFILTER) && defined(CONFIG_XFRM)
  	/* Policy lookup after SNAT yielded a new policy */
  	if (skb_dst(skb)->xfrm) {
-		IPCB(skb)->flags |= IPSKB_REROUTED;
+		IP6CB(skb)->flags |= IP6SKB_REROUTED;
  		return dst_output(net, sk, skb);
  	}
  #endif

Thanks for catching this.

#3 lore raw
In reply to Eric Dumazet
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:

Quoted 9 lines · On Thu, 18 Nov 2021 17:37:58 -0800 you wrote:

From: Eric Dumazet <[email protected]>

We deal with IPv6 packets, so we need to use IP6CB(skb)->flags and IP6SKB_REROUTED, instead of IPCB(skb)->flags and IPSKB_REROUTED

Found by code inspection, please double check that fixing this bug does not surface other bugs.

[...]

Here is the summary with links:
- [net] ipv6: fix typos in __ip6_finish_output()

    https://git.kernel.org/netdev/net/c/19d36c5f2948

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html