netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix handling of IPv6 RH with 0 segments left
@ 2007-07-07 14:34 Rémi Denis-Courmont
  2007-07-07 14:37 ` YOSHIFUJI Hideaki / 吉藤英明
  0 siblings, 1 reply; 2+ messages in thread
From: Rémi Denis-Courmont @ 2007-07-07 14:34 UTC (permalink / raw)
  To: yoshfuji, netdev

Fix handling of IPv6 Routing Headers with zero segments left.
In that case, we should ignore the extension header and continue with
the next one, rather than return a Paramater Problem.

This is more consistent with RFC2461 (§4.4) and 
draft-ietf-ipv6-deprecate-rh0.

Signed-off-by: Rémi Denis-Courmont <rdenis@simphalempin.com>
---
 net/ipv6/exthdrs.c |   45 +++++++++++++++++++--------------------------
 1 files changed, 19 insertions(+), 26 deletions(-)

diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 14be0b9..7c8fc06 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -398,32 +398,6 @@ static int ipv6_rthdr_rcv(struct sk_buff **skbp)
 
 	hdr = (struct ipv6_rt_hdr *)skb_transport_header(skb);
 
-	switch (hdr->type) {
-#ifdef CONFIG_IPV6_MIP6
-	case IPV6_SRCRT_TYPE_2:
-		break;
-#endif
-	case IPV6_SRCRT_TYPE_0:
-		if (accept_source_route > 0)
-			break;
-		kfree_skb(skb);
-		return -1;
-	default:
-		IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
-				 IPSTATS_MIB_INHDRERRORS);
-		icmpv6_param_prob(skb, ICMPV6_HDR_FIELD,
-				  (&hdr->type) - skb_network_header(skb));
-		return -1;
-	}
-
-	if (ipv6_addr_is_multicast(&ipv6_hdr(skb)->daddr) ||
-	    skb->pkt_type != PACKET_HOST) {
-		IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
-				 IPSTATS_MIB_INADDRERRORS);
-		kfree_skb(skb);
-		return -1;
-	}
-
 looped_back:
 	if (hdr->segments_left == 0) {
 		switch (hdr->type) {
@@ -454,6 +428,11 @@ looped_back:
 
 	switch (hdr->type) {
 	case IPV6_SRCRT_TYPE_0:
+		/* Silently discard RH0 by default */
+		if (accept_source_route <= 0) {
+			kfree_skb(skb);
+			return -1;
+		}
 		if (hdr->hdrlen & 0x01) {
 			IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
 					 IPSTATS_MIB_INHDRERRORS);
@@ -474,6 +453,20 @@ looped_back:
 		}
 		break;
 #endif
+	default:
+		IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
+				 IPSTATS_MIB_INHDRERRORS);
+		icmpv6_param_prob(skb, ICMPV6_HDR_FIELD,
+				  (&hdr->type) - skb_network_header(skb));
+		return -1;
+	}
+
+	if (ipv6_addr_is_multicast(&ipv6_hdr(skb)->daddr) ||
+	    skb->pkt_type != PACKET_HOST) {
+		IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
+				 IPSTATS_MIB_INADDRERRORS);
+		kfree_skb(skb);
+		return -1;
 	}
 
 	/*
-- 
1.5.2.3


-- 
Rémi Denis-Courmont
http://www.remlab.net/

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

end of thread, other threads:[~2007-07-07 14:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-07 14:34 [PATCH] Fix handling of IPv6 RH with 0 segments left Rémi Denis-Courmont
2007-07-07 14:37 ` YOSHIFUJI Hideaki / 吉藤英明

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