pim6d: Moving the common lines of pim_show_nexthop_lookup cli

Moving the common lines of pim_show_nexthop_lookup cli
in pim_cmd.c and pim6_cmd.c to pim_cmd_common.c file

Signed-off-by: Sai Gomathi N <nsaigomathi@vmware.com>
This commit is contained in:
Sai Gomathi N 2022-06-09 04:22:42 -07:00
parent cefa37cf41
commit fe7eaf4065
4 changed files with 58 additions and 74 deletions

View File

@ -1432,37 +1432,7 @@ DEFPY (show_ipv6_pim_nexthop_lookup,
"Source/RP address\n"
"Multicast Group address\n")
{
struct prefix nht_p;
int result = 0;
pim_addr vif_source;
struct prefix grp;
struct pim_nexthop nexthop;
struct vrf *v;
v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
if (!v)
return CMD_WARNING;
if (!pim_rp_set_upstream_addr(v->info, &vif_source, source, group))
return CMD_SUCCESS;
pim_addr_to_prefix(&nht_p, vif_source);
pim_addr_to_prefix(&grp, group);
memset(&nexthop, 0, sizeof(nexthop));
result = pim_ecmp_nexthop_lookup(v->info, &nexthop, &nht_p, &grp, 0);
if (!result) {
vty_out(vty,
"Nexthop Lookup failed, no usable routes returned.\n");
return CMD_SUCCESS;
}
vty_out(vty, "Group %s --- Nexthop %pPAs Interface %s\n", group_str,
&nexthop.mrib_nexthop_addr, nexthop.interface->name);
return CMD_SUCCESS;
return pim_show_nexthop_lookup_cmd_helper(vrf, vty, source, group);
}
DEFPY (show_ipv6_multicast,

View File

@ -3298,49 +3298,7 @@ DEFPY (show_ip_pim_nexthop_lookup,
"Source/RP address\n"
"Multicast Group address\n")
{
struct prefix nht_p;
int result = 0;
pim_addr vif_source;
struct prefix grp;
struct pim_nexthop nexthop;
struct vrf *v;
v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
if (!v)
return CMD_WARNING;
if (pim_is_group_224_4(source)) {
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");
return CMD_WARNING;
}
if (!pim_rp_set_upstream_addr(v->info, &vif_source, source, group))
return CMD_SUCCESS;
pim_addr_to_prefix(&nht_p, vif_source);
pim_addr_to_prefix(&grp, group);
memset(&nexthop, 0, sizeof(nexthop));
result = pim_ecmp_nexthop_lookup(v->info, &nexthop, &nht_p, &grp, 0);
if (!result) {
vty_out(vty,
"Nexthop Lookup failed, no usable routes returned.\n");
return CMD_SUCCESS;
}
vty_out(vty, "Group %s --- Nexthop %pPAs Interface %s \n", group_str,
&nexthop.mrib_nexthop_addr, nexthop.interface->name);
return CMD_SUCCESS;
return pim_show_nexthop_lookup_cmd_helper(vrf, vty, source, group);
}
DEFUN (show_ip_pim_interface_traffic,

View File

@ -55,6 +55,7 @@
#include "pim_static.h"
#include "pim_addr.h"
#include "pim_static.h"
#include "pim_util.h"
/**
* Get current node VRF name.
@ -2597,6 +2598,59 @@ static int pim_print_pnc_cache_walkcb(struct hash_bucket *bucket, void *arg)
return CMD_SUCCESS;
}
int pim_show_nexthop_lookup_cmd_helper(const char *vrf, struct vty *vty,
pim_addr source, pim_addr group)
{
struct prefix nht_p;
int result = 0;
pim_addr vif_source;
struct prefix grp;
struct pim_nexthop nexthop;
struct vrf *v;
char grp_str[PREFIX_STRLEN];
v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
if (!v)
return CMD_WARNING;
#if PIM_IPV == 4
if (pim_is_group_224_4(source)) {
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");
return CMD_WARNING;
}
#endif
if (!pim_rp_set_upstream_addr(v->info, &vif_source, source, group))
return CMD_SUCCESS;
pim_addr_to_prefix(&nht_p, vif_source);
pim_addr_to_prefix(&grp, group);
memset(&nexthop, 0, sizeof(nexthop));
result = pim_ecmp_nexthop_lookup(v->info, &nexthop, &nht_p, &grp, 0);
if (!result) {
vty_out(vty,
"Nexthop Lookup failed, no usable routes returned.\n");
return CMD_SUCCESS;
}
pim_addr_dump("<grp?>", &grp, grp_str, sizeof(grp_str));
vty_out(vty, "Group %s --- Nexthop %pPAs Interface %s\n", grp_str,
&nexthop.mrib_nexthop_addr, nexthop.interface->name);
return CMD_SUCCESS;
}
int pim_show_nexthop_cmd_helper(const char *vrf, struct vty *vty)
{
struct vrf *v;

View File

@ -102,6 +102,8 @@ void pim_show_interfaces_single(struct pim_instance *pim, struct vty *vty,
json_object *json);
void ip_pim_ssm_show_group_range(struct pim_instance *pim, struct vty *vty,
bool uj);
int pim_show_nexthop_lookup_cmd_helper(const char *vrf, struct vty *vty,
pim_addr source, pim_addr group);
int pim_show_nexthop_cmd_helper(const char *vrf, struct vty *vty);
void pim_show_nexthop(struct pim_instance *pim, struct vty *vty);
int pim_show_neighbors_cmd_helper(const char *vrf, struct vty *vty,