From: "Rémi Denis-Courmont" <rdenis@simphalempin.com>
To: yoshfuji@linux-ipv6.org, netdev@vger.kernel.org
Subject: [PATCH] Fix handling of IPv6 RH with 0 segments left
Date: Sat, 7 Jul 2007 17:34:59 +0300 [thread overview]
Message-ID: <200707071735.00366@auguste.remlab.net> (raw)
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/
next reply other threads:[~2007-07-07 14:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-07 14:34 Rémi Denis-Courmont [this message]
2007-07-07 14:37 ` [PATCH] Fix handling of IPv6 RH with 0 segments left YOSHIFUJI Hideaki / 吉藤英明
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=200707071735.00366@auguste.remlab.net \
--to=rdenis@simphalempin.com \
--cc=netdev@vger.kernel.org \
--cc=yoshfuji@linux-ipv6.org \
/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).