Skip to contentSkip to conversation

ipv6 : Don't reduce hop limit below current value

PATCH D. S. Ljungmark 2 participants 4 messages Mar 24, 2015 – Mar 25, 2015

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

A local route may have a lower hop_limit set than global routes do.

See RFC 3756 Section 4.2.7

From 846e648ac8ea9325778a61038a09d98c2fb7002a Mon Sep 17 00:00:00 2001
From: "D.S. Ljungmark" <[email protected]>
Date: Tue, 24 Mar 2015 22:18:47 +0100
Subject: [PATCH] ipv6: Don't reduce hop limit for an interface

A local route may have a lower hop_limit set than global routes do. See RFC 3756 Section 4.2.7

---
 net/ipv6/ndisc.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
net/ipv6/ndisc.c +8 -1
index 471ed24..b939652 100644
@@ -1218,7 +1218,14 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 	if (rt)
 		rt6_set_expires(rt, jiffies + (HZ * lifetime));
 	if (ra_msg->icmph.icmp6_hop_limit) {
-		in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;
+		/*	Only set hop_limit on the interface if it is higher than
+		*	the current hop_limit.
+		 */
+		if (in6_dev->cnf.hop_limit < ra_msg->icmph.icmp6_hop_limit) {
+			in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;
+		} else {
+			ND_PRINTK(2, warn, "RA: Got route advertisement with lower hop_limit than current\n");
+		}
 		if (rt)
 			dst_metric_set(&rt->dst, RTAX_HOPLIMIT,
 				       ra_msg->icmph.icmp6_hop_limit);
Signature · 1 line
2.1.0
maintainer
#1 lore raw

From: "D. S. Ljungmark" <[email protected]>
Date: Tue, 24 Mar 2015 22:36:09 +0100

net/ipv6/ndisc.c static void ndisc_router_discovery(struct sk_buff *skb) · line 1223

Quoted 3 lines
net/ipv6/ndisc.c +3 -0
+		/*	Only set hop_limit on the interface if it is higher than
+		*	the current hop_limit.
+		 */

Comments in the networking should be of the form:

	/* Like
	 * this.
	 */
#2 lore raw
Quoted 9 lines · David Miller

From: "D. S. Ljungmark" <[email protected]>
Date: Tue, 24 Mar 2015 22:36:09 +0100

Review

Quoted 3 lines
(quoted diff) +3 -0
+		/*	Only set hop_limit on the interface if it is higher than
+		*	the current hop_limit.
+		 */

Comments in the networking should be of the form:

Quoted 3 lines
	/* Like
	 * this.
	 */

Not sure if your complaint was about the misaligned *, or that there was a tab char after the comment start rather than a space.

Adjusted both and re-sending.

And there was a comment about quoting the relevant IETF standard,

RFC 3756, Section 4.2.7, "Parameter Spoofing"

1. The attacker includes a Current Hop Limit of one or another small number which the attacker knows will cause legitimate packets to be dropped before they reach their destination.
<snip>

As an example, one possible approach to mitigate this threat is to ignore very small hop limits. The nodes could implement a configurable minimum hop limit, and ignore attempts to set it below said limit.

This patch basically treats the current interface hop limit as the threshold to use.

//D.S.

From 8abb9ca595f83ae4f433dbe2b022c9e16a0cbc39 Mon Sep 17 00:00:00 2001
From: "D.S. Ljungmark" <[email protected]>
Date: Tue, 24 Mar 2015 22:18:47 +0100
Subject: [PATCH] ipv6: Don't reduce hop limit for an interface

A local route may have a lower hop_limit set than global routes do. See RFC 3756 Section 4.2.7

---
 net/ipv6/ndisc.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
net/ipv6/ndisc.c +8 -1
index 471ed24..14ecdaf 100644
@@ -1218,7 +1218,14 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 	if (rt)
 		rt6_set_expires(rt, jiffies + (HZ * lifetime));
 	if (ra_msg->icmph.icmp6_hop_limit) {
-		in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;
+		/* Only set hop_limit on the interface if it is higher than
+		 * the current hop_limit.
+		 */
+		if (in6_dev->cnf.hop_limit < ra_msg->icmph.icmp6_hop_limit) {
+			in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;
+		} else {
+			ND_PRINTK(2, warn, "RA: Got route advertisement with lower hop_limit than current\n");
+		}
 		if (rt)
 			dst_metric_set(&rt->dst, RTAX_HOPLIMIT,
 				       ra_msg->icmph.icmp6_hop_limit);
Signature · 1 line
2.1.0
maintainer
#3 lore raw

From: "D. S. Ljungmark" <[email protected]>
Date: Wed, 25 Mar 2015 00:36:38 +0100

Quoted 10 lines · David Miller
Quoted 9 lines

From: "D. S. Ljungmark" <[email protected]>
Date: Tue, 24 Mar 2015 22:36:09 +0100

net/ipv6/ndisc.c static void ndisc_router_discovery(struct sk_buff *skb) · line 1223

Quoted 3 lines
net/ipv6/ndisc.c +3 -0
+		/*	Only set hop_limit on the interface if it is higher than
+		*	the current hop_limit.
+		 */

Comments in the networking should be of the form:

Quoted 8 lines
Quoted 3 lines
	/* Like
	 * this.
	 */

Not sure if your complaint was about the misaligned *, or that there was a tab char after the comment start rather than a space.

Adjusted both and re-sending.

This is not how you resubmit a patch.

When you are asked to make a change in your submission, you must make a fresh, new, patch posting with full commit message and Signoffs.