mirror of
				https://git.proxmox.com/git/mirror_frr
				synced 2025-11-03 23:47:16 +00:00 
			
		
		
		
	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>
		
	
			
		
			
				
	
	
		
			97 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			97 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/*
 | 
						|
 * Static NHT code.
 | 
						|
 * Copyright (C) 2018 Cumulus Networks, Inc.
 | 
						|
 *               Donald Sharp
 | 
						|
 *
 | 
						|
 * This program is free software; you can redistribute it and/or modify it
 | 
						|
 * under the terms of the GNU General Public License as published by the Free
 | 
						|
 * Software Foundation; either version 2 of the License, or (at your option)
 | 
						|
 * any later version.
 | 
						|
 *
 | 
						|
 * This program is distributed in the hope that it will be useful, but WITHOUT
 | 
						|
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 | 
						|
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 | 
						|
 * more details.
 | 
						|
 *
 | 
						|
 * You should have received a copy of the GNU General Public License along
 | 
						|
 * with this program; see the file COPYING; if not, write to the Free Software
 | 
						|
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 | 
						|
 */
 | 
						|
#include <zebra.h>
 | 
						|
 | 
						|
#include "prefix.h"
 | 
						|
#include "table.h"
 | 
						|
#include "vrf.h"
 | 
						|
#include "nexthop.h"
 | 
						|
 | 
						|
#include "static_vrf.h"
 | 
						|
#include "static_routes.h"
 | 
						|
#include "static_zebra.h"
 | 
						|
#include "static_nht.h"
 | 
						|
 | 
						|
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;
 | 
						|
	bool orig;
 | 
						|
	bool reinstall;
 | 
						|
 | 
						|
	svrf = vrf->info;
 | 
						|
	if (!svrf)
 | 
						|
		return;
 | 
						|
 | 
						|
	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)
 | 
						|
				return;
 | 
						|
 | 
						|
			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;
 | 
						|
 | 
						|
			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 (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);
 | 
						|
	}
 | 
						|
}
 |