diff options
| author | Rafael Zalamena <rzalamena@users.noreply.github.com> | 2024-12-16 09:57:31 -0300 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-16 09:57:31 -0300 | 
| commit | 3bebb7be9204a51f194317438aa883f1b10c8646 (patch) | |
| tree | 6e4e508a35f6d03491661b25b645008d8ae7dd5a /zebra | |
| parent | 30467f8f2b3a671973aa4b0aa2bcc1e3a208cc56 (diff) | |
| parent | 06c3436a12226d1f7e18e549f562ba9ecde4b394 (diff) | |
Merge pull request #17252 from nabahr/mcast-mode
Fix PIMD RPF lookup mode and nexthop tracking
Diffstat (limited to 'zebra')
| -rw-r--r-- | zebra/rib.h | 6 | ||||
| -rw-r--r-- | zebra/zapi_msg.c | 36 | ||||
| -rw-r--r-- | zebra/zebra_nb.c | 6 | ||||
| -rw-r--r-- | zebra/zebra_nb_config.c | 17 | ||||
| -rw-r--r-- | zebra/zebra_rib.c | 61 | ||||
| -rw-r--r-- | zebra/zebra_router.c | 14 | ||||
| -rw-r--r-- | zebra/zebra_router.h | 18 | ||||
| -rw-r--r-- | zebra/zebra_vty.c | 396 | 
8 files changed, 165 insertions, 389 deletions
diff --git a/zebra/rib.h b/zebra/rib.h index 5fedb07335..8484fe1291 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -402,11 +402,7 @@ extern void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,  		       bool fromkernel);  extern struct route_entry *rib_match(afi_t afi, safi_t safi, vrf_id_t vrf_id, -				     const union g_addr *addr, -				     struct route_node **rn_out); -extern struct route_entry *rib_match_multicast(afi_t afi, vrf_id_t vrf_id, -					       union g_addr *gaddr, -					       struct route_node **rn_out); +				     const union g_addr *addr, struct route_node **rn_out);  extern void rib_update(enum rib_update_event event);  extern void rib_update_table(struct route_table *table, diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index d269cdd015..ab55998af0 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -640,10 +640,15 @@ int zsend_redistribute_route(int cmd, struct zserv *client,   * (Otherwise we would need to implement sending NHT updates for the result of   * this "URIB-MRIB-combined" table, but we only decide that here on the fly,   * so it'd be rather complex to do NHT for.) + * + * 9/19/24 NEB I've updated this API to include the SAFI in the lookup + * request and response. This allows PIM to do a syncronous lookup for the + * correct table along side NHT. + * This also makes this a more generic synchronous lookup not specifically + * tied to the mrib.   */ -static int zsend_nexthop_lookup_mrib(struct zserv *client, struct ipaddr *addr, -				     struct route_entry *re, -				     struct zebra_vrf *zvrf) +static int zsend_nexthop_lookup(struct zserv *client, struct ipaddr *addr, struct route_entry *re, +				struct route_node *rn, struct zebra_vrf *zvrf, safi_t safi)  {  	struct stream *s;  	unsigned long nump; @@ -655,14 +660,16 @@ static int zsend_nexthop_lookup_mrib(struct zserv *client, struct ipaddr *addr,  	stream_reset(s);  	/* Fill in result. */ -	zclient_create_header(s, ZEBRA_NEXTHOP_LOOKUP_MRIB, zvrf_id(zvrf)); +	zclient_create_header(s, ZEBRA_NEXTHOP_LOOKUP, zvrf_id(zvrf));  	stream_put_ipaddr(s, addr); -	if (re) { +	if (re && rn) {  		struct nexthop_group *nhg;  		stream_putc(s, re->distance);  		stream_putl(s, re->metric); +		stream_putw(s, rn->p.prefixlen); +  		num = 0;  		/* remember position for nexthop_num */  		nump = stream_get_endp(s); @@ -679,6 +686,7 @@ static int zsend_nexthop_lookup_mrib(struct zserv *client, struct ipaddr *addr,  	} else {  		stream_putc(s, 0); /* distance */  		stream_putl(s, 0); /* metric */ +		stream_putw(s, 0); /* prefix len */  		stream_putw(s, 0); /* nexthop_num */  	} @@ -2315,33 +2323,37 @@ static void zread_route_del(ZAPI_HANDLER_ARGS)  	}  } -/* MRIB Nexthop lookup for IPv4. */ -static void zread_nexthop_lookup_mrib(ZAPI_HANDLER_ARGS) +/* Syncronous Nexthop lookup. */ +static void zread_nexthop_lookup(ZAPI_HANDLER_ARGS)  {  	struct ipaddr addr;  	struct route_entry *re = NULL; +	struct route_node *rn = NULL;  	union g_addr gaddr; +	afi_t afi = AFI_IP; +	safi_t safi = SAFI_UNICAST;  	STREAM_GET_IPADDR(msg, &addr); +	STREAM_GETC(msg, safi);  	switch (addr.ipa_type) {  	case IPADDR_V4:  		gaddr.ipv4 = addr.ipaddr_v4; -		re = rib_match_multicast(AFI_IP, zvrf_id(zvrf), &gaddr, NULL); +		afi = AFI_IP;  		break;  	case IPADDR_V6:  		gaddr.ipv6 = addr.ipaddr_v6; -		re = rib_match_multicast(AFI_IP6, zvrf_id(zvrf), &gaddr, NULL); +		afi = AFI_IP6;  		break;  	case IPADDR_NONE:  		/* ??? */  		goto stream_failure;  	} -	zsend_nexthop_lookup_mrib(client, &addr, re, zvrf); +	re = rib_match(afi, safi, zvrf_id(zvrf), &gaddr, &rn);  stream_failure: -	return; +	zsend_nexthop_lookup(client, &addr, re, rn, zvrf, safi);  }  /* Register zebra server router-id information.  Send current router-id */ @@ -4027,7 +4039,7 @@ void (*const zserv_handlers[])(ZAPI_HANDLER_ARGS) = {  	[ZEBRA_REDISTRIBUTE_DELETE] = zebra_redistribute_delete,  	[ZEBRA_REDISTRIBUTE_DEFAULT_ADD] = zebra_redistribute_default_add,  	[ZEBRA_REDISTRIBUTE_DEFAULT_DELETE] = zebra_redistribute_default_delete, -	[ZEBRA_NEXTHOP_LOOKUP_MRIB] = zread_nexthop_lookup_mrib, +	[ZEBRA_NEXTHOP_LOOKUP] = zread_nexthop_lookup,  	[ZEBRA_HELLO] = zread_hello,  	[ZEBRA_NEXTHOP_REGISTER] = zread_rnh_register,  	[ZEBRA_NEXTHOP_UNREGISTER] = zread_rnh_unregister, diff --git a/zebra/zebra_nb.c b/zebra/zebra_nb.c index 0a7ed5db41..6b41993a95 100644 --- a/zebra/zebra_nb.c +++ b/zebra/zebra_nb.c @@ -26,12 +26,6 @@ const struct frr_yang_module_info frr_zebra_info = {  	.features = features,  	.nodes = {  		{ -			.xpath = "/frr-zebra:zebra/mcast-rpf-lookup", -			.cbs = { -				.modify = zebra_mcast_rpf_lookup_modify, -			} -		}, -		{  			.xpath = "/frr-zebra:zebra/ip-forwarding",  			.cbs = {  				.modify = zebra_ip_forwarding_modify, diff --git a/zebra/zebra_nb_config.c b/zebra/zebra_nb_config.c index 09c0091ec6..ec151360bd 100644 --- a/zebra/zebra_nb_config.c +++ b/zebra/zebra_nb_config.c @@ -31,23 +31,6 @@  #include "zebra/table_manager.h"  /* - * XPath: /frr-zebra:zebra/mcast-rpf-lookup - */ -int zebra_mcast_rpf_lookup_modify(struct nb_cb_modify_args *args) -{ -	switch (args->event) { -	case NB_EV_VALIDATE: -	case NB_EV_PREPARE: -	case NB_EV_ABORT: -	case NB_EV_APPLY: -		/* TODO: implement me. */ -		break; -	} - -	return NB_OK; -} - -/*   * XPath: /frr-zebra:zebra/ip-forwarding   */  int zebra_ip_forwarding_modify(struct nb_cb_modify_args *args) diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index e64a620f00..51458e4e84 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -503,7 +503,7 @@ struct route_entry *rib_match(afi_t afi, safi_t safi, vrf_id_t vrf_id,  	/* Lookup table.  */  	table = zebra_vrf_table(afi, safi, vrf_id);  	if (!table) -		return 0; +		return NULL;  	memset(&p, 0, sizeof(p));  	p.family = afi; @@ -552,65 +552,6 @@ struct route_entry *rib_match(afi_t afi, safi_t safi, vrf_id_t vrf_id,  	return NULL;  } -struct route_entry *rib_match_multicast(afi_t afi, vrf_id_t vrf_id, -					union g_addr *gaddr, -					struct route_node **rn_out) -{ -	struct route_entry *re = NULL, *mre = NULL, *ure = NULL; -	struct route_node *m_rn = NULL, *u_rn = NULL; - -	switch (zrouter.ipv4_multicast_mode) { -	case MCAST_MRIB_ONLY: -		return rib_match(afi, SAFI_MULTICAST, vrf_id, gaddr, rn_out); -	case MCAST_URIB_ONLY: -		return rib_match(afi, SAFI_UNICAST, vrf_id, gaddr, rn_out); -	case MCAST_NO_CONFIG: -	case MCAST_MIX_MRIB_FIRST: -		re = mre = rib_match(afi, SAFI_MULTICAST, vrf_id, gaddr, &m_rn); -		if (!mre) -			re = ure = rib_match(afi, SAFI_UNICAST, vrf_id, gaddr, -					     &u_rn); -		break; -	case MCAST_MIX_DISTANCE: -		mre = rib_match(afi, SAFI_MULTICAST, vrf_id, gaddr, &m_rn); -		ure = rib_match(afi, SAFI_UNICAST, vrf_id, gaddr, &u_rn); -		if (mre && ure) -			re = ure->distance < mre->distance ? ure : mre; -		else if (mre) -			re = mre; -		else if (ure) -			re = ure; -		break; -	case MCAST_MIX_PFXLEN: -		mre = rib_match(afi, SAFI_MULTICAST, vrf_id, gaddr, &m_rn); -		ure = rib_match(afi, SAFI_UNICAST, vrf_id, gaddr, &u_rn); -		if (mre && ure) -			re = u_rn->p.prefixlen > m_rn->p.prefixlen ? ure : mre; -		else if (mre) -			re = mre; -		else if (ure) -			re = ure; -		break; -	} - -	if (rn_out) -		*rn_out = (re == mre) ? m_rn : u_rn; - -	if (IS_ZEBRA_DEBUG_RIB) { -		char buf[BUFSIZ]; -		inet_ntop(afi == AFI_IP ? AF_INET : AF_INET6, gaddr, buf, -			  BUFSIZ); - -		zlog_debug("%s: %s: %pRN vrf: %s(%u) found %s, using %s", -			   __func__, buf, (re == mre) ? m_rn : u_rn, -			   vrf_id_to_name(vrf_id), vrf_id, -			   mre ? (ure ? "MRIB+URIB" : "MRIB") -			       : ure ? "URIB" : "nothing", -			   re == ure ? "URIB" : re == mre ? "MRIB" : "none"); -	} -	return re; -} -  /*   * Is this RIB labeled-unicast? It must be of type BGP and all paths   * (nexthops) must have a label. diff --git a/zebra/zebra_router.c b/zebra/zebra_router.c index 4022c1a26f..ae2910af41 100644 --- a/zebra/zebra_router.c +++ b/zebra/zebra_router.c @@ -23,7 +23,6 @@ DEFINE_MTYPE_STATIC(ZEBRA, ZEBRA_RT_TABLE, "Zebra VRF table");  struct zebra_router zrouter = {  	.multipath_num = MULTIPATH_NUM, -	.ipv4_multicast_mode = MCAST_NO_CONFIG,  };  static inline int @@ -221,19 +220,6 @@ uint32_t zebra_router_get_next_sequence(void)  					   memory_order_relaxed);  } -void multicast_mode_ipv4_set(enum multicast_mode mode) -{ -	if (IS_ZEBRA_DEBUG_RIB) -		zlog_debug("%s: multicast lookup mode set (%d)", __func__, -			   mode); -	zrouter.ipv4_multicast_mode = mode; -} - -enum multicast_mode multicast_mode_ipv4_get(void) -{ -	return zrouter.ipv4_multicast_mode; -} -  void zebra_router_terminate(void)  {  	struct zebra_router_table *zrt, *tmp; diff --git a/zebra/zebra_router.h b/zebra/zebra_router.h index a637c3214e..28c4cf0790 100644 --- a/zebra/zebra_router.h +++ b/zebra/zebra_router.h @@ -34,17 +34,6 @@ RB_HEAD(zebra_router_table_head, zebra_router_table);  RB_PROTOTYPE(zebra_router_table_head, zebra_router_table,  	     zebra_router_table_entry, zebra_router_table_entry_compare) -/* RPF lookup behaviour */ -enum multicast_mode { -	MCAST_NO_CONFIG = 0,  /* MIX_MRIB_FIRST, but no show in config write */ -	MCAST_MRIB_ONLY,      /* MRIB only */ -	MCAST_URIB_ONLY,      /* URIB only */ -	MCAST_MIX_MRIB_FIRST, /* MRIB, if nothing at all then URIB */ -	MCAST_MIX_DISTANCE,   /* MRIB & URIB, lower distance wins */ -	MCAST_MIX_PFXLEN,     /* MRIB & URIB, longer prefix wins */ -			      /* on equal value, MRIB wins for last 2 */ -}; -  /* An interface can be error-disabled if a protocol (such as EVPN or   * VRRP) detects a problem with keeping it operationally-up.   * If any of the protodown bits are set protodown-on is programmed @@ -187,9 +176,6 @@ struct zebra_router {  	uint32_t multipath_num; -	/* RPF Lookup behavior */ -	enum multicast_mode ipv4_multicast_mode; -  	/*  	 * zebra start time and time of sweeping RIB of old routes  	 */ @@ -287,10 +273,6 @@ static inline struct zebra_vrf *zebra_vrf_get_evpn(void)  			        : zebra_vrf_lookup_by_id(VRF_DEFAULT);  } -extern void multicast_mode_ipv4_set(enum multicast_mode mode); - -extern enum multicast_mode multicast_mode_ipv4_get(void); -  extern bool zebra_router_notify_on_ack(void);  static inline void zebra_router_set_supports_nhgs(bool support) diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index b65097e725..582d15627c 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -81,126 +81,14 @@ static void show_nexthop_detail_helper(struct vty *vty,  				       const struct nexthop *nexthop,  				       bool is_backup); -static void show_ip_route_dump_vty(struct vty *vty, struct route_table *table); +static void show_ip_route_dump_vty(struct vty *vty, struct route_table *table, afi_t afi, +				   safi_t safi);  static void show_ip_route_nht_dump(struct vty *vty,  				   const struct nexthop *nexthop,  				   const struct route_node *rn,  				   const struct route_entry *re,  				   unsigned int num); -DEFUN (ip_multicast_mode, -       ip_multicast_mode_cmd, -       "ip multicast rpf-lookup-mode <urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix>", -       IP_STR -       "Multicast options\n" -       "RPF lookup behavior\n" -       "Lookup in unicast RIB only\n" -       "Lookup in multicast RIB only\n" -       "Try multicast RIB first, fall back to unicast RIB\n" -       "Lookup both, use entry with lower distance\n" -       "Lookup both, use entry with longer prefix\n") -{ -	char *mode = argv[3]->text; - -	if (strmatch(mode, "urib-only")) -		multicast_mode_ipv4_set(MCAST_URIB_ONLY); -	else if (strmatch(mode, "mrib-only")) -		multicast_mode_ipv4_set(MCAST_MRIB_ONLY); -	else if (strmatch(mode, "mrib-then-urib")) -		multicast_mode_ipv4_set(MCAST_MIX_MRIB_FIRST); -	else if (strmatch(mode, "lower-distance")) -		multicast_mode_ipv4_set(MCAST_MIX_DISTANCE); -	else if (strmatch(mode, "longer-prefix")) -		multicast_mode_ipv4_set(MCAST_MIX_PFXLEN); -	else { -		vty_out(vty, "Invalid mode specified\n"); -		return CMD_WARNING_CONFIG_FAILED; -	} - -	return CMD_SUCCESS; -} - -DEFUN (no_ip_multicast_mode, -       no_ip_multicast_mode_cmd, -       "no ip multicast rpf-lookup-mode [<urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix>]", -       NO_STR -       IP_STR -       "Multicast options\n" -       "RPF lookup behavior\n" -       "Lookup in unicast RIB only\n" -       "Lookup in multicast RIB only\n" -       "Try multicast RIB first, fall back to unicast RIB\n" -       "Lookup both, use entry with lower distance\n" -       "Lookup both, use entry with longer prefix\n") -{ -	multicast_mode_ipv4_set(MCAST_NO_CONFIG); -	return CMD_SUCCESS; -} - - -DEFPY (show_ip_rpf, -       show_ip_rpf_cmd, -       "show [ip$ip|ipv6$ipv6] rpf [json]", -       SHOW_STR -       IP_STR -       IPV6_STR -       "Display RPF information for multicast source\n" -       JSON_STR) -{ -	bool uj = use_json(argc, argv); -	struct route_show_ctx ctx = { -		.multi = false, -	}; - -	return do_show_ip_route(vty, VRF_DEFAULT_NAME, ip ? AFI_IP : AFI_IP6, -				SAFI_MULTICAST, false, uj, 0, NULL, false, 0, 0, -				0, false, &ctx); -} - -DEFPY (show_ip_rpf_addr, -       show_ip_rpf_addr_cmd, -       "show ip rpf A.B.C.D$address", -       SHOW_STR -       IP_STR -       "Display RPF information for multicast source\n" -       "IP multicast source address (e.g. 10.0.0.0)\n") -{ -	struct route_node *rn; -	struct route_entry *re; - -	re = rib_match_multicast(AFI_IP, VRF_DEFAULT, (union g_addr *)&address, -				 &rn); - -	if (re) -		vty_show_ip_route_detail(vty, rn, 1, false, false); -	else -		vty_out(vty, "%% No match for RPF lookup\n"); - -	return CMD_SUCCESS; -} - -DEFPY (show_ipv6_rpf_addr, -       show_ipv6_rpf_addr_cmd, -       "show ipv6 rpf X:X::X:X$address", -       SHOW_STR -       IPV6_STR -       "Display RPF information for multicast source\n" -       "IPv6 multicast source address\n") -{ -	struct route_node *rn; -	struct route_entry *re; - -	re = rib_match_multicast(AFI_IP6, VRF_DEFAULT, (union g_addr *)&address, -				 &rn); - -	if (re) -		vty_show_ip_route_detail(vty, rn, 1, false, false); -	else -		vty_out(vty, "%% No match for RPF lookup\n"); - -	return CMD_SUCCESS; -} -  static char re_status_output_char(const struct route_entry *re,  				  const struct nexthop *nhop,  				  bool is_fib) @@ -858,35 +746,36 @@ static void vty_show_ip_route_detail_json(struct vty *vty,  	vty_json(vty, json);  } -static void zebra_vty_display_vrf_header(struct vty *vty, struct zebra_vrf *zvrf, uint32_t tableid) +static void zebra_vty_display_vrf_header(struct vty *vty, struct zebra_vrf *zvrf, uint32_t tableid, +					 afi_t afi, safi_t safi)  {  	if (!tableid) -		vty_out(vty, "VRF %s:\n", zvrf_name(zvrf)); +		vty_out(vty, "%s %s VRF %s:\n", afi2str(afi), safi2str(safi), zvrf_name(zvrf));  	else {  		if (vrf_is_backend_netns()) -			vty_out(vty, "VRF %s table %u:\n", zvrf_name(zvrf), tableid); +			vty_out(vty, "%s %s VRF %s table %u:\n", afi2str(afi), safi2str(safi), +				zvrf_name(zvrf), tableid);  		else {  			vrf_id_t vrf = zebra_vrf_lookup_by_table(tableid, zvrf->zns->ns_id);  			if (vrf == VRF_DEFAULT && tableid != RT_TABLE_ID_MAIN) -				vty_out(vty, "table %u:\n", tableid); +				vty_out(vty, "%s %s table %u:\n", afi2str(afi), safi2str(safi), +					tableid);  			else {  				struct zebra_vrf *zvrf2 = zebra_vrf_lookup_by_id(vrf); -				vty_out(vty, "VRF %s table %u:\n", zvrf_name(zvrf2), tableid); +				vty_out(vty, "%s %s VRF %s table %u:\n", afi2str(afi), +					safi2str(safi), zvrf_name(zvrf2), tableid);  			}  		}  	}  } -static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf, -				 struct route_table *table, afi_t afi, -				 bool use_fib, route_tag_t tag, -				 const struct prefix *longer_prefix_p, -				 bool supernets_only, int type, -				 unsigned short ospf_instance_id, bool use_json, -				 uint32_t tableid, bool show_ng, -				 struct route_show_ctx *ctx) +static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf, struct route_table *table, +				 afi_t afi, safi_t safi, bool use_fib, route_tag_t tag, +				 const struct prefix *longer_prefix_p, bool supernets_only, +				 int type, unsigned short ospf_instance_id, bool use_json, +				 uint32_t tableid, bool show_ng, struct route_show_ctx *ctx)  {  	struct route_node *rn;  	struct route_entry *re; @@ -958,9 +847,7 @@ static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf,  				}  				if (ctx->multi && ctx->header_done)  					vty_out(vty, "\n"); -				if (ctx->multi || zvrf_id(zvrf) != VRF_DEFAULT || tableid) -					zebra_vty_display_vrf_header(vty, zvrf, tableid); - +				zebra_vty_display_vrf_header(vty, zvrf, tableid, afi, safi);  				ctx->header_done = true;  				first = 0;  			} @@ -982,12 +869,10 @@ static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf,  		vty_json_close(vty, first_json);  } -static void do_show_ip_route_all(struct vty *vty, struct zebra_vrf *zvrf, -				 afi_t afi, bool use_fib, bool use_json, -				 route_tag_t tag, -				 const struct prefix *longer_prefix_p, -				 bool supernets_only, int type, -				 unsigned short ospf_instance_id, bool show_ng, +static void do_show_ip_route_all(struct vty *vty, struct zebra_vrf *zvrf, afi_t afi, safi_t safi, +				 bool use_fib, bool use_json, route_tag_t tag, +				 const struct prefix *longer_prefix_p, bool supernets_only, +				 int type, unsigned short ospf_instance_id, bool show_ng,  				 struct route_show_ctx *ctx)  {  	struct zebra_router_table *zrt; @@ -999,13 +884,11 @@ static void do_show_ip_route_all(struct vty *vty, struct zebra_vrf *zvrf,  		if (zvrf != info->zvrf)  			continue; -		if (zrt->afi != afi || -		    zrt->safi != SAFI_UNICAST) +		if (zrt->afi != afi || zrt->safi != safi)  			continue; -		do_show_ip_route(vty, zvrf_name(zvrf), afi, SAFI_UNICAST, -				 use_fib, use_json, tag, longer_prefix_p, -				 supernets_only, type, ospf_instance_id, +		do_show_ip_route(vty, zvrf_name(zvrf), afi, safi, use_fib, use_json, tag, +				 longer_prefix_p, supernets_only, type, ospf_instance_id,  				 zrt->tableid, show_ng, ctx);  	}  } @@ -1038,7 +921,7 @@ static int do_show_ip_route(struct vty *vty, const char *vrf_name, afi_t afi,  	}  	if (tableid) -		table = zebra_router_find_table(zvrf, tableid, afi, SAFI_UNICAST); +		table = zebra_router_find_table(zvrf, tableid, afi, safi);  	else  		table = zebra_vrf_table(afi, safi, zvrf_id(zvrf));  	if (!table) { @@ -1047,9 +930,9 @@ static int do_show_ip_route(struct vty *vty, const char *vrf_name, afi_t afi,  		return CMD_SUCCESS;  	} -	do_show_route_helper(vty, zvrf, table, afi, use_fib, tag, -			     longer_prefix_p, supernets_only, type, -			     ospf_instance_id, use_json, tableid, show_ng, ctx); +	do_show_route_helper(vty, zvrf, table, afi, safi, use_fib, tag, longer_prefix_p, +			     supernets_only, type, ospf_instance_id, use_json, tableid, show_ng, +			     ctx);  	return CMD_SUCCESS;  } @@ -1702,27 +1585,35 @@ DEFPY_HIDDEN(rnh_hide_backups, rnh_hide_backups_cmd,  DEFPY (show_route,         show_route_cmd,         "show\ -         <\ -	  ip$ipv4 <fib$fib|route> [table <(1-4294967295)$table|all$table_all>]\ -	  [vrf <NAME$vrf_name|all$vrf_all>]\ -	   [{\ -	    tag (1-4294967295)\ -	    |A.B.C.D/M$prefix longer-prefixes\ -	    |supernets-only$supernets_only\ -	   }]\ -	   [<\ -	    " FRR_IP_REDIST_STR_ZEBRA "$type_str\ -	    |ospf$type_str (1-65535)$ospf_instance_id\ -	   >]\ -          |ipv6$ipv6 <fib$fib|route> [table <(1-4294967295)$table|all$table_all>]\ -	  [vrf <NAME$vrf_name|all$vrf_all>]\ -	   [{\ -	    tag (1-4294967295)\ -	    |X:X::X:X/M$prefix longer-prefixes\ -	   }]\ -	   [" FRR_IP6_REDIST_STR_ZEBRA "$type_str]\ -	 >\ -        [<json$json|nexthop-group$ng>]", +        <\ +         ip$ipv4 <fib$fib|route>\ +          [{\ +           table <(1-4294967295)$table|all$table_all>\ +           |mrib$mrib\ +           |vrf <NAME$vrf_name|all$vrf_all>\ +          }]\ +          [{\ +           tag (1-4294967295)\ +           |A.B.C.D/M$prefix longer-prefixes\ +           |supernets-only$supernets_only\ +          }]\ +          [<\ +           " FRR_IP_REDIST_STR_ZEBRA "$type_str\ +           |ospf$type_str (1-65535)$ospf_instance_id\ +          >]\ +         |ipv6$ipv6 <fib$fib|route>\ +          [{\ +           table <(1-4294967295)$table|all$table_all>\ +           |mrib$mrib\ +           |vrf <NAME$vrf_name|all$vrf_all>\ +          }]\ +          [{\ +           tag (1-4294967295)\ +           |X:X::X:X/M$prefix longer-prefixes\ +          }]\ +          [" FRR_IP6_REDIST_STR_ZEBRA "$type_str]\ +        >\ +       [<json$json|nexthop-group$ng>]",         SHOW_STR         IP_STR         "IP forwarding table\n" @@ -1730,6 +1621,7 @@ DEFPY (show_route,         "Table to display\n"         "The table number to display\n"         "All tables\n" +       "Multicast SAFI table\n"         VRF_FULL_CMD_HELP_STR         "Show only routes with tag\n"         "Tag value\n" @@ -1745,6 +1637,7 @@ DEFPY (show_route,         "Table to display\n"         "The table number to display\n"         "All tables\n" +       "Multicast SAFI table\n"         VRF_FULL_CMD_HELP_STR         "Show only routes with tag\n"         "Tag value\n" @@ -1755,6 +1648,7 @@ DEFPY (show_route,         "Nexthop Group Information\n")  {  	afi_t afi = ipv4 ? AFI_IP : AFI_IP6; +	safi_t safi = mrib ? SAFI_MULTICAST : SAFI_UNICAST;  	bool first_vrf_json = true;  	struct vrf *vrf;  	int type = 0; @@ -1784,26 +1678,19 @@ DEFPY (show_route,  	if (vrf_all) {  		RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { -			if ((zvrf = vrf->info) == NULL -			    || (zvrf->table[afi][SAFI_UNICAST] == NULL)) +			if ((zvrf = vrf->info) == NULL || (zvrf->table[afi][safi] == NULL))  				continue;  			if (json)  				vty_json_key(vty, zvrf_name(zvrf),  					     &first_vrf_json);  			if (table_all) -				do_show_ip_route_all(vty, zvrf, afi, !!fib, -						     !!json, tag, -						     prefix_str ? prefix : NULL, -						     !!supernets_only, type, -						     ospf_instance_id, !!ng, -						     &ctx); +				do_show_ip_route_all(vty, zvrf, afi, safi, !!fib, !!json, tag, +						     prefix_str ? prefix : NULL, !!supernets_only, +						     type, ospf_instance_id, !!ng, &ctx);  			else -				do_show_ip_route(vty, zvrf_name(zvrf), afi, -						 SAFI_UNICAST, !!fib, !!json, -						 tag, prefix_str ? prefix : NULL, -						 !!supernets_only, type, -						 ospf_instance_id, table, !!ng, -						 &ctx); +				do_show_ip_route(vty, zvrf_name(zvrf), afi, safi, !!fib, !!json, +						 tag, prefix_str ? prefix : NULL, !!supernets_only, +						 type, ospf_instance_id, table, !!ng, &ctx);  		}  		if (json)  			vty_json_close(vty, first_vrf_json); @@ -1821,21 +1708,27 @@ DEFPY (show_route,  			return CMD_SUCCESS;  		if (table_all) -			do_show_ip_route_all(vty, zvrf, afi, !!fib, !!json, tag, -					     prefix_str ? prefix : NULL, -					     !!supernets_only, type, +			do_show_ip_route_all(vty, zvrf, afi, safi, !!fib, !!json, tag, +					     prefix_str ? prefix : NULL, !!supernets_only, type,  					     ospf_instance_id, !!ng, &ctx);  		else -			do_show_ip_route(vty, vrf->name, afi, SAFI_UNICAST, -					 !!fib, !!json, tag, -					 prefix_str ? prefix : NULL, -					 !!supernets_only, type, +			do_show_ip_route(vty, vrf->name, afi, safi, !!fib, !!json, tag, +					 prefix_str ? prefix : NULL, !!supernets_only, type,  					 ospf_instance_id, table, !!ng, &ctx);  	}  	return CMD_SUCCESS;  } +ALIAS_DEPRECATED (show_route, +                  show_ip_rpf_cmd, +                  "show <ip$ipv4|ipv6$ipv6> rpf$mrib [json$json]", +                  SHOW_STR +                  IP_STR +                  IPV6_STR +                  "Display RPF information for multicast source\n" +                  JSON_STR); +  ALIAS_HIDDEN (show_route,                show_ro_cmd,                "show <ip$ipv4|ipv6$ipv6> ro", @@ -1849,28 +1742,38 @@ DEFPY (show_route_detail,         show_route_detail_cmd,         "show\           <\ -          ip$ipv4 <fib$fib|route> [vrf <NAME$vrf_name|all$vrf_all>]\ -          <\ -	   A.B.C.D$address\ -	   |A.B.C.D/M$prefix\ -	  >\ -          |ipv6$ipv6 <fib$fib|route> [vrf <NAME$vrf_name|all$vrf_all>]\ -          <\ -	   X:X::X:X$address\ -	   |X:X::X:X/M$prefix\ -	  >\ -	 >\ -	 [json$json] [nexthop-group$ng]", +          ip$ipv4 <fib$fib|route>\ +           [{\ +            mrib$mrib\ +            |vrf <NAME$vrf_name|all$vrf_all>\ +           }]\ +           <\ +            A.B.C.D$address\ +            |A.B.C.D/M$prefix\ +           >\ +          |ipv6$ipv6 <fib$fib|route>\ +           [{\ +            mrib$mrib\ +            |vrf <NAME$vrf_name|all$vrf_all>\ +           }]\ +           <\ +            X:X::X:X$address\ +            |X:X::X:X/M$prefix\ +           >\ +         >\ +         [json$json] [nexthop-group$ng]",         SHOW_STR         IP_STR         "IP forwarding table\n"         "IP routing table\n" +       "Multicast SAFI table\n"         VRF_FULL_CMD_HELP_STR         "Network in the IP routing table to display\n"         "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"         IP6_STR         "IPv6 forwarding table\n"         "IPv6 routing table\n" +       "Multicast SAFI table\n"         VRF_FULL_CMD_HELP_STR         "IPv6 Address\n"         "IPv6 prefix\n" @@ -1878,6 +1781,7 @@ DEFPY (show_route_detail,         "Nexthop Group Information\n")  {  	afi_t afi = ipv4 ? AFI_IP : AFI_IP6; +	safi_t safi = mrib ? SAFI_MULTICAST : SAFI_UNICAST;  	struct route_table *table;  	struct prefix p;  	struct route_node *rn; @@ -1898,8 +1802,7 @@ DEFPY (show_route_detail,  		struct zebra_vrf *zvrf;  		RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { -			if ((zvrf = vrf->info) == NULL -			    || (table = zvrf->table[afi][SAFI_UNICAST]) == NULL) +			if ((zvrf = vrf->info) == NULL || (table = zvrf->table[afi][safi]) == NULL)  				continue;  			rn = route_node_match(table, &p); @@ -1920,7 +1823,7 @@ DEFPY (show_route_detail,  			if (json)  				vty_show_ip_route_detail_json(vty, rn, use_fib);  			else -				vty_show_ip_route_detail(vty, rn, 0, use_fib, +				vty_show_ip_route_detail(vty, rn, (safi == SAFI_MULTICAST), use_fib,  							 show_ng);  			route_unlock_node(rn); @@ -1945,7 +1848,7 @@ DEFPY (show_route_detail,  		if (vrf_name)  			VRF_GET_ID(vrf_id, vrf_name, false); -		table = zebra_vrf_table(afi, SAFI_UNICAST, vrf_id); +		table = zebra_vrf_table(afi, safi, vrf_id);  		if (!table)  			return CMD_SUCCESS; @@ -1973,7 +1876,8 @@ DEFPY (show_route_detail,  		if (json)  			vty_show_ip_route_detail_json(vty, rn, use_fib);  		else -			vty_show_ip_route_detail(vty, rn, 0, use_fib, show_ng); +			vty_show_ip_route_detail(vty, rn, (safi == SAFI_MULTICAST), use_fib, +						 show_ng);  		route_unlock_node(rn);  	} @@ -1983,12 +1887,13 @@ DEFPY (show_route_detail,  DEFPY (show_route_summary,         show_route_summary_cmd, -       "show <ip$ipv4|ipv6$ipv6> route [vrf <NAME$vrf_name|all$vrf_all>] \ +       "show <ip$ipv4|ipv6$ipv6> route [{mrib$mrib|vrf <NAME$vrf_name|all$vrf_all>}] \              summary [table (1-4294967295)$table_id] [prefix$prefix] [json]",         SHOW_STR         IP_STR         IP6_STR         "IP routing table\n" +       "Multicast SAFI table\n"         VRF_FULL_CMD_HELP_STR         "Summary of all routes\n"         "Table to display summary for\n" @@ -1997,6 +1902,7 @@ DEFPY (show_route_summary,         JSON_STR)  {  	afi_t afi = ipv4 ? AFI_IP : AFI_IP6; +	safi_t safi = mrib ? SAFI_MULTICAST : SAFI_UNICAST;  	struct route_table *table;  	bool uj = use_json(argc, argv);  	json_object *vrf_json = NULL; @@ -2013,12 +1919,11 @@ DEFPY (show_route_summary,  				continue;  			if (table_id == 0) -				table = zebra_vrf_table(afi, SAFI_UNICAST, -							zvrf->vrf->vrf_id); +				table = zebra_vrf_table(afi, safi, zvrf->vrf->vrf_id);  			else -				table = zebra_vrf_lookup_table_with_table_id( -					afi, SAFI_UNICAST, zvrf->vrf->vrf_id, -					table_id); +				table = zebra_vrf_lookup_table_with_table_id(afi, safi, +									     zvrf->vrf->vrf_id, +									     table_id);  			if (!table)  				continue; @@ -2040,10 +1945,9 @@ DEFPY (show_route_summary,  			VRF_GET_ID(vrf_id, vrf_name, false);  		if (table_id == 0) -			table = zebra_vrf_table(afi, SAFI_UNICAST, vrf_id); +			table = zebra_vrf_table(afi, safi, vrf_id);  		else -			table = zebra_vrf_lookup_table_with_table_id( -				afi, SAFI_UNICAST, vrf_id, table_id); +			table = zebra_vrf_lookup_table_with_table_id(afi, safi, vrf_id, table_id);  		if (!table)  			return CMD_SUCCESS; @@ -2056,50 +1960,49 @@ DEFPY (show_route_summary,  	return CMD_SUCCESS;  } -DEFUN_HIDDEN (show_route_zebra_dump, +DEFPY_HIDDEN (show_route_zebra_dump,                show_route_zebra_dump_cmd, -              "show <ip|ipv6> zebra route dump [vrf VRFNAME]", +              "show <ip$ipv4|ipv6$ipv6> zebra route dump [{mrib$mrib|vrf <NAME$vrf_name|all$vrf_all>}]",                SHOW_STR                IP_STR                IP6_STR                "Zebra daemon\n"                "Routing table\n"                "All information\n" -              VRF_CMD_HELP_STR) +              "Multicast SAFI table\n" +              VRF_FULL_CMD_HELP_STR)  { -	afi_t afi = AFI_IP; +	afi_t afi = ipv4 ? AFI_IP : AFI_IP6; +	safi_t safi = mrib ? SAFI_MULTICAST : SAFI_UNICAST;  	struct route_table *table; -	const char *vrf_name = NULL; -	int idx = 0; -	afi = strmatch(argv[1]->text, "ipv6") ? AFI_IP6 : AFI_IP; - -	if (argv_find(argv, argc, "vrf", &idx)) -		vrf_name = argv[++idx]->arg; - -	if (!vrf_name) { +	if (vrf_all) {  		struct vrf *vrf;  		struct zebra_vrf *zvrf;  		RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {  			zvrf = vrf->info; -			if ((zvrf == NULL) -			    || (zvrf->table[afi][SAFI_UNICAST] == NULL)) +			if (zvrf == NULL)  				continue; -			table = zvrf->table[afi][SAFI_UNICAST]; -			show_ip_route_dump_vty(vty, table); +			table = zebra_vrf_table(afi, safi, zvrf->vrf->vrf_id); +			if (!table) +				continue; + +			show_ip_route_dump_vty(vty, table, afi, safi);  		}  	} else {  		vrf_id_t vrf_id = VRF_DEFAULT; -		VRF_GET_ID(vrf_id, vrf_name, true); +		if (vrf_name) +			VRF_GET_ID(vrf_id, vrf_name, false); + +		table = zebra_vrf_table(afi, safi, vrf_id); -		table = zebra_vrf_table(afi, SAFI_UNICAST, vrf_id);  		if (!table)  			return CMD_SUCCESS; -		show_ip_route_dump_vty(vty, table); +		show_ip_route_dump_vty(vty, table, afi, safi);  	}  	return CMD_SUCCESS; @@ -2193,7 +2096,8 @@ static void show_ip_route_nht_dump(struct vty *vty,  	}  } -static void show_ip_route_dump_vty(struct vty *vty, struct route_table *table) +static void show_ip_route_dump_vty(struct vty *vty, struct route_table *table, afi_t afi, +				   safi_t safi)  {  	struct route_node *rn;  	struct route_entry *re; @@ -2205,7 +2109,7 @@ static void show_ip_route_dump_vty(struct vty *vty, struct route_table *table)  	struct nexthop *nexthop = NULL;  	int nexthop_num = 0; -	vty_out(vty, "\nIPv4/IPv6 Routing table dump\n"); +	vty_out(vty, "\n%s %s Routing table dump\n", afi2str(afi), safi2str(safi));  	vty_out(vty, "----------------------------\n");  	for (rn = route_top(table); rn; rn = route_next(rn)) { @@ -3757,22 +3661,6 @@ static int config_write_protocol(struct vty *vty)  		vty_out(vty, "zebra zapi-packets %u\n",  			zrouter.packets_to_process); -	enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get(); - -	if (ipv4_multicast_mode != MCAST_NO_CONFIG) -		vty_out(vty, "ip multicast rpf-lookup-mode %s\n", -			ipv4_multicast_mode == MCAST_URIB_ONLY -				? "urib-only" -				: ipv4_multicast_mode == MCAST_MRIB_ONLY -					  ? "mrib-only" -					  : ipv4_multicast_mode -							    == MCAST_MIX_MRIB_FIRST -						    ? "mrib-then-urib" -						    : ipv4_multicast_mode -								      == MCAST_MIX_DISTANCE -							      ? "lower-distance" -							      : "longer-prefix"); -  	/* Include dataplane info */  	dplane_config_write_helper(vty); @@ -4356,9 +4244,6 @@ void zebra_vty_init(void)  	install_element(CONFIG_NODE, &allow_external_route_update_cmd);  	install_element(CONFIG_NODE, &no_allow_external_route_update_cmd); -	install_element(CONFIG_NODE, &ip_multicast_mode_cmd); -	install_element(CONFIG_NODE, &no_ip_multicast_mode_cmd); -  	install_element(CONFIG_NODE, &zebra_nexthop_group_keep_cmd);  	install_element(CONFIG_NODE, &ip_zebra_import_table_distance_cmd);  	install_element(CONFIG_NODE, &no_ip_zebra_import_table_cmd); @@ -4376,15 +4261,12 @@ void zebra_vty_init(void)  	install_element(VIEW_NODE, &show_vrf_cmd);  	install_element(VIEW_NODE, &show_vrf_vni_cmd);  	install_element(VIEW_NODE, &show_route_cmd); +	install_element(VIEW_NODE, &show_ip_rpf_cmd);  	install_element(VIEW_NODE, &show_ro_cmd);  	install_element(VIEW_NODE, &show_route_detail_cmd);  	install_element(VIEW_NODE, &show_route_summary_cmd);  	install_element(VIEW_NODE, &show_ip_nht_cmd); -	install_element(VIEW_NODE, &show_ip_rpf_cmd); -	install_element(VIEW_NODE, &show_ip_rpf_addr_cmd); -	install_element(VIEW_NODE, &show_ipv6_rpf_addr_cmd); -  	install_element(CONFIG_NODE, &rnh_hide_backups_cmd);  	install_element(VIEW_NODE, &show_frr_cmd);  | 
