[Patch v2] IPv6: Fixed support for blackhole and prohibit routes

Subsystems: networking [general], networking [ipv4/ipv6], the rest

STALE4633d

3 messages, 2 authors, 2013-11-28 · open the first message on its own page

[Patch v2] IPv6: Fixed support for blackhole and prohibit routes

From: Kamala R <hidden>
Date: 2013-11-22 08:22:19

From: Kamala R <redacted>

The behaviour of blackhole and prohibit routes has been corrected by setting
the input and output function pointers of the dst variable appropriately. For
blackhole routes, they are set to dst_discard and to ip6_pkt_prohibit and
ip6_pkt_prohbit_out respectively for prohibit routes.

Changes from v1: Logic is the same. Changes made for readability and so it
looks pleasing.

Signed-off-by: Kamala R <redacted>
---
 net/ipv6/route.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index f54e3a1..d90b9ab 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1564,21 +1564,24 @@ int ip6_route_add(struct fib6_config *cfg)
 				goto out;
 			}
 		}
-		rt->dst.output = ip6_pkt_discard_out;
-		rt->dst.input = ip6_pkt_discard;
 		rt->rt6i_flags = RTF_REJECT|RTF_NONEXTHOP;
+		rt->dst.error = -ENETUNREACH;
 		switch (cfg->fc_type) {
 		case RTN_BLACKHOLE:
 			rt->dst.error = -EINVAL;
+			rt->dst.output = dst_discard;
+			rt->dst.input = dst_discard;
 			break;
 		case RTN_PROHIBIT:
 			rt->dst.error = -EACCES;
+			rt->dst.output = ip6_pkt_prohibit_out;
+			rt->dst.input = ip6_pkt_prohibit;
 			break;
 		case RTN_THROW:
 			rt->dst.error = -EAGAIN;
-			break;
 		default:
-			rt->dst.error = -ENETUNREACH;
+			rt->dst.output = ip6_pkt_discard_out;
+			rt->dst.input = ip6_pkt_discard;
 			break;
 		}
 		goto install_route;
-- 
1.7.9.5

Re: [Patch v2] IPv6: Fixed support for blackhole and prohibit routes

From: Hannes Frederic Sowa <hidden>
Date: 2013-11-23 22:41:19

On Fri, Nov 22, 2013 at 01:51:28PM +0530, Kamala R wrote:
quoted hunk
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index f54e3a1..d90b9ab 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1564,21 +1564,24 @@ int ip6_route_add(struct fib6_config *cfg)
 				goto out;
 			}
 		}
-		rt->dst.output = ip6_pkt_discard_out;
-		rt->dst.input = ip6_pkt_discard;
 		rt->rt6i_flags = RTF_REJECT|RTF_NONEXTHOP;
+		rt->dst.error = -ENETUNREACH;
 		switch (cfg->fc_type) {
 		case RTN_BLACKHOLE:
 			rt->dst.error = -EINVAL;
+			rt->dst.output = dst_discard;
+			rt->dst.input = dst_discard;
 			break;
 		case RTN_PROHIBIT:
 			rt->dst.error = -EACCES;
+			rt->dst.output = ip6_pkt_prohibit_out;
+			rt->dst.input = ip6_pkt_prohibit;
 			break;
 		case RTN_THROW:
 			rt->dst.error = -EAGAIN;
-			break;
 		default:
-			rt->dst.error = -ENETUNREACH;
+			rt->dst.output = ip6_pkt_discard_out;
+			rt->dst.input = ip6_pkt_discard;
 			break;
 		}
 		goto install_route;
I like it more if a variable is only assigned once. Otherwise it is fine by
me. 

Re: [Patch v2] IPv6: Fixed support for blackhole and prohibit routes

From: Hannes Frederic Sowa <hidden>
Date: 2013-11-28 18:50:29

On Fri, Nov 22, 2013 at 01:51:28PM +0530, Kamala R wrote:
From: Kamala R <redacted>

The behaviour of blackhole and prohibit routes has been corrected by setting
the input and output function pointers of the dst variable appropriately. For
blackhole routes, they are set to dst_discard and to ip6_pkt_prohibit and
ip6_pkt_prohbit_out respectively for prohibit routes.

Changes from v1: Logic is the same. Changes made for readability and so it
looks pleasing.
David, fyi a third version of this patch has been posted.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help