summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/if.c2
-rw-r--r--lib/if.h2
-rw-r--r--lib/nexthop_group.c34
-rw-r--r--lib/nexthop_group.h3
-rw-r--r--lib/zclient.c2
5 files changed, 35 insertions, 8 deletions
diff --git a/lib/if.c b/lib/if.c
index d8392708e1..10db574dc4 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -188,7 +188,9 @@ void if_destroy_via_zapi(struct interface *ifp)
if (ifp_master.destroy_hook)
(*ifp_master.destroy_hook)(ifp);
+ ifp->oldifindex = ifp->ifindex;
if_set_index(ifp, IFINDEX_INTERNAL);
+
if (!ifp->configured)
if_delete(&ifp);
}
diff --git a/lib/if.h b/lib/if.h
index 1fb0757db2..a2a40d0957 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -224,6 +224,8 @@ struct interface {
not work as expected.
*/
ifindex_t ifindex;
+ ifindex_t oldifindex;
+
/*
* ifindex of parent interface, if any
*/
diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c
index 8ae001e42a..687cac4062 100644
--- a/lib/nexthop_group.c
+++ b/lib/nexthop_group.c
@@ -940,6 +940,12 @@ DEFPY(ecmp_nexthops, ecmp_nexthops_cmd,
nhg_hooks.add_nexthop(nhgc, nh);
}
+ if (intf) {
+ struct interface *ifp = if_lookup_by_name_all_vrf(intf);
+
+ if (ifp)
+ ifp->configured = true;
+ }
return CMD_SUCCESS;
}
@@ -952,24 +958,29 @@ static struct cmd_node nexthop_group_node = {
.config_write = nexthop_group_write,
};
-void nexthop_group_write_nexthop(struct vty *vty, const struct nexthop *nh)
+void nexthop_group_write_nexthop_simple(struct vty *vty,
+ const struct nexthop *nh,
+ char *altifname)
{
char buf[100];
- struct vrf *vrf;
- int i;
+ char *ifname;
vty_out(vty, "nexthop ");
+ if (altifname)
+ ifname = altifname;
+ else
+ ifname = (char *)ifindex2ifname(nh->ifindex, nh->vrf_id);
+
switch (nh->type) {
case NEXTHOP_TYPE_IFINDEX:
- vty_out(vty, "%s", ifindex2ifname(nh->ifindex, nh->vrf_id));
+ vty_out(vty, "%s", ifname);
break;
case NEXTHOP_TYPE_IPV4:
vty_out(vty, "%s", inet_ntoa(nh->gate.ipv4));
break;
case NEXTHOP_TYPE_IPV4_IFINDEX:
- vty_out(vty, "%s %s", inet_ntoa(nh->gate.ipv4),
- ifindex2ifname(nh->ifindex, nh->vrf_id));
+ vty_out(vty, "%s %s", inet_ntoa(nh->gate.ipv4), ifname);
break;
case NEXTHOP_TYPE_IPV6:
vty_out(vty, "%s",
@@ -978,11 +989,19 @@ void nexthop_group_write_nexthop(struct vty *vty, const struct nexthop *nh)
case NEXTHOP_TYPE_IPV6_IFINDEX:
vty_out(vty, "%s %s",
inet_ntop(AF_INET6, &nh->gate.ipv6, buf, sizeof(buf)),
- ifindex2ifname(nh->ifindex, nh->vrf_id));
+ ifname);
break;
case NEXTHOP_TYPE_BLACKHOLE:
break;
}
+}
+
+void nexthop_group_write_nexthop(struct vty *vty, const struct nexthop *nh)
+{
+ struct vrf *vrf;
+ int i;
+
+ nexthop_group_write_nexthop_simple(vty, nh, NULL);
if (nh->vrf_id != VRF_DEFAULT) {
vrf = vrf_lookup_by_id(nh->vrf_id);
@@ -1229,6 +1248,7 @@ void nexthop_group_interface_state_change(struct interface *ifp,
if (ifp->ifindex != nhop.ifindex)
continue;
+ ifp->configured = true;
nh = nexthop_new();
memcpy(nh, &nhop, sizeof(nhop));
diff --git a/lib/nexthop_group.h b/lib/nexthop_group.h
index 0b5ac91bb2..5f7bde0def 100644
--- a/lib/nexthop_group.h
+++ b/lib/nexthop_group.h
@@ -135,6 +135,9 @@ extern bool nexthop_group_equal(const struct nexthop_group *nhg1,
extern struct nexthop_group_cmd *nhgc_find(const char *name);
+extern void nexthop_group_write_nexthop_simple(struct vty *vty,
+ const struct nexthop *nh,
+ char *altifname);
extern void nexthop_group_write_nexthop(struct vty *vty,
const struct nexthop *nh);
diff --git a/lib/zclient.c b/lib/zclient.c
index 6b5f3e349a..b842e7c31b 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -2068,7 +2068,7 @@ static void zebra_interface_if_set_value(struct stream *s,
uint8_t link_params_status = 0;
ifindex_t old_ifindex, new_ifindex;
- old_ifindex = ifp->ifindex;
+ old_ifindex = ifp->oldifindex;
/* Read interface's index. */
STREAM_GETL(s, new_ifindex);
if_set_index(ifp, new_ifindex);