diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2019-01-04 09:42:11 -0500 | 
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2019-01-04 09:48:10 -0500 | 
| commit | c45fb58dd310ba05ca9e1f2da05b37f79b7aa16c (patch) | |
| tree | f54afbc9368dca2e330ab1f19fae00b808c7cffa /staticd | |
| parent | ea66cec4882d8e3c53cbe9465cb4313c667e87bf (diff) | |
staticd: Fix nht to include SAFI_MULTICAST
The nexthop tracking was correctly registering the nexthops in
the SAFI_UNICAST table, but we need to apply them to the
SAFI_MULTICAST mroute information( if any ) as well.
donna.cumulusnetworks.com# conf t
donna.cumulusnetworks.com(config)# ip mroute 230.0.4.0/24 192.168.210.50
donna.cumulusnetworks.com(config)# end
donna.cumulusnetworks.com# show ip rpf
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route
C>* 10.0.2.0/24 is directly connected, enp0s3, 00:08:28
C>* 192.168.209.0/24 is directly connected, enp0s8, 00:08:28
C>* 192.168.210.0/24 is directly connected, enp0s9, 00:08:28
S>* 230.0.4.0/24 [1/0] via 192.168.210.50, enp0s9, 00:07:56
S>* 230.0.5.0/24 [1/0] via 192.168.210.50, enp0s9, 00:07:17
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'staticd')
| -rw-r--r-- | staticd/static_nht.c | 83 | 
1 files changed, 46 insertions, 37 deletions
diff --git a/staticd/static_nht.c b/staticd/static_nht.c index 44f7fb79da..38fd53a1f2 100644 --- a/staticd/static_nht.c +++ b/staticd/static_nht.c @@ -29,59 +29,68 @@  #include "static_zebra.h"  #include "static_nht.h" -void static_nht_update(struct prefix *p, uint32_t nh_num, afi_t afi, -		       vrf_id_t nh_vrf_id) +static void static_nht_update_safi(struct prefix *p, uint32_t nh_num, +				   afi_t afi, safi_t safi, struct vrf *vrf, +				   vrf_id_t nh_vrf_id)  {  	struct route_table *stable;  	struct static_route *si;  	struct static_vrf *svrf;  	struct route_node *rn; -	struct vrf *vrf;  	bool orig;  	bool reinstall; -	RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { -		svrf = vrf->info; -		if (!svrf) -			continue; +	svrf = vrf->info; +	if (!svrf) +		return; -		stable = static_vrf_static_table(afi, SAFI_UNICAST, svrf); -		if (!stable) -			continue; +	stable = static_vrf_static_table(afi, safi, svrf); +	if (!stable) +		return; -		for (rn = route_top(stable); rn; rn = route_next(rn)) { -			reinstall = false; -			for (si = rn->info; si; si = si->next) { -				if (si->nh_vrf_id != nh_vrf_id) -					continue; +	for (rn = route_top(stable); rn; rn = route_next(rn)) { +		reinstall = false; +		for (si = rn->info; si; si = si->next) { +			if (si->nh_vrf_id != nh_vrf_id) +				return; -				if (si->type != STATIC_IPV4_GATEWAY -				    && si->type != STATIC_IPV4_GATEWAY_IFNAME -				    && si->type != STATIC_IPV6_GATEWAY -				    && si->type != STATIC_IPV6_GATEWAY_IFNAME) -					continue; +			if (si->type != STATIC_IPV4_GATEWAY +			    && si->type != STATIC_IPV4_GATEWAY_IFNAME +			    && si->type != STATIC_IPV6_GATEWAY +			    && si->type != STATIC_IPV6_GATEWAY_IFNAME) +				return; -				orig = si->nh_valid; -				if (p->family == AF_INET -				    && p->u.prefix4.s_addr -					       == si->addr.ipv4.s_addr) -					si->nh_valid = !!nh_num; +			orig = si->nh_valid; +			if (p->family == AF_INET +			    && p->u.prefix4.s_addr == si->addr.ipv4.s_addr) +				si->nh_valid = !!nh_num; -				if (p->family == AF_INET6 -				    && memcmp(&p->u.prefix6, &si->addr.ipv6, 16) -					       == 0) -					si->nh_valid = !!nh_num; +			if (p->family == AF_INET6 +			    && memcmp(&p->u.prefix6, &si->addr.ipv6, 16) == 0) +				si->nh_valid = !!nh_num; -				if (orig != si->nh_valid) -					reinstall = true; +			if (orig != si->nh_valid) +				reinstall = true; -				if (reinstall) { -					static_zebra_route_add( -						rn, si, vrf->vrf_id, -						SAFI_UNICAST, true); -					reinstall = false; -				} +			if (reinstall) { +				static_zebra_route_add(rn, si, vrf->vrf_id, +						       safi, true); +				reinstall = false;  			}  		}  	}  } + +void static_nht_update(struct prefix *p, uint32_t nh_num, afi_t afi, +		       vrf_id_t nh_vrf_id) +{ + +	struct vrf *vrf; + +	RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { +		static_nht_update_safi(p, nh_num, afi, SAFI_UNICAST, +				       vrf, nh_vrf_id); +		static_nht_update_safi(p, nh_num, afi, SAFI_MULTICAST, +				       vrf, nh_vrf_id); +	} +}  | 
