Skip to contentSkip to conversation

gre: propagate ipv6 transport class

RFC In review Stephen Hemminger 2 participants 2 messages Jul 6, 2010 – Jul 9, 2010

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

RFC 1/1 gre: propagate ipv6 transport class

This patch makes IPV6 over IPv4 GRE tunnel propagate the transport class field from the underlying IPV6 header to the IPV4 Type Of Service field. Without the patch, all IPV6 packets in tunnel look the same to QoS.

This assumes that IPV6 transport class is exactly the same as IPv4 TOS. Not sure if that is always the case? Maybe need to mask off some bits.

The mask and shift to get tclass is copied from ipv6/datagram.c

net/ipv4/ip_gre.c +2 -0
@@ -731,6 +731,8 @@ static netdev_tx_t ipgre_tunnel_xmit(str
 		tos = 0;
 		if (skb->protocol == htons(ETH_P_IP))
 			tos = old_iph->tos;
+		else if (skb->protocol == htons(ETH_P_IPV6))
+			tos = (ntohl(*(__be32 *)ipv6_hdr(skb)) >> 20) & 0xff;
 	}
 
 	{
maintainer
#1 lore raw

From: Stephen Hemminger <[email protected]>
Date: Tue, 6 Jul 2010 10:58:21 -0700

Quoted 11 lines

This patch makes IPV6 over IPv4 GRE tunnel propagate the transport class field from the underlying IPV6 header to the IPV4 Type Of Service field. Without the patch, all IPV6 packets in tunnel look the same to QoS.

This assumes that IPV6 transport class is exactly the same as IPv4 TOS. Not sure if that is always the case? Maybe need to mask off some bits.

The mask and shift to get tclass is copied from ipv6/datagram.c

Looks good, but we should use ipv6_get_dsfield() just like ipgre_ecn_encapsulate() does.

Note that this also influences the route since this 'tos' feeds into the flowi lookup key. We should make sure that this is OK too.

Anyways, I've committed the following to net-next-2.6, thanks!

--------------------
gre: propagate ipv6 transport class

This patch makes IPV6 over IPv4 GRE tunnel propagate the transport class field from the underlying IPV6 header to the IPV4 Type Of Service field. Without the patch, all IPV6 packets in tunnel look the same to QoS.

This assumes that IPV6 transport class is exactly the same as IPv4 TOS. Not sure if that is always the case? Maybe need to mask off some bits.

The mask and shift to get tclass is copied from ipv6/datagram.c

---
 net/ipv4/ip_gre.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
net/ipv4/ip_gre.c +2 -0
index 749e548..945b20a 100644
@@ -731,6 +731,8 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
 		tos = 0;
 		if (skb->protocol == htons(ETH_P_IP))
 			tos = old_iph->tos;
+		else if (skb->protocol == htons(ETH_P_IPV6))
+			tos = ipv6_get_dsfield((struct ipv6hdr *)old_iph);
 	}
 
 	{
Signature · 1 line
1.7.1.1