Skip to contentSkip to conversation

gre: fix ToS/DiffServ inherit bug

PATCH In review Andreas Jaggi 3 participants 4 messages Jul 14, 2009

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

PATCH 1/1 gre: fix ToS/DiffServ inherit bug

Fixes two bugs:
- ToS/DiffServ inheritance was unintentionally activated when using impair fixed ToS values
- ECN bit was lost during ToS/DiffServ inheritance

net/ipv4/ip_gre.c +2 -2
@@ -677,10 +677,10 @@
 	}
 
 	tos = tiph->tos;
-	if (tos&1) {
+	if (tos == 1) {
+		tos = 0;
 		if (skb->protocol == htons(ETH_P_IP))
 			tos = old_iph->tos;
-		tos &= ~1;
 	}
 
 	{
maintainer
#1 lore raw

From: Andreas Jaggi <[email protected]>
Date: Tue, 14 Jul 2009 17:36:48 +0200

Quoted 5 lines

Fixes two bugs:
- ToS/DiffServ inheritance was unintentionally activated when using impair fixed ToS values
- ECN bit was lost during ToS/DiffServ inheritance

...

net/ipv4/ip_gre.c line 684

Quoted 8 lines
net/ipv4/ip_gre.c +2 -2
 	tos = tiph->tos;
-	if (tos&1) {
+	if (tos == 1) {
+		tos = 0;
 		if (skb->protocol == htons(ETH_P_IP))
 			tos = old_iph->tos;
-		tos &= ~1;
 	}

Note that this only works out because one wouldn't specify ECN bits in the TOS to use for the tunnel.

But it demonstrates the outright danger of trying to use "undefined" flag bits in protocol header fields to pass private control flags into the driver from user interfaces.

maintainer
#2 lore raw

From: David Miller <[email protected]>
Date: Tue, 14 Jul 2009 09:34:33 -0700 (PDT)

Quoted 8 lines

From: Andreas Jaggi <[email protected]>
Date: Tue, 14 Jul 2009 17:36:48 +0200

Quoted 5 lines

Fixes two bugs:
- ToS/DiffServ inheritance was unintentionally activated when using impair fixed ToS values
- ECN bit was lost during ToS/DiffServ inheritance

In case it wasn't clear, I've applied this patch.

#3 lore raw
In reply to David Miller

Hello!

Quoted 6 lines · David Miller

Note that this only works out because one wouldn't specify ECN bits in the TOS to use for the tunnel.

But it demonstrates the outright danger of trying to use "undefined" flag bits in protocol header fields to pass private control flags into the driver from user interfaces.

Yes. My fault.

Well, in the form after the patch it will survive at least until the next change of semantics of tos. :-)

Alexey