Skip to content

Commit

Permalink
pimd: Update show ip pim nexthop-lookup... command
Browse files Browse the repository at this point in the history
Allow group to be optional in the command. Only validate group if
source is ANY. Documented setting source via RP if not provided.
Added new output if ANY source + group lookup is performed and no
RP is found for the group. Updated output to include souce and
group for lookup.

Signed-off-by: Nathan Bahr <nbahr@atcorp.com>
  • Loading branch information
nabahr committed Oct 27, 2024
1 parent ae80c7e commit f34c67b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pimd/pim_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2930,7 +2930,7 @@ DEFPY (show_ip_pim_nexthop,

DEFPY (show_ip_pim_nexthop_lookup,
show_ip_pim_nexthop_lookup_cmd,
"show ip pim [vrf NAME] nexthop-lookup A.B.C.D$source A.B.C.D$group",
"show ip pim [vrf NAME] nexthop-lookup A.B.C.D$source [A.B.C.D$group]",
SHOW_STR
IP_STR
PIM_STR
Expand Down
25 changes: 15 additions & 10 deletions pimd/pim_cmd_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2989,31 +2989,36 @@ int pim_show_nexthop_lookup_cmd_helper(const char *vrf, struct vty *vty,

#if PIM_IPV == 4
if (pim_is_group_224_4(source)) {
vty_out(vty,
"Invalid argument. Expected Valid Source Address.\n");
vty_out(vty, "Invalid argument. Expected Valid Source Address.\n");
return CMD_WARNING;
}

if (!pim_is_group_224_4(group)) {
vty_out(vty,
"Invalid argument. Expected Valid Multicast Group Address.\n");
/* Only require group if source is not provided */
if (pim_addr_is_any(source) && !pim_is_group_224_4(group)) {
vty_out(vty, "Invalid argument. Expected Valid Multicast Group Address.\n");
return CMD_WARNING;
}
#endif

if (!pim_rp_set_upstream_addr(v->info, &vif_source, source, group))
/* This call will set vif_source=source, if source is not ANY. Otherwise vif_source
* will be set to the RP address according to the group address. If no RP is configured
* for the group, then return 0 and set vif_source to ANY
*/
if (!pim_rp_set_upstream_addr(v->info, &vif_source, source, group)) {
vty_out(vty, "(%pPAs, %pPA) --- Nexthop Lookup failed, no RP.\n", &source, &group);
return CMD_SUCCESS;
}


pim_addr_to_prefix(&grp, group);
memset(&nexthop, 0, sizeof(nexthop));

if (!pim_nht_lookup_ecmp(v->info, &nexthop, vif_source, &grp, false)) {
vty_out(vty,
"Nexthop Lookup failed, no usable routes returned.\n");
vty_out(vty, "(%pPAs, %pPA) --- Nexthop Lookup failed, no usable routes returned.\n",
&source, &group);
return CMD_SUCCESS;
}

vty_out(vty, "Group %pFXh --- Nexthop %pPAs Interface %s\n", &grp,
vty_out(vty, "(%pPAs, %pPA) --- Nexthop %pPAs Interface %s\n", &source, &group,
&nexthop.mrib_nexthop_addr, nexthop.interface->name);

return CMD_SUCCESS;
Expand Down

0 comments on commit f34c67b

Please sign in to comment.