forked from Mirror/frr
lib: Allow nexthop simple display to take an alternate ifp name
The nexthop_group_write_nexthop_simple function outputs the interface name, because we've stored the ifindex. The problem is that there are ephermeal interfaces in linux that can be destroyed/recreated. Allow us to keep that data and do something a bit smarter to allow show run's and other show commands to continue to work when the interface is deleted. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
fcf29c6919
commit
a251884bff
|
@ -953,22 +953,28 @@ static struct cmd_node nexthop_group_node = {
|
||||||
};
|
};
|
||||||
|
|
||||||
void nexthop_group_write_nexthop_simple(struct vty *vty,
|
void nexthop_group_write_nexthop_simple(struct vty *vty,
|
||||||
const struct nexthop *nh)
|
const struct nexthop *nh,
|
||||||
|
char *altifname)
|
||||||
{
|
{
|
||||||
char buf[100];
|
char buf[100];
|
||||||
|
char *ifname;
|
||||||
|
|
||||||
vty_out(vty, "nexthop ");
|
vty_out(vty, "nexthop ");
|
||||||
|
|
||||||
|
if (altifname)
|
||||||
|
ifname = altifname;
|
||||||
|
else
|
||||||
|
ifname = (char *)ifindex2ifname(nh->ifindex, nh->vrf_id);
|
||||||
|
|
||||||
switch (nh->type) {
|
switch (nh->type) {
|
||||||
case NEXTHOP_TYPE_IFINDEX:
|
case NEXTHOP_TYPE_IFINDEX:
|
||||||
vty_out(vty, "%s", ifindex2ifname(nh->ifindex, nh->vrf_id));
|
vty_out(vty, "%s", ifname);
|
||||||
break;
|
break;
|
||||||
case NEXTHOP_TYPE_IPV4:
|
case NEXTHOP_TYPE_IPV4:
|
||||||
vty_out(vty, "%s", inet_ntoa(nh->gate.ipv4));
|
vty_out(vty, "%s", inet_ntoa(nh->gate.ipv4));
|
||||||
break;
|
break;
|
||||||
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
||||||
vty_out(vty, "%s %s", inet_ntoa(nh->gate.ipv4),
|
vty_out(vty, "%s %s", inet_ntoa(nh->gate.ipv4), ifname);
|
||||||
ifindex2ifname(nh->ifindex, nh->vrf_id));
|
|
||||||
break;
|
break;
|
||||||
case NEXTHOP_TYPE_IPV6:
|
case NEXTHOP_TYPE_IPV6:
|
||||||
vty_out(vty, "%s",
|
vty_out(vty, "%s",
|
||||||
|
@ -977,7 +983,7 @@ void nexthop_group_write_nexthop_simple(struct vty *vty,
|
||||||
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
||||||
vty_out(vty, "%s %s",
|
vty_out(vty, "%s %s",
|
||||||
inet_ntop(AF_INET6, &nh->gate.ipv6, buf, sizeof(buf)),
|
inet_ntop(AF_INET6, &nh->gate.ipv6, buf, sizeof(buf)),
|
||||||
ifindex2ifname(nh->ifindex, nh->vrf_id));
|
ifname);
|
||||||
break;
|
break;
|
||||||
case NEXTHOP_TYPE_BLACKHOLE:
|
case NEXTHOP_TYPE_BLACKHOLE:
|
||||||
break;
|
break;
|
||||||
|
@ -989,7 +995,7 @@ void nexthop_group_write_nexthop(struct vty *vty, const struct nexthop *nh)
|
||||||
struct vrf *vrf;
|
struct vrf *vrf;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
nexthop_group_write_nexthop_simple(vty, nh);
|
nexthop_group_write_nexthop_simple(vty, nh, NULL);
|
||||||
|
|
||||||
if (nh->vrf_id != VRF_DEFAULT) {
|
if (nh->vrf_id != VRF_DEFAULT) {
|
||||||
vrf = vrf_lookup_by_id(nh->vrf_id);
|
vrf = vrf_lookup_by_id(nh->vrf_id);
|
||||||
|
|
|
@ -136,7 +136,8 @@ extern bool nexthop_group_equal(const struct nexthop_group *nhg1,
|
||||||
extern struct nexthop_group_cmd *nhgc_find(const char *name);
|
extern struct nexthop_group_cmd *nhgc_find(const char *name);
|
||||||
|
|
||||||
extern void nexthop_group_write_nexthop_simple(struct vty *vty,
|
extern void nexthop_group_write_nexthop_simple(struct vty *vty,
|
||||||
const struct nexthop *nh);
|
const struct nexthop *nh,
|
||||||
|
char *altifname);
|
||||||
extern void nexthop_group_write_nexthop(struct vty *vty,
|
extern void nexthop_group_write_nexthop(struct vty *vty,
|
||||||
const struct nexthop *nh);
|
const struct nexthop *nh);
|
||||||
|
|
||||||
|
|
|
@ -627,7 +627,7 @@ pbrms_nexthop_group_write_individual_nexthop(
|
||||||
struct pbr_nexthop_cache lookup;
|
struct pbr_nexthop_cache lookup;
|
||||||
struct pbr_nexthop_cache *pnhc;
|
struct pbr_nexthop_cache *pnhc;
|
||||||
|
|
||||||
nexthop_group_write_nexthop_simple(vty, pbrms->nhg->nexthop);
|
nexthop_group_write_nexthop_simple(vty, pbrms->nhg->nexthop, NULL);
|
||||||
|
|
||||||
memset(&find, 0, sizeof(find));
|
memset(&find, 0, sizeof(find));
|
||||||
strlcpy(find.name, pbrms->internal_nhg_name, sizeof(find.name));
|
strlcpy(find.name, pbrms->internal_nhg_name, sizeof(find.name));
|
||||||
|
|
Loading…
Reference in a new issue