netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] gre: propagate ipv6 transport class
@ 2010-07-06 17:58 Stephen Hemminger
  2010-07-09  4:36 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2010-07-06 17:58 UTC (permalink / raw)
  To: David Miller, YOSHIFUJI Hideaki, Herbert Xu; +Cc: netdev

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

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

--- a/net/ipv4/ip_gre.c	2010-07-06 08:52:03.702096234 -0700
+++ b/net/ipv4/ip_gre.c	2010-07-06 08:59:18.416738831 -0700
@@ -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;
 	}
 
 	{

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [RFC] gre: propagate ipv6 transport class
  2010-07-06 17:58 [RFC] gre: propagate ipv6 transport class Stephen Hemminger
@ 2010-07-09  4:36 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2010-07-09  4:36 UTC (permalink / raw)
  To: shemminger; +Cc: yoshfuji, herbert, netdev

From: Stephen Hemminger <shemminger@vyatta.com>
Date: Tue, 6 Jul 2010 10:58:21 -0700

> 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
> 
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

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

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
 net/ipv4/ip_gre.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 749e548..945b20a 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -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);
 	}
 
 	{
-- 
1.7.1.1




^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-07-09  4:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-06 17:58 [RFC] gre: propagate ipv6 transport class Stephen Hemminger
2010-07-09  4:36 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).