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 <[EMAIL PROTECTED]>
---
 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/
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to