netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [IP6IP6] Handle ECN correctly
@ 2004-09-09  3:45 Herbert Xu
  2004-09-09  4:40 ` David S. Miller
  0 siblings, 1 reply; 10+ messages in thread
From: Herbert Xu @ 2004-09-09  3:45 UTC (permalink / raw)
  To: David S. Miller, YOSHIFUJI Hideaki, vnourval, netdev

[-- Attachment #1: Type: text/plain, Size: 346 bytes --]

Hi:

This patch adds ECN encapsulation/decapsulation to ip6_tunnel.c.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[-- Attachment #2: p --]
[-- Type: text/plain, Size: 1792 bytes --]

===== net/ipv6/ip6_tunnel.c 1.23 vs edited =====
--- 1.23/net/ipv6/ip6_tunnel.c	2004-06-22 07:34:06 +10:00
+++ edited/net/ipv6/ip6_tunnel.c	2004-09-09 13:34:19 +10:00
@@ -48,6 +48,8 @@
 #include <net/addrconf.h>
 #include <net/ip6_tunnel.h>
 #include <net/xfrm.h>
+#include <net/dsfield.h>
+#include <net/inet_ecn.h>
 
 MODULE_AUTHOR("Ville Nuorvala");
 MODULE_DESCRIPTION("IPv6-in-IPv6 tunnel");
@@ -490,6 +492,15 @@
 	read_unlock(&ip6ip6_lock);
 }
 
+static inline void ip6ip6_ecn_decapsulate(struct ipv6hdr *outer_iph,
+					  struct sk_buff *skb)
+{
+	struct ipv6hdr *inner_iph = skb->nh.ipv6h;
+
+	if (INET_ECN_is_ce(ipv6_get_dsfield(outer_iph)))
+		IP6_ECN_set_ce(inner_iph);
+}
+
 /**
  * ip6ip6_rcv - decapsulate IPv6 packet and retransmit it locally
  *   @skb: received socket buffer
@@ -531,6 +542,7 @@
 		skb->dev = t->dev;
 		dst_release(skb->dst);
 		skb->dst = NULL;
+		ip6ip6_ecn_decapsulate(ipv6h, skb);
 		t->stat.rx_packets++;
 		t->stat.rx_bytes += skb->len;
 		netif_rx(skb);
@@ -621,6 +633,7 @@
 	u8 proto;
 	int err;
 	int pkt_len;
+	int dsfield;
 
 	if (t->recursion++) {
 		stats->collisions++;
@@ -646,6 +659,7 @@
 	memcpy(&fl, &t->fl, sizeof (fl));
 	proto = fl.proto;
 
+	dsfield = ipv6_get_dsfield(ipv6h);
 	if ((t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS))
 		fl.fl6_flowlabel |= (*(__u32 *) ipv6h & IPV6_TCLASS_MASK);
 	if ((t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL))
@@ -717,6 +731,8 @@
 	skb->nh.raw = skb_push(skb, sizeof(struct ipv6hdr));
 	ipv6h = skb->nh.ipv6h;
 	*(u32*)ipv6h = fl.fl6_flowlabel | htonl(0x60000000);
+	dsfield = INET_ECN_encapsulate(0, dsfield);
+	ipv6_change_dsfield(ipv6h, ~INET_ECN_MASK, dsfield);
 	ipv6h->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
 	ipv6h->hop_limit = t->parms.hop_limit;
 	ipv6h->nexthdr = proto;

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

end of thread, other threads:[~2004-09-10 21:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-09  3:45 [IP6IP6] Handle ECN correctly Herbert Xu
2004-09-09  4:40 ` David S. Miller
2004-09-09  4:43   ` Herbert Xu
2004-09-09  4:49     ` David S. Miller
2004-09-09  4:54       ` Herbert Xu
2004-09-09  5:08         ` David S. Miller
2004-09-10  0:31           ` Herbert Xu
2004-09-10  7:02             ` Herbert Xu
2004-09-10 21:58               ` David S. Miller
2004-09-09  7:04       ` Pekka Savola

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).