Skip to contentSkip to conversation

ipv6: Don't unset flowi6_proto in ipxip6_tnl_xmit()

PATCH In review Eli Cooper 3 participants 6 messages Aug 26, 2016 – Sep 2, 2016

Subsystems (3)
lore
Share & tools
lore

Eli Cooper

author
#0 lore raw

PATCH 1/1 ipv6: Don't unset flowi6_proto in ipxip6_tnl_xmit()

Commit 8eb30be0352d0916 ("ipv6: Create ip6_tnl_xmit") unsets flowi6_proto in ip4ip6_tnl_xmit() and ip6ip6_tnl_xmit(). Since xfrm_selector_match() relies on this info, IPv6 packets sent by an ip6tunnel cannot be properly selected by their protocols after removing it. This patch puts flowi6_proto back.

Fixes 8eb30be0352d ("ipv6: Create ip6_tnl_xmit")
---
 net/ipv6/ip6_tunnel.c | 2 ++
 1 file changed, 2 insertions(+)
net/ipv6/ip6_tunnel.c +2 -0
index 2050217..5c57797 100644
@@ -1174,6 +1174,7 @@ ip4ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
 		encap_limit = t->parms.encap_limit;
 
 	memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6));
+	fl6.flowi6_proto = IPPROTO_IPIP;
 
 	dsfield = ipv4_get_dsfield(iph);
 
@@ -1233,6 +1234,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
 		encap_limit = t->parms.encap_limit;
 
 	memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6));
+	fl6.flowi6_proto = IPPROTO_IPV6;
 
 	dsfield = ipv6_get_dsfield(ipv6h);
 	if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
Signature · 1 line
2.9.3
#1 lore raw

Hi,

Quoted 26 lines · On Fri, 26 Aug 2016 23:52:29 +0800 Eli Cooper <[email protected]> wrote:

Commit 8eb30be0352d0916 ("ipv6: Create ip6_tnl_xmit") unsets flowi6_proto in ip4ip6_tnl_xmit() and ip6ip6_tnl_xmit(). Since xfrm_selector_match() relies on this info, IPv6 packets sent by an ip6tunnel cannot be properly selected by their protocols after removing it. This patch puts flowi6_proto back.

Fixes 8eb30be0352d ("ipv6: Create ip6_tnl_xmit")
---
 net/ipv6/ip6_tunnel.c | 2 ++
 1 file changed, 2 insertions(+)
net/ipv6/ip6_tunnel.c +1 -0
index 2050217..5c57797 100644
@@ -1174,6 +1174,7 @@ ip4ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
 		encap_limit = t->parms.encap_limit;
 
 	memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6));
+	fl6.flowi6_proto = IPPROTO_IPIP;
 
 	dsfield = ipv4_get_dsfield(iph);
 

net/ipv6/ip6_tunnel.c ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev) · line 1238

Quoted 5 lines
net/ipv6/ip6_tunnel.c +1 -0
@@ -1233,6 +1234,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
 		encap_limit = t->parms.encap_limit;
 
 	memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6));
+	fl6.flowi6_proto = IPPROTO_IPV6;
 

I wonder if this is the right way to go.

This DOES fix the regression for ip4ip6_tnl_xmit and ip6ip6_tnl_xmit users.

However new users of 'ip6_tnl_xmit' (e.g. __gre6_xmit callers) may still have their 'fl6->flowi6_proto' not armed.

Maybe the right fix is assigning 'fl6->flowi6_proto = proto', either at start of 'ip6_tnl_xmit' or just prior the ip6_route_output() call.

Tom, can you acknowledge?

Thanks,
Shmulik

author
#2 lore raw

Hi,

Quoted 5 lines · Shmulik Ladkani

However new users of 'ip6_tnl_xmit' (e.g. __gre6_xmit callers) may still have their 'fl6->flowi6_proto' not armed.

Maybe the right fix is assigning 'fl6->flowi6_proto = proto', either at start of 'ip6_tnl_xmit' or just prior the ip6_route_output() call.

The only other user of ip6_tnl_xmit() is ip6gre, and it has its fl6->flowi6_proto set in ip6gre_tnl_link_config() as in commit 252f3f5a1189 ("ip6_gre: Set flowi6_proto as IPPROTO_GRE in xmit path.")

Assigning flowi6_proto at the start of ip6_tnl_xmit() was also my first idea, but I was unsure which fix would be better.

Thanks,
Eli

maintainer
#3 lore raw
In reply to Eli Cooper

From: Eli Cooper <[email protected]>
Date: Fri, 26 Aug 2016 23:52:29 +0800

net/ipv6/ip6_tunnel.c ip4ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev) · line 1177

Quoted 5 lines
net/ipv6/ip6_tunnel.c +1 -0
@@ -1174,6 +1174,7 @@ ip4ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
 		encap_limit = t->parms.encap_limit;
 
 	memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6));
+	fl6.flowi6_proto = IPPROTO_IPIP;

Let's just simply have t->fl have the proto setup properly, just like in GRE.

Assigning it explicitly every packet transmit doesn't make much sense.

author
#4 lore raw

Hello,

Quoted 6 lines · David Miller

From: Eli Cooper <[email protected]>
Date: Fri, 26 Aug 2016 23:52:29 +0800

Quoted 3 lines
(quoted diff) +0 -0
@@ -1174,6 +1174,7 @@ ip4ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
 		encap_limit = t->parms.encap_limit;
 
Quoted 6 lines

net/ipv6/ip6_tunnel.c ip4ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev) · line 1177

Quoted 2 lines
net/ipv6/ip6_tunnel.c +1 -0
 	memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6));
+	fl6.flowi6_proto = IPPROTO_IPIP;

Let's just simply have t->fl have the proto setup properly, just like in GRE.

Assigning it explicitly every packet transmit doesn't make much sense.

I doubt that. Unlike GRE, where the proto must be IPPROTO_GRE, the proto here can be either IPPROTO_IPV6 or IPPROTO_IPIP for a single tunnel, and t->fl is shared by them. Thus it has to be assigned for every packet.

Thanks,
Eli

maintainer
#5 lore raw

From: Eli Cooper <[email protected]>
Date: Thu, 1 Sep 2016 09:18:04 +0800

Quoted 14 lines

Hello,

Quoted 11 lines · David Miller

From: Eli Cooper <[email protected]>
Date: Fri, 26 Aug 2016 23:52:29 +0800

net/ipv6/ip6_tunnel.c ip4ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev) · line 1177

Quoted 5 lines
net/ipv6/ip6_tunnel.c +1 -0
@@ -1174,6 +1174,7 @@ ip4ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
 		encap_limit = t->parms.encap_limit;
 
 	memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6));
+	fl6.flowi6_proto = IPPROTO_IPIP;

Let's just simply have t->fl have the proto setup properly, just like in GRE.

Quoted 5 lines
Quoted 1 line

Assigning it explicitly every packet transmit doesn't make much sense.

I doubt that. Unlike GRE, where the proto must be IPPROTO_GRE, the proto here can be either IPPROTO_IPV6 or IPPROTO_IPIP for a single tunnel, and t->fl is shared by them. Thus it has to be assigned for every packet.

You're right. Patch applied, thanks for explaining.