Skip to contentSkip to conversation

ipv4: unnecessary to set err on no_route path

PATCH In review [email protected] 3 participants 3 messages Sep 29, 2014

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

PATCH 1/1 ipv4: unnecessary to set err on no_route path

From: Li RongQing <[email protected]>

When the code skips to no_route label, it will skip to local_input at last, then err will be reset on the local_input path before exit function.

---
 net/ipv4/route.c |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
net/ipv4/route.c +4 -7
index d4bd68d..403914b 100644
@@ -1704,11 +1704,9 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
 	fl4.daddr = daddr;
 	fl4.saddr = saddr;
 	err = fib_lookup(net, &fl4, &res);
-	if (err != 0) {
-		if (!IN_DEV_FORWARD(in_dev))
-			err = -EHOSTUNREACH;
+	if (err != 0)
 		goto no_route;
-	}
+
 
 	if (res.type == RTN_BROADCAST)
 		goto brd_input;
@@ -1721,10 +1719,9 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
 		goto local_input;
 	}
 
-	if (!IN_DEV_FORWARD(in_dev)) {
-		err = -EHOSTUNREACH;
+	if (!IN_DEV_FORWARD(in_dev))
 		goto no_route;
-	}
+
 	if (res.type != RTN_UNICAST)
 		goto martian_destination;
 
Signature · 1 line
1.7.10.4
#1 lore raw

Hello.

Quoted 15 lines · On 9/29/2014 1:16 PM, [email protected] wrote:

From: Li RongQing <[email protected]>

When the code skips to no_route label, it will skip to local_input at last, then err will be reset on the local_input path before exit function.

---
  net/ipv4/route.c |   11 ++++-------
  1 file changed, 4 insertions(+), 7 deletions(-)
net/ipv4/route.c +0 -0
index d4bd68d..403914b 100644

net/ipv4/route.c static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr, · line 1709

Quoted 10 lines
net/ipv4/route.c +2 -4
@@ -1704,11 +1704,9 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
  	fl4.daddr = daddr;
  	fl4.saddr = saddr;
  	err = fib_lookup(net, &fl4, &res);
-	if (err != 0) {
-		if (!IN_DEV_FORWARD(in_dev))
-			err = -EHOSTUNREACH;
+	if (err != 0)
  		goto no_route;
-	}
+

This extra empty line is not needed.

net/ipv4/route.c static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr, · line 1712

Quoted 3 lines
net/ipv4/route.c +0 -0
  	if (res.type == RTN_BROADCAST)
  		goto brd_input;

WBR, Sergei

#2 lore raw
In reply to [email protected]

Hello,

Quoted 4 lines · On Mon, 29 Sep 2014, [email protected] wrote:

From: Li RongQing <[email protected]>

When the code skips to no_route label, it will skip to local_input at last, then err will be reset on the local_input path before exit function.

	But local_input saves -err into rth->dst.error,

the places you change provided more-specific error code.

Quoted 38 lines
---
 net/ipv4/route.c |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
net/ipv4/route.c +4 -7
index d4bd68d..403914b 100644
@@ -1704,11 +1704,9 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
 	fl4.daddr = daddr;
 	fl4.saddr = saddr;
 	err = fib_lookup(net, &fl4, &res);
-	if (err != 0) {
-		if (!IN_DEV_FORWARD(in_dev))
-			err = -EHOSTUNREACH;
+	if (err != 0)
 		goto no_route;
-	}
+
 
 	if (res.type == RTN_BROADCAST)
 		goto brd_input;
@@ -1721,10 +1719,9 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
 		goto local_input;
 	}
 
-	if (!IN_DEV_FORWARD(in_dev)) {
-		err = -EHOSTUNREACH;
+	if (!IN_DEV_FORWARD(in_dev))
 		goto no_route;
-	}
+
 	if (res.type != RTN_UNICAST)
 		goto martian_destination;
 
Signature · 1 line
1.7.10.4

Regards

--
Julian Anastasov <[email protected]>