netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Jaggi <aj@open.ch>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net,
	kuznet@ms2.inr.ac.ru, kaber@trash.net
Subject: Re: [PATCH] gre: copy ToS/DiffServ bits to outer IP header
Date: Mon, 13 Jul 2009 18:01:42 +0200	[thread overview]
Message-ID: <20090713160142.GA9252@urbino.open.ch> (raw)
In-Reply-To: <20090713083303.61a59b63@nehalam>

On Mon, Jul 13, 2009 at 08:33:03AM -0700, Stephen Hemminger wrote:
> Why make it an option? Sounds like it should always be on.

In some scenarios people might want to set the ToS value for all
GRE tunnel packets to a fixed value (cf. ip tunnel tos option).


Signed-off-by: Andreas Jaggi <aj@open.ch>

diff -urN vanilla-linux-2.6.29.4/include/linux/if_tunnel.h dev-gre/include/linux/if_tunnel.h
--- vanilla-linux-2.6.29.4/include/linux/if_tunnel.h	2009-05-19 01:52:34.000000000 +0200
+++ dev-gre/include/linux/if_tunnel.h	2009-07-13 15:15:26.000000000 +0200
@@ -24,6 +24,7 @@
 #define GRE_REC		__constant_htons(0x0700)
 #define GRE_FLAGS	__constant_htons(0x00F8)
 #define GRE_VERSION	__constant_htons(0x0007)
+#define GRE_COPY_TOS	__constant_htons(0x0008)
 
 struct ip_tunnel_parm
 {
diff -urN vanilla-linux-2.6.29.4/net/ipv4/ip_gre.c dev-gre/net/ipv4/ip_gre.c
--- vanilla-linux-2.6.29.4/net/ipv4/ip_gre.c	2009-05-19 01:52:34.000000000 +0200
+++ dev-gre/net/ipv4/ip_gre.c	2009-07-13 17:56:21.000000000 +0200
@@ -677,7 +677,7 @@
 	}
 
 	tos = tiph->tos;
-	if (tos&1) {
+	if ((tunnel->parms.o_flags & GRE_COPY_TOS) || (tos & 1)) {
 		if (skb->protocol == htons(ETH_P_IP))
 			tos = old_iph->tos;
 		tos &= ~1;
@@ -804,7 +804,7 @@
 			iph->ttl = dst_metric(&rt->u.dst, RTAX_HOPLIMIT);
 	}
 
-	((__be16 *)(iph + 1))[0] = tunnel->parms.o_flags;
+	((__be16 *)(iph + 1))[0] = tunnel->parms.o_flags & ~GRE_FLAGS;
 	((__be16 *)(iph + 1))[1] = (dev->type == ARPHRD_ETHER) ?
 				   htons(ETH_P_TEB) : skb->protocol;
 
@@ -1080,7 +1080,7 @@
 	__be16 *p = (__be16*)(iph+1);
 
 	memcpy(iph, &t->parms.iph, sizeof(struct iphdr));
-	p[0]		= t->parms.o_flags;
+	p[0]		= t->parms.o_flags & ~GRE_FLAGS;
 	p[1]		= htons(type);
 
 	/*
@@ -1503,6 +1503,7 @@
 	t->parms.iph.ttl = p.iph.ttl;
 	t->parms.iph.tos = p.iph.tos;
 	t->parms.iph.frag_off = p.iph.frag_off;
+	t->parms.o_flags |= p.o_flags & GRE_COPY_TOS;
 
 	if (t->parms.link != p.link) {
 		t->parms.link = p.link;

  reply	other threads:[~2009-07-13 16:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-13 13:32 [PATCH] gre: copy ToS/DiffServ bits to outer IP header Andreas Jaggi
2009-07-13 15:33 ` Stephen Hemminger
2009-07-13 16:01   ` Andreas Jaggi [this message]
2009-07-13 16:07     ` Stephen Hemminger
2009-07-13 16:27       ` David Miller
2009-07-13 17:44 ` David Miller
2009-07-14  7:14   ` Andreas Jaggi
2009-07-14 16:35     ` David Miller
2009-07-14 14:21   ` Andreas Jaggi
  -- strict thread matches above, loose matches on Subject: below --
2009-06-29 13:07 Andreas Jaggi
2009-06-29 13:48 ` Patrick McHardy
2009-06-30  9:05   ` Andreas Jaggi
2009-07-01 10:28     ` Patrick McHardy
2009-06-30  9:06   ` Andreas Jaggi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090713160142.GA9252@urbino.open.ch \
    --to=aj@open.ch \
    --cc=davem@davemloft.net \
    --cc=kaber@trash.net \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).