diff options
| author | David Lamparter <equinox@diac24.net> | 2010-02-05 04:31:56 +0100 | 
|---|---|---|
| committer | David Lamparter <equinox@opensourcerouting.org> | 2017-08-28 05:07:51 +0200 | 
| commit | a830942228110cbec0e857d0877d624206627f81 (patch) | |
| tree | 6823772eab9415dadaeb0722cd8c1114197fa8a1 /zebra/zebra_fpm_netlink.c | |
| parent | fd36be7e15ee49d12500a5ec4d9597d1597715a7 (diff) | |
zebra: cleanup blackhole support
blackhole support was horribly broken. cleanup by removing blackhole
stuff from ZEBRA_FLAG_*
introduces support for "prohibit" routes (Linux/netlink only)
also clean up blackhole options on "ip route" vty commands.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'zebra/zebra_fpm_netlink.c')
| -rw-r--r-- | zebra/zebra_fpm_netlink.c | 40 | 
1 files changed, 17 insertions, 23 deletions
diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c index 28f7956639..27c7891372 100644 --- a/zebra/zebra_fpm_netlink.c +++ b/zebra/zebra_fpm_netlink.c @@ -222,7 +222,6 @@ static int netlink_route_info_fill(netlink_route_info_t *ri, int cmd,  				   rib_dest_t *dest, struct route_entry *re)  {  	struct nexthop *nexthop; -	int discard;  	memset(ri, 0, sizeof(*ri)); @@ -247,30 +246,9 @@ static int netlink_route_info_fill(netlink_route_info_t *ri, int cmd,  	}  	ri->rtm_protocol = netlink_proto_from_route_type(re->type); - -	if ((re->flags & ZEBRA_FLAG_BLACKHOLE) -	    || (re->flags & ZEBRA_FLAG_REJECT)) -		discard = 1; -	else -		discard = 0; - -	if (cmd == RTM_NEWROUTE) { -		if (discard) { -			if (re->flags & ZEBRA_FLAG_BLACKHOLE) -				ri->rtm_type = RTN_BLACKHOLE; -			else if (re->flags & ZEBRA_FLAG_REJECT) -				ri->rtm_type = RTN_UNREACHABLE; -			else -				assert(0); -		} else -			ri->rtm_type = RTN_UNICAST; -	} - +	ri->rtm_type = RTN_UNICAST;  	ri->metric = &re->metric; -	if (discard) -		return 1; -  	for (ALL_NEXTHOPS(re->nexthop, nexthop)) {  		if (ri->num_nhs >= multipath_num)  			break; @@ -278,6 +256,22 @@ static int netlink_route_info_fill(netlink_route_info_t *ri, int cmd,  		if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_RECURSIVE))  			continue; +		if (nexthop->type == NEXTHOP_TYPE_BLACKHOLE) { +			switch (nexthop->bh_type) { +			case BLACKHOLE_ADMINPROHIB: +				ri->rtm_type = RTN_PROHIBIT; +				break; +			case BLACKHOLE_REJECT: +				ri->rtm_type = RTN_UNREACHABLE; +				break; +			case BLACKHOLE_NULL: +			default: +				ri->rtm_type = RTN_BLACKHOLE; +				break; +			} +			return 1; +		} +  		if ((cmd == RTM_NEWROUTE  		     && CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE))  		    || (cmd == RTM_DELROUTE  | 
