summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_mplsvpn.c10
-rw-r--r--bgpd/bgp_route.c6
-rw-r--r--bgpd/bgp_routemap.c11
-rw-r--r--bgpd/rfapi/rfapi.c4
-rw-r--r--bgpd/rfapi/vnc_export_bgp.c8
-rw-r--r--ldpd/l2vpn.c8
-rw-r--r--ldpd/lde.c15
-rw-r--r--ldpd/lde.h9
-rw-r--r--ldpd/lde_lib.c24
-rw-r--r--ldpd/ldp_zebra.c71
-rw-r--r--ldpd/ldpd.h3
-rw-r--r--lib/log.c1
-rw-r--r--lib/mpls.h2
-rw-r--r--lib/yang_wrappers.c53
-rw-r--r--lib/yang_wrappers.h8
-rw-r--r--lib/zclient.c137
-rw-r--r--lib/zclient.h29
-rw-r--r--ospfd/ospf_sr.c95
-rw-r--r--ospfd/ospf_sr.h3
-rw-r--r--tests/topotests/bgp_aggregate-address_route-map/test_bgp_aggregate-address_route-map.py44
-rw-r--r--tests/topotests/ldp-topo1/r1/ip_mpls_route.ref-15
-rw-r--r--tests/topotests/ldp-topo1/r1/show_ipv4_route.ref-17
-rw-r--r--tests/topotests/ldp-topo1/r1/show_mpls_ldp_binding.ref-142
-rw-r--r--tests/topotests/ldp-topo1/r1/show_mpls_ldp_discovery.ref-17
-rw-r--r--tests/topotests/ldp-topo1/r1/show_mpls_ldp_interface.ref-12
-rw-r--r--tests/topotests/ldp-topo1/r1/show_mpls_ldp_neighbor.ref-18
-rw-r--r--tests/topotests/ldp-topo1/r1/show_mpls_table.ref16
-rw-r--r--tests/topotests/ldp-topo1/r1/show_mpls_table.ref-18
-rw-r--r--tests/topotests/ldp-topo1/r1/show_mpls_table.ref-no-impl-null8
-rw-r--r--tests/topotests/ldp-topo1/r2/show_ipv4_route.ref-17
-rw-r--r--tests/topotests/ldp-topo1/r2/show_mpls_ldp_binding.ref-156
-rw-r--r--tests/topotests/ldp-topo1/r2/show_mpls_ldp_discovery.ref-112
-rw-r--r--tests/topotests/ldp-topo1/r2/show_mpls_ldp_interface.ref-13
-rw-r--r--tests/topotests/ldp-topo1/r2/show_mpls_ldp_neighbor.ref-126
-rw-r--r--tests/topotests/ldp-topo1/r2/show_mpls_table.ref14
-rw-r--r--tests/topotests/ldp-topo1/r2/show_mpls_table.ref-17
-rw-r--r--tests/topotests/ldp-topo1/r2/show_mpls_table.ref-no-impl-null7
-rw-r--r--tests/topotests/ldp-topo1/r3/show_ipv4_route.ref-17
-rw-r--r--tests/topotests/ldp-topo1/r3/show_mpls_ldp_binding.ref-149
-rw-r--r--tests/topotests/ldp-topo1/r3/show_mpls_ldp_discovery.ref-19
-rw-r--r--tests/topotests/ldp-topo1/r3/show_mpls_ldp_interface.ref-12
-rw-r--r--tests/topotests/ldp-topo1/r3/show_mpls_ldp_neighbor.ref-117
-rw-r--r--tests/topotests/ldp-topo1/r3/show_mpls_table.ref20
-rw-r--r--tests/topotests/ldp-topo1/r3/show_mpls_table.ref-110
-rw-r--r--tests/topotests/ldp-topo1/r3/show_mpls_table.ref-no-impl-null10
-rw-r--r--tests/topotests/ldp-topo1/r4/show_ipv4_route.ref-17
-rw-r--r--tests/topotests/ldp-topo1/r4/show_mpls_ldp_binding.ref-149
-rw-r--r--tests/topotests/ldp-topo1/r4/show_mpls_ldp_discovery.ref-19
-rw-r--r--tests/topotests/ldp-topo1/r4/show_mpls_ldp_interface.ref-12
-rw-r--r--tests/topotests/ldp-topo1/r4/show_mpls_ldp_neighbor.ref-117
-rw-r--r--tests/topotests/ldp-topo1/r4/show_mpls_table.ref18
-rw-r--r--tests/topotests/ldp-topo1/r4/show_mpls_table.ref-19
-rw-r--r--tests/topotests/ldp-topo1/r4/show_mpls_table.ref-no-impl-null9
-rwxr-xr-xtests/topotests/ldp-topo1/test_ldp_topo1.py119
-rw-r--r--tests/topotests/ospf-sr-topo1/r1/zebra_mpls.json12
-rw-r--r--tests/topotests/ospf-sr-topo1/r2/zebra_mpls.json18
-rw-r--r--tests/topotests/ospf-sr-topo1/r3/zebra_mpls.json10
-rw-r--r--tests/topotests/ospf-sr-topo1/r4/zebra_mpls.json12
-rw-r--r--tests/topotests/pytest.ini2
-rw-r--r--yang/libyang_plugins/frr_user_types.c18
-rw-r--r--zebra/zapi_msg.c195
-rw-r--r--zebra/zebra_mpls.c185
-rw-r--r--zebra/zebra_mpls.h34
-rw-r--r--zebra/zebra_rnh.c7
64 files changed, 789 insertions, 843 deletions
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 1156810510..c81abd643f 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -781,12 +781,12 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */
static_attr.nexthop.s_addr = nexthop->u.prefix4.s_addr;
static_attr.mp_nexthop_global_in = nexthop->u.prefix4;
- static_attr.mp_nexthop_len = 4;
+ static_attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV4;
break;
case AF_INET6:
static_attr.mp_nexthop_global = nexthop->u.prefix6;
- static_attr.mp_nexthop_len = 16;
+ static_attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL;
break;
default:
@@ -802,7 +802,8 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */
*/
static_attr.mp_nexthop_global_in =
static_attr.nexthop;
- static_attr.mp_nexthop_len = 4;
+ static_attr.mp_nexthop_len =
+ BGP_ATTR_NHLEN_IPV4;
/*
* XXX Leave static_attr.nexthop
* intact for NHT
@@ -821,7 +822,8 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */
&& !BGP_ATTR_NEXTHOP_AFI_IP6(path_vrf->attr)) {
static_attr.mp_nexthop_global_in.s_addr =
static_attr.nexthop.s_addr;
- static_attr.mp_nexthop_len = 4;
+ static_attr.mp_nexthop_len =
+ BGP_ATTR_NHLEN_IPV4;
static_attr.flag |=
ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP);
}
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 5eeab36742..962f0b3375 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -7269,7 +7269,8 @@ void route_vty_out(struct vty *vty, struct prefix *p,
/* We display both LL & GL if both have been
* received */
- if ((attr->mp_nexthop_len == 32)
+ if ((attr->mp_nexthop_len
+ == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
|| (path->peer->conf_if)) {
json_nexthop_ll = json_object_new_object();
json_object_string_add(
@@ -7301,7 +7302,8 @@ void route_vty_out(struct vty *vty, struct prefix *p,
} else {
/* Display LL if LL/Global both in table unless
* prefer-global is set */
- if (((attr->mp_nexthop_len == 32)
+ if (((attr->mp_nexthop_len
+ == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
&& !attr->mp_nexthop_prefer_global)
|| (path->peer->conf_if)) {
if (path->peer->conf_if) {
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index b1f1819b6b..da702ec857 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -2856,12 +2856,15 @@ route_set_ipv6_nexthop_peer(void *rule, const struct prefix *pfx,
/* Set next hop value and length in attribute. */
if (IN6_IS_ADDR_LINKLOCAL(&peer_address)) {
path->attr->mp_nexthop_local = peer_address;
- if (path->attr->mp_nexthop_len != 32)
- path->attr->mp_nexthop_len = 32;
+ if (path->attr->mp_nexthop_len
+ != BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
+ path->attr->mp_nexthop_len =
+ BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL;
} else {
path->attr->mp_nexthop_global = peer_address;
if (path->attr->mp_nexthop_len == 0)
- path->attr->mp_nexthop_len = 16;
+ path->attr->mp_nexthop_len =
+ BGP_ATTR_NHLEN_IPV6_GLOBAL;
}
} else if (CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_OUT)) {
@@ -2926,7 +2929,7 @@ route_set_vpnv4_nexthop(void *rule, const struct prefix *prefix,
/* Set next hop value. */
path->attr->mp_nexthop_global_in = *address;
- path->attr->mp_nexthop_len = 4;
+ path->attr->mp_nexthop_len = BGP_ATTR_NHLEN_IPV4;
}
return RMAP_OKAY;
diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c
index 9b8f64ee67..0aa102feab 100644
--- a/bgpd/rfapi/rfapi.c
+++ b/bgpd/rfapi/rfapi.c
@@ -880,12 +880,12 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
attr.nexthop.s_addr = nexthop->addr.v4.s_addr;
attr.mp_nexthop_global_in = nexthop->addr.v4;
- attr.mp_nexthop_len = 4;
+ attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV4;
break;
case AF_INET6:
attr.mp_nexthop_global = nexthop->addr.v6;
- attr.mp_nexthop_len = 16;
+ attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL;
break;
default:
diff --git a/bgpd/rfapi/vnc_export_bgp.c b/bgpd/rfapi/vnc_export_bgp.c
index 3d8d5bccb0..b97c8c3030 100644
--- a/bgpd/rfapi/vnc_export_bgp.c
+++ b/bgpd/rfapi/vnc_export_bgp.c
@@ -86,13 +86,13 @@ static void encap_attr_export_ce(struct attr *new, struct attr *orig,
switch (use_nexthop->family) {
case AF_INET:
new->nexthop = use_nexthop->u.prefix4;
- new->mp_nexthop_len = 4; /* bytes */
+ new->mp_nexthop_len = BGP_ATTR_NHLEN_IPV4; /* bytes */
new->flag |= ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP);
break;
case AF_INET6:
new->mp_nexthop_global = use_nexthop->u.prefix6;
- new->mp_nexthop_len = 16; /* bytes */
+ new->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; /* bytes */
break;
default:
@@ -624,13 +624,13 @@ encap_attr_export(struct attr *new, struct attr *orig,
switch (use_nexthop->family) {
case AF_INET:
new->nexthop = use_nexthop->u.prefix4;
- new->mp_nexthop_len = 4; /* bytes */
+ new->mp_nexthop_len = BGP_ATTR_NHLEN_IPV4; /* bytes */
new->flag |= ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP);
break;
case AF_INET6:
new->mp_nexthop_global = use_nexthop->u.prefix6;
- new->mp_nexthop_len = 16; /* bytes */
+ new->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; /* bytes */
break;
default:
diff --git a/ldpd/l2vpn.c b/ldpd/l2vpn.c
index 7f2e396a7f..b234e3ebe3 100644
--- a/ldpd/l2vpn.c
+++ b/ldpd/l2vpn.c
@@ -249,7 +249,7 @@ l2vpn_pw_init(struct l2vpn_pw *pw)
l2vpn_pw_fec(pw, &fec);
lde_kernel_insert(&fec, AF_INET, (union ldpd_addr*)&pw->lsr_id, 0, 0,
- 0, (void *)pw);
+ 0, 0, (void *)pw);
lde_kernel_update(&fec);
}
@@ -260,7 +260,7 @@ l2vpn_pw_exit(struct l2vpn_pw *pw)
struct zapi_pw zpw;
l2vpn_pw_fec(pw, &fec);
- lde_kernel_remove(&fec, AF_INET, (union ldpd_addr*)&pw->lsr_id, 0, 0);
+ lde_kernel_remove(&fec, AF_INET, (union ldpd_addr*)&pw->lsr_id, 0, 0, 0);
lde_kernel_update(&fec);
pw2zpw(pw, &zpw);
@@ -433,7 +433,7 @@ l2vpn_recv_pw_status(struct lde_nbr *ln, struct notify_msg *nm)
if (pw == NULL)
return;
- fnh = fec_nh_find(fn, AF_INET, (union ldpd_addr *)&ln->id, 0, 0);
+ fnh = fec_nh_find(fn, AF_INET, (union ldpd_addr *)&ln->id, 0, 0, 0);
if (fnh == NULL)
return;
@@ -482,7 +482,7 @@ l2vpn_recv_pw_status_wcard(struct lde_nbr *ln, struct notify_msg *nm)
}
fnh = fec_nh_find(fn, AF_INET, (union ldpd_addr *)&ln->id,
- 0, 0);
+ 0, 0, 0);
if (fnh == NULL)
continue;
diff --git a/ldpd/lde.c b/ldpd/lde.c
index ac680b47a9..006d27f6ab 100644
--- a/ldpd/lde.c
+++ b/ldpd/lde.c
@@ -520,7 +520,8 @@ lde_dispatch_parent(struct thread *thread)
switch (imsg.hdr.type) {
case IMSG_NETWORK_ADD:
lde_kernel_insert(&fec, kr->af, &kr->nexthop,
- kr->ifindex, kr->priority,
+ kr->ifindex, kr->route_type,
+ kr->route_instance,
kr->flags & F_CONNECTED, NULL);
break;
case IMSG_NETWORK_UPDATE:
@@ -747,7 +748,8 @@ lde_send_change_klabel(struct fec_node *fn, struct fec_nh *fnh)
kr.ifindex = fnh->ifindex;
kr.local_label = fn->local_label;
kr.remote_label = fnh->remote_label;
- kr.priority = fnh->priority;
+ kr.route_type = fnh->route_type;
+ kr.route_instance = fnh->route_instance;
lde_imsg_compose_parent(IMSG_KLABEL_CHANGE, 0, &kr,
sizeof(kr));
@@ -761,7 +763,8 @@ lde_send_change_klabel(struct fec_node *fn, struct fec_nh *fnh)
kr.ifindex = fnh->ifindex;
kr.local_label = fn->local_label;
kr.remote_label = fnh->remote_label;
- kr.priority = fnh->priority;
+ kr.route_type = fnh->route_type;
+ kr.route_instance = fnh->route_instance;
lde_imsg_compose_parent(IMSG_KLABEL_CHANGE, 0, &kr,
sizeof(kr));
@@ -798,7 +801,8 @@ lde_send_delete_klabel(struct fec_node *fn, struct fec_nh *fnh)
kr.ifindex = fnh->ifindex;
kr.local_label = fn->local_label;
kr.remote_label = fnh->remote_label;
- kr.priority = fnh->priority;
+ kr.route_type = fnh->route_type;
+ kr.route_instance = fnh->route_instance;
lde_imsg_compose_parent(IMSG_KLABEL_DELETE, 0, &kr,
sizeof(kr));
@@ -812,7 +816,8 @@ lde_send_delete_klabel(struct fec_node *fn, struct fec_nh *fnh)
kr.ifindex = fnh->ifindex;
kr.local_label = fn->local_label;
kr.remote_label = fnh->remote_label;
- kr.priority = fnh->priority;
+ kr.route_type = fnh->route_type;
+ kr.route_instance = fnh->route_instance;
lde_imsg_compose_parent(IMSG_KLABEL_DELETE, 0, &kr,
sizeof(kr));
diff --git a/ldpd/lde.h b/ldpd/lde.h
index 0a7d0a58fe..ce466c16b9 100644
--- a/ldpd/lde.h
+++ b/ldpd/lde.h
@@ -108,7 +108,8 @@ struct fec_nh {
union ldpd_addr nexthop;
ifindex_t ifindex;
uint32_t remote_label;
- uint8_t priority;
+ uint8_t route_type;
+ unsigned short route_instance;
uint8_t flags;
};
#define F_FEC_NH_NEW 0x01
@@ -193,11 +194,11 @@ void rt_dump(pid_t);
void fec_snap(struct lde_nbr *);
void fec_tree_clear(void);
struct fec_nh *fec_nh_find(struct fec_node *, int, union ldpd_addr *,
- ifindex_t, uint8_t);
+ ifindex_t, uint8_t, unsigned short);
void lde_kernel_insert(struct fec *, int, union ldpd_addr *,
- ifindex_t, uint8_t, int, void *);
+ ifindex_t, uint8_t, unsigned short, int, void *);
void lde_kernel_remove(struct fec *, int, union ldpd_addr *,
- ifindex_t, uint8_t);
+ ifindex_t, uint8_t, unsigned short);
void lde_kernel_update(struct fec *);
void lde_check_mapping(struct map *, struct lde_nbr *);
void lde_check_request(struct map *, struct lde_nbr *);
diff --git a/ldpd/lde_lib.c b/ldpd/lde_lib.c
index 0957a5455e..eb1a6d9434 100644
--- a/ldpd/lde_lib.c
+++ b/ldpd/lde_lib.c
@@ -31,7 +31,7 @@ static int lde_nbr_is_nexthop(struct fec_node *,
static void fec_free(void *);
static struct fec_node *fec_add(struct fec *fec);
static struct fec_nh *fec_nh_add(struct fec_node *, int, union ldpd_addr *,
- ifindex_t, uint8_t);
+ ifindex_t, uint8_t, unsigned short);
static void fec_nh_del(struct fec_nh *);
RB_GENERATE(fec_tree, fec, entry, fec_compare)
@@ -275,7 +275,7 @@ fec_add(struct fec *fec)
struct fec_nh *
fec_nh_find(struct fec_node *fn, int af, union ldpd_addr *nexthop,
- ifindex_t ifindex, uint8_t priority)
+ ifindex_t ifindex, uint8_t route_type, unsigned short route_instance)
{
struct fec_nh *fnh;
@@ -283,7 +283,8 @@ fec_nh_find(struct fec_node *fn, int af, union ldpd_addr *nexthop,
if (fnh->af == af &&
ldp_addrcmp(af, &fnh->nexthop, nexthop) == 0 &&
fnh->ifindex == ifindex &&
- fnh->priority == priority)
+ fnh->route_type == route_type &&
+ fnh->route_instance == route_instance)
return (fnh);
return (NULL);
@@ -291,7 +292,7 @@ fec_nh_find(struct fec_node *fn, int af, union ldpd_addr *nexthop,
static struct fec_nh *
fec_nh_add(struct fec_node *fn, int af, union ldpd_addr *nexthop,
- ifindex_t ifindex, uint8_t priority)
+ ifindex_t ifindex, uint8_t route_type, unsigned short route_instance)
{
struct fec_nh *fnh;
@@ -303,7 +304,8 @@ fec_nh_add(struct fec_node *fn, int af, union ldpd_addr *nexthop,
fnh->nexthop = *nexthop;
fnh->ifindex = ifindex;
fnh->remote_label = NO_LABEL;
- fnh->priority = priority;
+ fnh->route_type = route_type;
+ fnh->route_instance = route_instance;
LIST_INSERT_HEAD(&fn->nexthops, fnh, entry);
return (fnh);
@@ -318,7 +320,8 @@ fec_nh_del(struct fec_nh *fnh)
void
lde_kernel_insert(struct fec *fec, int af, union ldpd_addr *nexthop,
- ifindex_t ifindex, uint8_t priority, int connected, void *data)
+ ifindex_t ifindex, uint8_t route_type, unsigned short route_instance,
+ int connected, void *data)
{
struct fec_node *fn;
struct fec_nh *fnh;
@@ -329,9 +332,10 @@ lde_kernel_insert(struct fec *fec, int af, union ldpd_addr *nexthop,
if (data)
fn->data = data;
- fnh = fec_nh_find(fn, af, nexthop, ifindex, priority);
+ fnh = fec_nh_find(fn, af, nexthop, ifindex, route_type, route_instance);
if (fnh == NULL)
- fnh = fec_nh_add(fn, af, nexthop, ifindex, priority);
+ fnh = fec_nh_add(fn, af, nexthop, ifindex, route_type,
+ route_instance);
fnh->flags |= F_FEC_NH_NEW;
if (connected)
fnh->flags |= F_FEC_NH_CONNECTED;
@@ -339,7 +343,7 @@ lde_kernel_insert(struct fec *fec, int af, union ldpd_addr *nexthop,
void
lde_kernel_remove(struct fec *fec, int af, union ldpd_addr *nexthop,
- ifindex_t ifindex, uint8_t priority)
+ ifindex_t ifindex, uint8_t route_type, unsigned short route_instance)
{
struct fec_node *fn;
struct fec_nh *fnh;
@@ -348,7 +352,7 @@ lde_kernel_remove(struct fec *fec, int af, union ldpd_addr *nexthop,
if (fn == NULL)
/* route lost */
return;
- fnh = fec_nh_find(fn, af, nexthop, ifindex, priority);
+ fnh = fec_nh_find(fn, af, nexthop, ifindex, route_type, route_instance);
if (fnh == NULL)
/* route lost */
return;
diff --git a/ldpd/ldp_zebra.c b/ldpd/ldp_zebra.c
index 35a7d944d3..884ae159be 100644
--- a/ldpd/ldp_zebra.c
+++ b/ldpd/ldp_zebra.c
@@ -37,7 +37,7 @@
static void ifp2kif(struct interface *, struct kif *);
static void ifc2kaddr(struct interface *, struct connected *,
struct kaddr *);
-static int zebra_send_mpls_labels(int, struct kroute *);
+static int ldp_zebra_send_mpls_labels(int, struct kroute *);
static int ldp_router_id_update(ZAPI_CALLBACK_ARGS);
static int ldp_interface_add(ZAPI_CALLBACK_ARGS);
static int ldp_interface_delete(ZAPI_CALLBACK_ARGS);
@@ -106,9 +106,10 @@ pw2zpw(struct l2vpn_pw *pw, struct zapi_pw *zpw)
}
static int
-zebra_send_mpls_labels(int cmd, struct kroute *kr)
+ldp_zebra_send_mpls_labels(int cmd, struct kroute *kr)
{
- struct stream *s;
+ struct zapi_labels zl = {};
+ struct zapi_nexthop_label *znh;
if (kr->local_label < MPLS_LABEL_RESERVED_MAX ||
kr->remote_label == NO_LABEL)
@@ -120,48 +121,65 @@ zebra_send_mpls_labels(int cmd, struct kroute *kr)
log_label(kr->local_label), log_label(kr->remote_label),
(cmd == ZEBRA_MPLS_LABELS_ADD) ? "add" : "delete");
- /* Reset stream. */
- s = zclient->obuf;
- stream_reset(s);
+ zl.type = ZEBRA_LSP_LDP;
+ zl.local_label = kr->local_label;
- zclient_create_header(s, cmd, VRF_DEFAULT);
- stream_putc(s, ZEBRA_LSP_LDP);
- stream_putl(s, kr->af);
+ /* Set prefix. */
+ SET_FLAG(zl.message, ZAPI_LABELS_FTN);
+ zl.route.prefix.family = kr->af;
switch (kr->af) {
case AF_INET:
- stream_put_in_addr(s, &kr->prefix.v4);
- stream_putc(s, kr->prefixlen);
- stream_put_in_addr(s, &kr->nexthop.v4);
+ zl.route.prefix.u.prefix4 = kr->prefix.v4;
break;
case AF_INET6:
- stream_write(s, (uint8_t *)&kr->prefix.v6, 16);
- stream_putc(s, kr->prefixlen);
- stream_write(s, (uint8_t *)&kr->nexthop.v6, 16);
+ zl.route.prefix.u.prefix6 = kr->prefix.v6;
break;
default:
- fatalx("kr_change: unknown af");
+ fatalx("ldp_zebra_send_mpls_labels: unknown af");
}
- stream_putl(s, kr->ifindex);
- stream_putc(s, kr->priority);
- stream_putl(s, kr->local_label);
- stream_putl(s, kr->remote_label);
+ zl.route.prefix.prefixlen = kr->prefixlen;
+ zl.route.type = kr->route_type;
+ zl.route.instance = kr->route_instance;
- /* Put length at the first point of the stream. */
- stream_putw_at(s, 0, stream_get_endp(s));
+ /* Set nexthop. */
+ zl.nexthop_num = 1;
+ znh = &zl.nexthops[0];
+ switch (kr->af) {
+ case AF_INET:
+ znh->family = AF_INET;
+ znh->address.ipv4 = kr->nexthop.v4;
+ if (kr->ifindex)
+ znh->type = NEXTHOP_TYPE_IPV4_IFINDEX;
+ else
+ znh->type = NEXTHOP_TYPE_IPV4;
+ break;
+ case AF_INET6:
+ znh->family = AF_INET6;
+ znh->address.ipv6 = kr->nexthop.v6;
+ if (kr->ifindex)
+ znh->type = NEXTHOP_TYPE_IPV6_IFINDEX;
+ else
+ znh->type = NEXTHOP_TYPE_IPV6;
+ break;
+ default:
+ break;
+ }
+ znh->ifindex = kr->ifindex;
+ znh->label = kr->remote_label;
- return (zclient_send_message(zclient));
+ return zebra_send_mpls_labels(zclient, cmd, &zl);
}
int
kr_change(struct kroute *kr)
{
- return (zebra_send_mpls_labels(ZEBRA_MPLS_LABELS_ADD, kr));
+ return (ldp_zebra_send_mpls_labels(ZEBRA_MPLS_LABELS_ADD, kr));
}
int
kr_delete(struct kroute *kr)
{
- return (zebra_send_mpls_labels(ZEBRA_MPLS_LABELS_DELETE, kr));
+ return (ldp_zebra_send_mpls_labels(ZEBRA_MPLS_LABELS_DELETE, kr));
}
int
@@ -407,7 +425,8 @@ ldp_zebra_read_route(ZAPI_CALLBACK_ARGS)
break;
}
kr.prefixlen = api.prefix.prefixlen;
- kr.priority = api.distance;
+ kr.route_type = api.type;
+ kr.route_instance = api.instance;
switch (api.type) {
case ZEBRA_ROUTE_CONNECT:
diff --git a/ldpd/ldpd.h b/ldpd/ldpd.h
index 9113505581..bd7562e5ad 100644
--- a/ldpd/ldpd.h
+++ b/ldpd/ldpd.h
@@ -543,7 +543,8 @@ struct kroute {
uint32_t local_label;
uint32_t remote_label;
unsigned short ifindex;
- uint8_t priority;
+ uint8_t route_type;
+ uint8_t route_instance;
uint16_t flags;
};
diff --git a/lib/log.c b/lib/log.c
index f1c0fabfba..c777868736 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -1041,6 +1041,7 @@ static const struct zebra_desc_table command_types[] = {
DESC_ENTRY(ZEBRA_INTERFACE_LINK_PARAMS),
DESC_ENTRY(ZEBRA_MPLS_LABELS_ADD),
DESC_ENTRY(ZEBRA_MPLS_LABELS_DELETE),
+ DESC_ENTRY(ZEBRA_MPLS_LABELS_REPLACE),
DESC_ENTRY(ZEBRA_IPMR_ROUTE_STATS),
DESC_ENTRY(ZEBRA_LABEL_MANAGER_CONNECT),
DESC_ENTRY(ZEBRA_LABEL_MANAGER_CONNECT_ASYNC),
diff --git a/lib/mpls.h b/lib/mpls.h
index d7b56c47bd..472ee9bc46 100644
--- a/lib/mpls.h
+++ b/lib/mpls.h
@@ -125,7 +125,7 @@ enum lsp_types_t {
ZEBRA_LSP_STATIC = 1, /* Static LSP. */
ZEBRA_LSP_LDP = 2, /* LDP LSP. */
ZEBRA_LSP_BGP = 3, /* BGP LSP. */
- ZEBRA_LSP_SR = 4, /* Segment Routing LSP. */
+ ZEBRA_LSP_OSPF_SR = 4,/* OSPF Segment Routing LSP. */
ZEBRA_LSP_SHARP = 5, /* Identifier for test protocol */
};
diff --git a/lib/yang_wrappers.c b/lib/yang_wrappers.c
index 0558383823..cd776f333d 100644
--- a/lib/yang_wrappers.c
+++ b/lib/yang_wrappers.c
@@ -1000,3 +1000,56 @@ void yang_get_default_ipv6p(union prefixptr var, const char *xpath_fmt, ...)
value = yang_get_default_value(xpath);
yang_str2ipv6p(value, var);
}
+
+/*
+ * Derived type: ip.
+ */
+void yang_str2ip(const char *value, struct ipaddr *ip)
+{
+ (void)str2ipaddr(value, ip);
+}
+
+struct yang_data *yang_data_new_ip(const char *xpath, const struct ipaddr *addr)
+{
+ size_t sz = IS_IPADDR_V4(addr) ? INET_ADDRSTRLEN : INET6_ADDRSTRLEN;
+ char value_str[sz];
+
+ ipaddr2str(addr, value_str, sizeof(value_str));
+ return yang_data_new(xpath, value_str);
+}
+
+void yang_dnode_get_ip(struct ipaddr *addr, const struct lyd_node *dnode,
+ const char *xpath_fmt, ...)
+{
+ const struct lyd_node_leaf_list *dleaf;
+
+ assert(dnode);
+ if (xpath_fmt) {
+ va_list ap;
+ char xpath[XPATH_MAXLEN];
+
+ va_start(ap, xpath_fmt);
+ vsnprintf(xpath, sizeof(xpath), xpath_fmt, ap);
+ va_end(ap);
+ dnode = yang_dnode_get(dnode, xpath);
+ YANG_DNODE_GET_ASSERT(dnode, xpath);
+ }
+
+ dleaf = (const struct lyd_node_leaf_list *)dnode;
+ assert(dleaf->value_type == LY_TYPE_STRING);
+ (void)str2ipaddr(dleaf->value_str, addr);
+}
+
+void yang_get_default_ip(struct ipaddr *var, const char *xpath_fmt, ...)
+{
+ char xpath[XPATH_MAXLEN];
+ const char *value;
+ va_list ap;
+
+ va_start(ap, xpath_fmt);
+ vsnprintf(xpath, sizeof(xpath), xpath_fmt, ap);
+ va_end(ap);
+
+ value = yang_get_default_value(xpath);
+ yang_str2ip(value, var);
+}
diff --git a/lib/yang_wrappers.h b/lib/yang_wrappers.h
index 5203a033ad..ab7abe173c 100644
--- a/lib/yang_wrappers.h
+++ b/lib/yang_wrappers.h
@@ -154,4 +154,12 @@ extern void yang_dnode_get_ipv6p(union prefixptr prefix,
extern void yang_get_default_ipv6p(union prefixptr var, const char *xpath_fmt,
...);
+/* ip */
+extern void yang_str2ip(const char *value, struct ipaddr *addr);
+extern struct yang_data *yang_data_new_ip(const char *xpath,
+ const struct ipaddr *addr);
+extern void yang_dnode_get_ip(struct ipaddr *addr, const struct lyd_node *dnode,
+ const char *xpath_fmt, ...);
+extern void yang_get_default_ip(struct ipaddr *var, const char *xpath_fmt, ...);
+
#endif /* _FRR_NORTHBOUND_WRAPPERS_H_ */
diff --git a/lib/zclient.c b/lib/zclient.c
index f809704f86..92a495ac61 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -2451,6 +2451,143 @@ int tm_release_table_chunk(struct zclient *zclient, uint32_t start,
return zclient_send_message(zclient);
}
+int zebra_send_mpls_labels(struct zclient *zclient, int cmd,
+ struct zapi_labels *zl)
+{
+ if (zapi_labels_encode(zclient->obuf, cmd, zl) < 0)
+ return -1;
+ return zclient_send_message(zclient);
+}
+
+int zapi_labels_encode(struct stream *s, int cmd, struct zapi_labels *zl)
+{
+ struct zapi_nexthop_label *znh;
+
+ stream_reset(s);
+
+ zclient_create_header(s, cmd, VRF_DEFAULT);
+ stream_putc(s, zl->message);
+ stream_putc(s, zl->type);
+ stream_putl(s, zl->local_label);
+
+ if (CHECK_FLAG(zl->message, ZAPI_LABELS_FTN)) {
+ stream_putw(s, zl->route.prefix.family);
+ stream_put_prefix(s, &zl->route.prefix);
+ stream_putc(s, zl->route.type);
+ stream_putw(s, zl->route.instance);
+ }
+
+ if (zl->nexthop_num > MULTIPATH_NUM) {
+ flog_err(
+ EC_LIB_ZAPI_ENCODE,
+ "%s: label %u: can't encode %u nexthops (maximum is %u)",
+ __func__, zl->local_label, zl->nexthop_num,
+ MULTIPATH_NUM);
+ return -1;
+ }
+ stream_putw(s, zl->nexthop_num);
+
+ for (int i = 0; i < zl->nexthop_num; i++) {
+ znh = &zl->nexthops[i];
+
+ stream_putc(s, znh->type);
+ stream_putw(s, znh->family);
+ switch (znh->family) {
+ case AF_INET:
+ stream_put_in_addr(s, &znh->address.ipv4);
+ break;
+ case AF_INET6:
+ stream_write(s, (uint8_t *)&znh->address.ipv6, 16);
+ break;
+ default:
+ break;
+ }
+ stream_putl(s, znh->ifindex);
+ stream_putl(s, znh->label);
+ }
+
+ /* Put length at the first point of the stream. */
+ stream_putw_at(s, 0, stream_get_endp(s));
+
+ return 0;
+}
+
+int zapi_labels_decode(struct stream *s, struct zapi_labels *zl)
+{
+ struct zapi_nexthop_label *znh;
+
+ memset(zl, 0, sizeof(*zl));
+
+ /* Get data. */
+ STREAM_GETC(s, zl->message);
+ STREAM_GETC(s, zl->type);
+ STREAM_GETL(s, zl->local_label);
+
+ if (CHECK_FLAG(zl->message, ZAPI_LABELS_FTN)) {
+ size_t psize;
+
+ STREAM_GETW(s, zl->route.prefix.family);
+ STREAM_GETC(s, zl->route.prefix.prefixlen);
+
+ psize = PSIZE(zl->route.prefix.prefixlen);
+ switch (zl->route.prefix.family) {
+ case AF_INET:
+ if (zl->route.prefix.prefixlen > IPV4_MAX_BITLEN) {
+ zlog_debug(
+ "%s: Specified prefix length %d is greater than a v4 address can support",
+ __PRETTY_FUNCTION__,
+ zl->route.prefix.prefixlen);
+ return -1;
+ }
+ STREAM_GET(&zl->route.prefix.u.prefix4.s_addr, s,
+ psize);
+ break;
+ case AF_INET6:
+ if (zl->route.prefix.prefixlen > IPV6_MAX_BITLEN) {
+ zlog_debug(
+ "%s: Specified prefix length %d is greater than a v6 address can support",
+ __PRETTY_FUNCTION__,
+ zl->route.prefix.prefixlen);
+ return -1;
+ }
+ STREAM_GET(&zl->route.prefix.u.prefix6, s, psize);
+ break;
+ default:
+ flog_err(EC_LIB_ZAPI_ENCODE,
+ "%s: Specified family %u is not v4 or v6",
+ __PRETTY_FUNCTION__, zl->route.prefix.family);
+ return -1;
+ }
+
+ STREAM_GETC(s, zl->route.type);
+ STREAM_GETW(s, zl->route.instance);
+ }
+
+ STREAM_GETW(s, zl->nexthop_num);
+ for (int i = 0; i < zl->nexthop_num; i++) {
+ znh = &zl->nexthops[i];
+
+ STREAM_GETC(s, znh->type);
+ STREAM_GETW(s, znh->family);
+ switch (znh->family) {
+ case AF_INET:
+ STREAM_GET(&znh->address.ipv4.s_addr, s,
+ IPV4_MAX_BYTELEN);
+ break;
+ case AF_INET6:
+ STREAM_GET(&znh->address.ipv6, s, 16);
+ break;
+ default:
+ break;
+ }
+ STREAM_GETL(s, znh->ifindex);
+ STREAM_GETL(s, znh->label);
+ }
+
+ return 0;
+stream_failure:
+ return -1;
+}
int zebra_send_pw(struct zclient *zclient, int command, struct zapi_pw *pw)
{
diff --git a/lib/zclient.h b/lib/zclient.h
index 81e454d192..eb3c97b111 100644
--- a/lib/zclient.h
+++ b/lib/zclient.h
@@ -126,6 +126,7 @@ typedef enum {
ZEBRA_INTERFACE_LINK_PARAMS,
ZEBRA_MPLS_LABELS_ADD,
ZEBRA_MPLS_LABELS_DELETE,
+ ZEBRA_MPLS_LABELS_REPLACE,
ZEBRA_IPMR_ROUTE_STATS,
ZEBRA_LABEL_MANAGER_CONNECT,
ZEBRA_LABEL_MANAGER_CONNECT_ASYNC,
@@ -395,6 +396,28 @@ struct zapi_route {
uint32_t tableid;
};
+struct zapi_nexthop_label {
+ enum nexthop_types_t type;
+ int family;
+ union g_addr address;
+ ifindex_t ifindex;
+ mpls_label_t label;
+};
+
+struct zapi_labels {
+ uint8_t message;
+#define ZAPI_LABELS_FTN 0x01
+ enum lsp_types_t type;
+ mpls_label_t local_label;
+ struct {
+ struct prefix prefix;
+ uint8_t type;
+ unsigned short instance;
+ } route;
+ uint16_t nexthop_num;
+ struct zapi_nexthop_label nexthops[MULTIPATH_NUM];
+};
+
struct zapi_pw {
char ifname[IF_NAMESIZE];
ifindex_t ifindex;
@@ -625,6 +648,12 @@ extern int tm_get_table_chunk(struct zclient *zclient, uint32_t chunk_size,
extern int tm_release_table_chunk(struct zclient *zclient, uint32_t start,
uint32_t end);
+extern int zebra_send_mpls_labels(struct zclient *zclient, int cmd,
+ struct zapi_labels *zl);
+extern int zapi_labels_encode(struct stream *s, int cmd,
+ struct zapi_labels *zl);
+extern int zapi_labels_decode(struct stream *s, struct zapi_labels *zl);
+
extern int zebra_send_pw(struct zclient *zclient, int command,
struct zapi_pw *pw);
extern void zebra_read_pw_status_update(ZAPI_CALLBACK_ARGS, struct zapi_pw_status *pw);
diff --git a/ospfd/ospf_sr.c b/ospfd/ospf_sr.c
index 6947393a60..ff2039bec8 100644
--- a/ospfd/ospf_sr.c
+++ b/ospfd/ospf_sr.c
@@ -608,26 +608,8 @@ static int compute_prefix_nhlfe(struct sr_prefix *srp)
/* Send MPLS Label entry to Zebra for installation or deletion */
static int ospf_zebra_send_mpls_labels(int cmd, struct sr_nhlfe nhlfe)
{
- struct stream *s;
-
- /* Reset stream. */
- s = zclient->obuf;
- stream_reset(s);
-
- zclient_create_header(s, cmd, VRF_DEFAULT);
- stream_putc(s, ZEBRA_LSP_SR);
- /* OSPF Segment Routing currently support only IPv4 */
- stream_putl(s, nhlfe.prefv4.family);
- stream_put_in_addr(s, &nhlfe.prefv4.prefix);
- stream_putc(s, nhlfe.prefv4.prefixlen);
- stream_put_in_addr(s, &nhlfe.nexthop);
- stream_putl(s, nhlfe.ifindex);
- stream_putc(s, OSPF_SR_PRIORITY_DEFAULT);
- stream_putl(s, nhlfe.label_in);
- stream_putl(s, nhlfe.label_out);
-
- /* Put length at the first point of the stream. */
- stream_putw_at(s, 0, stream_get_endp(s));
+ struct zapi_labels zl = {};
+ struct zapi_nexthop_label *znh;
if (IS_DEBUG_OSPF_SR)
zlog_debug(" |- %s LSP %u/%u for %s/%u via %u",
@@ -636,70 +618,39 @@ static int ospf_zebra_send_mpls_labels(int cmd, struct sr_nhlfe nhlfe)
inet_ntoa(nhlfe.prefv4.prefix),
nhlfe.prefv4.prefixlen, nhlfe.ifindex);
- return zclient_send_message(zclient);
-}
-
-/* Request zebra to install/remove FEC in FIB */
-static int ospf_zebra_send_mpls_ftn(int cmd, struct sr_nhlfe nhlfe)
-{
- struct zapi_route api;
- struct zapi_nexthop *api_nh;
-
- /* Support only IPv4 */
- if (nhlfe.prefv4.family != AF_INET)
- return -1;
-
- memset(&api, 0, sizeof(api));
- api.vrf_id = VRF_DEFAULT;
- api.type = ZEBRA_ROUTE_OSPF;
- api.safi = SAFI_UNICAST;
- memcpy(&api.prefix, &nhlfe.prefv4, sizeof(struct prefix_ipv4));
-
- if (cmd == ZEBRA_ROUTE_ADD) {
- /* Metric value. */
- SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
- api.metric = OSPF_SR_DEFAULT_METRIC;
- /* Nexthop */
- SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
- api_nh = &api.nexthops[0];
- IPV4_ADDR_COPY(&api_nh->gate.ipv4, &nhlfe.nexthop);
- api_nh->type = NEXTHOP_TYPE_IPV4_IFINDEX;
- api_nh->ifindex = nhlfe.ifindex;
- /* MPLS labels */
- SET_FLAG(api.message, ZAPI_MESSAGE_LABEL);
- api_nh->labels[0] = nhlfe.label_out;
- api_nh->label_num = 1;
- api_nh->vrf_id = VRF_DEFAULT;
- api.nexthop_num = 1;
- }
-
- if (IS_DEBUG_OSPF_SR)
- zlog_debug(" |- %s FEC %u for %s/%u via %u",
- cmd == ZEBRA_ROUTE_ADD ? "Add" : "Delete",
- nhlfe.label_out, inet_ntoa(nhlfe.prefv4.prefix),
- nhlfe.prefv4.prefixlen, nhlfe.ifindex);
-
- return zclient_route_send(cmd, zclient, &api);
+ zl.type = ZEBRA_LSP_OSPF_SR;
+ zl.local_label = nhlfe.label_in;
+
+ SET_FLAG(zl.message, ZAPI_LABELS_FTN);
+ zl.route.prefix.family = nhlfe.prefv4.family;
+ zl.route.prefix.prefixlen = nhlfe.prefv4.prefixlen;
+ zl.route.prefix.u.prefix4 = nhlfe.prefv4.prefix;
+ zl.route.type = ZEBRA_ROUTE_OSPF;
+ zl.route.instance = 0;
+
+ zl.nexthop_num = 1;
+ znh = &zl.nexthops[0];
+ znh->type = NEXTHOP_TYPE_IPV4_IFINDEX;
+ znh->family = AF_INET;
+ znh->address.ipv4 = nhlfe.nexthop;
+ znh->ifindex = nhlfe.ifindex;
+ znh->label = nhlfe.label_out;
+
+ return zebra_send_mpls_labels(zclient, cmd, &zl);
}
/* Add new NHLFE entry for SID */
static inline void add_sid_nhlfe(struct sr_nhlfe nhlfe)
{
- if ((nhlfe.label_in != 0) && (nhlfe.label_out != 0)) {
+ if ((nhlfe.label_in != 0) && (nhlfe.label_out != 0))
ospf_zebra_send_mpls_labels(ZEBRA_MPLS_LABELS_ADD, nhlfe);
- if (nhlfe.label_out != MPLS_LABEL_IMPLICIT_NULL)
- ospf_zebra_send_mpls_ftn(ZEBRA_ROUTE_ADD, nhlfe);
- }
}
/* Remove NHLFE entry for SID */
static inline void del_sid_nhlfe(struct sr_nhlfe nhlfe)
{
- if ((nhlfe.label_in != 0) && (nhlfe.label_out != 0)) {
+ if ((nhlfe.label_in != 0) && (nhlfe.label_out != 0))
ospf_zebra_send_mpls_labels(ZEBRA_MPLS_LABELS_DELETE, nhlfe);
- if (nhlfe.label_out != MPLS_LABEL_IMPLICIT_NULL)
- ospf_zebra_send_mpls_ftn(ZEBRA_ROUTE_DELETE, nhlfe);
- }
}
/* Update NHLFE entry for SID */
diff --git a/ospfd/ospf_sr.h b/ospfd/ospf_sr.h
index 4d3f5f441a..df923e970f 100644
--- a/ospfd/ospf_sr.h
+++ b/ospfd/ospf_sr.h
@@ -27,9 +27,6 @@
#ifndef _FRR_OSPF_SR_H
#define _FRR_OSPF_SR_H
-/* Default Route priority for OSPF Segment Routing */
-#define OSPF_SR_PRIORITY_DEFAULT 10
-
/* macros and constants for segment routing */
#define SET_RANGE_SIZE_MASK 0xffffff00
#define GET_RANGE_SIZE_MASK 0x00ffffff
diff --git a/tests/topotests/bgp_aggregate-address_route-map/test_bgp_aggregate-address_route-map.py b/tests/topotests/bgp_aggregate-address_route-map/test_bgp_aggregate-address_route-map.py
index bee5115323..d6753e9b23 100644
--- a/tests/topotests/bgp_aggregate-address_route-map/test_bgp_aggregate-address_route-map.py
+++ b/tests/topotests/bgp_aggregate-address_route-map/test_bgp_aggregate-address_route-map.py
@@ -39,6 +39,7 @@ import sys
import json
import time
import pytest
+import functools
CWD = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(CWD, '../'))
@@ -88,21 +89,42 @@ def test_bgp_maximum_prefix_invalid():
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
+ router = tgen.gears['r2']
+
def _bgp_converge(router):
- while True:
- output = json.loads(tgen.gears[router].vtysh_cmd("show ip bgp neighbor 192.168.255.1 json"))
- if output['192.168.255.1']['bgpState'] == 'Established':
- if output['192.168.255.1']['addressFamilyInfo']['ipv4Unicast']['acceptedPrefixCounter'] == 3:
- return True
+ output = json.loads(router.vtysh_cmd("show ip bgp neighbor 192.168.255.1 json"))
+ expected = {
+ '192.168.255.1': {
+ 'bgpState': 'Established',
+ 'addressFamilyInfo': {
+ 'ipv4Unicast': {
+ 'acceptedPrefixCounter': 3
+ }
+ }
+ }
+ }
+ return topotest.json_cmp(output, expected)
def _bgp_aggregate_address_has_metric(router):
- output = json.loads(tgen.gears[router].vtysh_cmd("show ip bgp 172.16.255.0/24 json"))
- if output['paths'][0]['med'] == 123:
- return True
- return False
+ output = json.loads(router.vtysh_cmd("show ip bgp 172.16.255.0/24 json"))
+ expected = {
+ 'paths': [
+ {
+ 'med': 123
+ }
+ ]
+ }
+ return topotest.json_cmp(output, expected)
+
+ test_func = functools.partial(_bgp_converge, router)
+ success, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
+
+ assert result is None, 'Failed to see bgp convergence in "{}"'.format(router)
+
+ test_func = functools.partial(_bgp_aggregate_address_has_metric, router)
+ success, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
- if _bgp_converge('r2'):
- assert _bgp_aggregate_address_has_metric('r2') == True
+ assert result is None, 'Failed to see applied metric for aggregated prefix in "{}"'.format(router)
if __name__ == '__main__':
args = ["-s"] + sys.argv[1:]
diff --git a/tests/topotests/ldp-topo1/r1/ip_mpls_route.ref-1 b/tests/topotests/ldp-topo1/r1/ip_mpls_route.ref-1
deleted file mode 100644
index f244122f1a..0000000000
--- a/tests/topotests/ldp-topo1/r1/ip_mpls_route.ref-1
+++ /dev/null
@@ -1,5 +0,0 @@
-xx as to xx via inet 10.0.1.2 dev r1-eth0 proto xx
-xx as to xx via inet 10.0.1.2 dev r1-eth0 proto xx
-xx via inet 10.0.1.2 dev r1-eth0 proto xx
-xx via inet 10.0.1.2 dev r1-eth0 proto xx
-xx via inet 10.0.1.2 dev r1-eth0 proto xx
diff --git a/tests/topotests/ldp-topo1/r1/show_ipv4_route.ref-1 b/tests/topotests/ldp-topo1/r1/show_ipv4_route.ref-1
deleted file mode 100644
index ff99ff9866..0000000000
--- a/tests/topotests/ldp-topo1/r1/show_ipv4_route.ref-1
+++ /dev/null
@@ -1,7 +0,0 @@
-O 1.1.1.1/32 [110/0] is directly connected, lo
-O>* 2.2.2.2/32 [110/10] via 10.0.1.2, r1-eth0
-O>* 3.3.3.3/32 [110/20] via 10.0.1.2, r1-eth0, label xxx
-O>* 4.4.4.4/32 [110/20] via 10.0.1.2, r1-eth0, label xxx
-O 10.0.1.0/24 [110/10] is directly connected, r1-eth0
-O>* 10.0.2.0/24 [110/20] via 10.0.1.2, r1-eth0
-O>* 10.0.3.0/24 [110/20] via 10.0.1.2, r1-eth0
diff --git a/tests/topotests/ldp-topo1/r1/show_mpls_ldp_binding.ref-1 b/tests/topotests/ldp-topo1/r1/show_mpls_ldp_binding.ref-1
deleted file mode 100644
index ff72a1c0b7..0000000000
--- a/tests/topotests/ldp-topo1/r1/show_mpls_ldp_binding.ref-1
+++ /dev/null
@@ -1,42 +0,0 @@
-1.1.1.1/32
- Local binding: label: imp-null
- Remote bindings:
- Peer Label
- ----------------- ---------
- 2.2.2.2 xxx
-2.2.2.2/32
- Local binding: label: xxx
- Remote bindings:
- Peer Label
- ----------------- ---------
- 2.2.2.2 imp-null
-3.3.3.3/32
- Local binding: label: xxx
- Remote bindings:
- Peer Label
- ----------------- ---------
- 2.2.2.2 xxx
-4.4.4.4/32
- Local binding: label: xxx
- Remote bindings:
- Peer Label
- ----------------- ---------
- 2.2.2.2 xxx
-10.0.1.0/24
- Local binding: label: imp-null
- Remote bindings:
- Peer Label
- ----------------- ---------
- 2.2.2.2 imp-null
-10.0.2.0/24
- Local binding: label: xxx
- Remote bindings:
- Peer Label
- ----------------- ---------
- 2.2.2.2 imp-null
-10.0.3.0/24
- Local binding: label: xxx
- Remote bindings:
- Peer Label
- ----------------- ---------
- 2.2.2.2 imp-null
diff --git a/tests/topotests/ldp-topo1/r1/show_mpls_ldp_discovery.ref-1 b/tests/topotests/ldp-topo1/r1/show_mpls_ldp_discovery.ref-1
deleted file mode 100644
index 38522e162e..0000000000
--- a/tests/topotests/ldp-topo1/r1/show_mpls_ldp_discovery.ref-1
+++ /dev/null
@@ -1,7 +0,0 @@
-Local LDP Identifier: 1.1.1.1:0
-Discovery Sources:
- Interfaces:
- r1-eth0: xmit/recv
- LDP Id: 2.2.2.2:0, Transport address: 2.2.2.2
- Hold time: 15 sec
- Targeted Hellos:
diff --git a/tests/topotests/ldp-topo1/r1/show_mpls_ldp_interface.ref-1 b/tests/topotests/ldp-topo1/r1/show_mpls_ldp_interface.ref-1
deleted file mode 100644
index 0fb15d2da7..0000000000
--- a/tests/topotests/ldp-topo1/r1/show_mpls_ldp_interface.ref-1
+++ /dev/null
@@ -1,2 +0,0 @@
-AF Interface State Uptime Hello Timers ac
-ipv4 r1-eth0 ACTIVE xx:xx:xx 5/15 1
diff --git a/tests/topotests/ldp-topo1/r1/show_mpls_ldp_neighbor.ref-1 b/tests/topotests/ldp-topo1/r1/show_mpls_ldp_neighbor.ref-1
deleted file mode 100644
index 3df98bfae5..0000000000
--- a/tests/topotests/ldp-topo1/r1/show_mpls_ldp_neighbor.ref-1
+++ /dev/null
@@ -1,8 +0,0 @@
-Peer LDP Identifier: 2.2.2.2:0
- TCP connection: 1.1.1.1:xxx - 2.2.2.2:xxx
- Session Holdtime: 180 sec
- State: OPERATIONAL; Downstream-Unsolicited
- Up time: xx:xx:xx
- LDP Discovery Sources:
- IPv4:
- Interface: r1-eth0
diff --git a/tests/topotests/ldp-topo1/r1/show_mpls_table.ref b/tests/topotests/ldp-topo1/r1/show_mpls_table.ref
index 61cb9eec82..7e24359af3 100644
--- a/tests/topotests/ldp-topo1/r1/show_mpls_table.ref
+++ b/tests/topotests/ldp-topo1/r1/show_mpls_table.ref
@@ -1,8 +1,8 @@
- Inbound Outbound
- Label Type Nexthop Label
--------- ------- --------------- --------
- XX LDP 10.0.1.2 XX
- XX LDP 10.0.1.2 XX
- XX LDP 10.0.1.2 implicit-null
- XX LDP 10.0.1.2 implicit-null
- XX LDP 10.0.1.2 implicit-null
+ Inbound Label Type Nexthop Outbound Label
+ -----------------------------------------------
+ XX LDP 10.0.1.2 XX
+ XX LDP 10.0.1.2 XX
+ XX LDP 10.0.1.2 implicit-null
+ XX LDP 10.0.1.2 implicit-null
+ XX LDP 10.0.1.2 implicit-null
+
diff --git a/tests/topotests/ldp-topo1/r1/show_mpls_table.ref-1 b/tests/topotests/ldp-topo1/r1/show_mpls_table.ref-1
deleted file mode 100644
index 912a082019..0000000000
--- a/tests/topotests/ldp-topo1/r1/show_mpls_table.ref-1
+++ /dev/null
@@ -1,8 +0,0 @@
- Inbound Outbound
- Label Type Nexthop Label
--------- ------- --------------- --------
- XX LDP 10.0.1.2 3
- XX LDP 10.0.1.2 3
- XX LDP 10.0.1.2 3
- XX LDP 10.0.1.2 XX
- XX LDP 10.0.1.2 XX
diff --git a/tests/topotests/ldp-topo1/r1/show_mpls_table.ref-no-impl-null b/tests/topotests/ldp-topo1/r1/show_mpls_table.ref-no-impl-null
deleted file mode 100644
index 912a082019..0000000000
--- a/tests/topotests/ldp-topo1/r1/show_mpls_table.ref-no-impl-null
+++ /dev/null
@@ -1,8 +0,0 @@
- Inbound Outbound
- Label Type Nexthop Label
--------- ------- --------------- --------
- XX LDP 10.0.1.2 3
- XX LDP 10.0.1.2 3
- XX LDP 10.0.1.2 3
- XX LDP 10.0.1.2 XX
- XX LDP 10.0.1.2 XX
diff --git a/tests/topotests/ldp-topo1/r2/show_ipv4_route.ref-1 b/tests/topotests/ldp-topo1/r2/show_ipv4_route.ref-1
deleted file mode 100644
index eaec2f16b9..0000000000
--- a/tests/topotests/ldp-topo1/r2/show_ipv4_route.ref-1
+++ /dev/null
@@ -1,7 +0,0 @@
-O>* 1.1.1.1/32 [110/10] via 10.0.1.1, r2-eth0
-O 2.2.2.2/32 [110/0] is directly connected, lo
-O>* 3.3.3.3/32 [110/10] via 10.0.2.3, r2-eth1
-O>* 4.4.4.4/32 [110/10] via 10.0.2.4, r2-eth1
-O 10.0.1.0/24 [110/10] is directly connected, r2-eth0
-O 10.0.2.0/24 [110/10] is directly connected, r2-eth1
-O 10.0.3.0/24 [110/10] is directly connected, r2-eth2
diff --git a/tests/topotests/ldp-topo1/r2/show_mpls_ldp_binding.ref-1 b/tests/topotests/ldp-topo1/r2/show_mpls_ldp_binding.ref-1
deleted file mode 100644
index 54ee39080a..0000000000
--- a/tests/topotests/ldp-topo1/r2/show_mpls_ldp_binding.ref-1
+++ /dev/null
@@ -1,56 +0,0 @@
-1.1.1.1/32
- Local binding: label: xxx
- Remote bindings:
- Peer Label
- ----------------- ---------
- 1.1.1.1 imp-null
- 3.3.3.3 xxx
- 4.4.4.4 xxx
-2.2.2.2/32
- Local binding: label: imp-null
- Remote bindings:
- Peer Label
- ----------------- ---------
- 1.1.1.1 xxx
- 3.3.3.3 xxx
- 4.4.4.4 xxx
-3.3.3.3/32
- Local binding: label: xxx
- Remote bindings:
- Peer Label
- ----------------- ---------
- 1.1.1.1 xxx
- 3.3.3.3 imp-null
- 4.4.4.4 xxx
-4.4.4.4/32
- Local binding: label: xxx
- Remote bindings:
- Peer Label
- ----------------- ---------
- 1.1.1.1 xxx
- 3.3.3.3 xxx
- 4.4.4.4 imp-null
-10.0.1.0/24
- Local binding: label: imp-null
- Remote bindings:
- Peer Label
- ----------------- ---------
- 1.1.1.1 imp-null
- 3.3.3.3 xxx
- 4.4.4.4 xxx
-10.0.2.0/24
- Local binding: label: imp-null
- Remote bindings:
- Peer Label
- ----------------- ---------
- 1.1.1.1 xxx
- 3.3.3.3 imp-null
- 4.4.4.4 imp-null
-10.0.3.0/24
- Local binding: label: imp-null
- Remote bindings:
- Peer Label
- ----------------- ---------
- 1.1.1.1 xxx
- 3.3.3.3 imp-null
- 4.4.4.4 xxx
diff --git a/tests/topotests/ldp-topo1/r2/show_mpls_ldp_discovery.ref-1 b/tests/topotests/ldp-topo1/r2/show_mpls_ldp_discovery.ref-1
deleted file mode 100644
index b1bebd7c46..0000000000
--- a/tests/topotests/ldp-topo1/r2/show_mpls_ldp_discovery.ref-1
+++ /dev/null
@@ -1,12 +0,0 @@
-Local LDP Identifier: 2.2.2.2:0
-Discovery Sources:
- Interfaces:
- r2-eth0: xmit/recv
- LDP Id: 1.1.1.1:0, Transport address: 1.1.1.1
- Hold time: 15 sec
- r2-eth1: xmit/recv
- LDP Id: 3.3.3.3:0, Transport address: 3.3.3.3
- Hold time: 15 sec
- LDP Id: 4.4.4.4:0, Transport address: 4.4.4.4
- Hold time: 15 sec
- Targeted Hellos:
diff --git a/tests/topotests/ldp-topo1/r2/show_mpls_ldp_interface.ref-1 b/tests/topotests/ldp-topo1/r2/show_mpls_ldp_interface.ref-1
deleted file mode 100644
index f9fc98408c..0000000000
--- a/tests/topotests/ldp-topo1/r2/show_mpls_ldp_interface.ref-1
+++ /dev/null
@@ -1,3 +0,0 @@
-AF Interface State Uptime Hello Timers ac
-ipv4 r2-eth0 ACTIVE xx:xx:xx 5/15 1
-ipv4 r2-eth1 ACTIVE xx:xx:xx 5/15 2
diff --git a/tests/topotests/ldp-topo1/r2/show_mpls_ldp_neighbor.ref-1 b/tests/topotests/ldp-topo1/r2/show_mpls_ldp_neighbor.ref-1
deleted file mode 100644
index a70e2f48c6..0000000000
--- a/tests/topotests/ldp-topo1/r2/show_mpls_ldp_neighbor.ref-1
+++ /dev/null
@@ -1,26 +0,0 @@
-Peer LDP Identifier: 1.1.1.1:0
- TCP connection: 2.2.2.2:xxx - 1.1.1.1:xxx
- Session Holdtime: 180 sec
- State: OPERATIONAL; Downstream-Unsolicited
- Up time: xx:xx:xx
- LDP Discovery Sources:
- IPv4:
- Interface: r2-eth0
-
-Peer LDP Identifier: 3.3.3.3:0
- TCP connection: 2.2.2.2:xxx - 3.3.3.3:xxx
- Session Holdtime: 180 sec
- State: OPERATIONAL; Downstream-Unsolicited
- Up time: xx:xx:xx
- LDP Discovery Sources:
- IPv4:
- Interface: r2-eth1
-
-Peer LDP Identifier: 4.4.4.4:0
- TCP connection: 2.2.2.2:xxx - 4.4.4.4:xxx
- Session Holdtime: 180 sec
- State: OPERATIONAL; Downstream-Unsolicited
- Up time: xx:xx:xx
- LDP Discovery Sources:
- IPv4:
- Interface: r2-eth1
diff --git a/tests/topotests/ldp-topo1/r2/show_mpls_table.ref b/tests/topotests/ldp-topo1/r2/show_mpls_table.ref
index 46420ccd11..df05a6b31a 100644
--- a/tests/topotests/ldp-topo1/r2/show_mpls_table.ref
+++ b/tests/topotests/ldp-topo1/r2/show_mpls_table.ref
@@ -1,7 +1,7 @@
- Inbound Outbound
- Label Type Nexthop Label
--------- ------- --------------- --------
- XX LDP 10.0.1.1 implicit-null
- XX LDP 10.0.2.3 implicit-null
- XX LDP 10.0.2.4 implicit-null
- XX LDP 10.0.3.3 implicit-null
+ Inbound Label Type Nexthop Outbound Label
+ -----------------------------------------------
+ XX LDP 10.0.1.1 implicit-null
+ XX LDP 10.0.2.3 implicit-null
+ XX LDP 10.0.2.4 implicit-null
+ XX LDP 10.0.3.3 implicit-null
+
diff --git a/tests/topotests/ldp-topo1/r2/show_mpls_table.ref-1 b/tests/topotests/ldp-topo1/r2/show_mpls_table.ref-1
deleted file mode 100644
index ba244e76ec..0000000000
--- a/tests/topotests/ldp-topo1/r2/show_mpls_table.ref-1
+++ /dev/null
@@ -1,7 +0,0 @@
- Inbound Outbound
- Label Type Nexthop Label
--------- ------- --------------- --------
- XX LDP 10.0.1.1 3
- XX LDP 10.0.2.3 3
- XX LDP 10.0.2.4 3
- XX LDP 10.0.3.3 3
diff --git a/tests/topotests/ldp-topo1/r2/show_mpls_table.ref-no-impl-null b/tests/topotests/ldp-topo1/r2/show_mpls_table.ref-no-impl-null
deleted file mode 100644
index ba244e76ec..0000000000
--- a/tests/topotests/ldp-topo1/r2/show_mpls_table.ref-no-impl-null
+++ /dev/null
@@ -1,7 +0,0 @@
- Inbound Outbound
- Label Type Nexthop Label
--------- ------- --------------- --------
- XX LDP 10.0.1.1 3
- XX LDP 10.0.2.3 3
- XX LDP 10.0.2.4 3
- XX LDP 10.0.3.3 3
diff --git a/tests/topotests/ldp-topo1/r3/show_ipv4_route.ref-1 b/tests/topotests/ldp-topo1/r3/show_ipv4_route.ref-1
deleted file mode 100644
index c8a29400b2..0000000000
--- a/tests/topotests/ldp-topo1/r3/show_ipv4_route.ref-1
+++ /dev/null
@@ -1,7 +0,0 @@
-O>* 1.1.1.1/32 [110/20] via 10.0.2.2, r3-eth0, label xxx
-O>* 2.2.2.2/32 [110/10] via 10.0.2.2, r3-eth0
-O 3.3.3.3/32 [110/0] is directly connected, lo
-O>* 4.4.4.4/32 [110/10] via 10.0.2.4, r3-eth0
-O>* 10.0.1.0/24 [110/20] via 10.0.2.2, r3-eth0
-O 10.0.2.0/24 [110/10] is directly connected, r3-eth0
-O 10.0.3.0/24 [110/10] is directly connected, r3-eth1
diff --git a/tests/topotests/ldp-topo1/r3/show_mpls_ldp_binding.ref-1 b/tests/topotests/ldp-topo1/r3/show_mpls_ldp_binding.ref-1
deleted file mode 100644
index e04d2b7e4a..0000000000
--- a/tests/topotests/ldp-topo1/r3/show_mpls_ldp_binding.ref-1
+++ /dev/null
@@ -1,49 +0,0 @@
-1.1.1.1/32
- Local binding: label: xxx
- Remote bindings:
- Peer Label
- ----------------- ---------
- 2.2.2.2 xxx
- 4.4.4.4 xxx
-2.2.2.2/32
- Local binding: label: xxx
- Remote bindings:
- Peer Label
- ----------------- ---------
- 2.2.2.2 imp-null
- 4.4.4.4 xxx
-3.3.3.3/32
- Local binding: label: imp-null
- Remote bindings:
- Peer Label
- ----------------- ---------
- 2.2.2.2 xxx
- 4.4.4.4 xxx
-4.4.4.4/32
- Local binding: label: xxx
- Remote bindings:
- Peer Label
- ----------------- ---------
- 2.2.2.2 xxx
- 4.4.4.4 imp-null
-10.0.1.0/24
- Local binding: label: xxx
- Remote bindings:
- Peer Label
- ----------------- ---------
- 2.2.2.2 imp-null
- 4.4.4.4 xxx
-10.0.2.0/24
- Local binding: label: imp-null
- Remote bindings:
- Peer Label
- ----------------- ---------
- 2.2.2.2 imp-null
- 4.4.4.4 imp-null
-10.0.3.0/24
- Local binding: label: imp-null
- Remote bindings:
- Peer Label
- ----------------- ---------
- 2.2.2.2 imp-null
- 4.4.4.4 xxx
diff --git a/tests/topotests/ldp-topo1/r3/show_mpls_ldp_discovery.ref-1 b/tests/topotests/ldp-topo1/r3/show_mpls_ldp_discovery.ref-1
deleted file mode 100644
index 5e299fff9c..0000000000
--- a/tests/topotests/ldp-topo1/r3/show_mpls_ldp_discovery.ref-1
+++ /dev/null
@@ -1,9 +0,0 @@
-Local LDP Identifier: 3.3.3.3:0
-Discovery Sources:
- Interfaces:
- r3-eth0: xmit/recv
- LDP Id: 2.2.2.2:0, Transport address: 2.2.2.2
- Hold time: 15 sec
- LDP Id: 4.4.4.4:0, Transport address: 4.4.4.4
- Hold time: 15 sec
- Targeted Hellos:
diff --git a/tests/topotests/ldp-topo1/r3/show_mpls_ldp_interface.ref-1 b/tests/topotests/ldp-topo1/r3/show_mpls_ldp_interface.ref-1
deleted file mode 100644
index 243811e3a9..0000000000
--- a/tests/topotests/ldp-topo1/r3/show_mpls_ldp_interface.ref-1
+++ /dev/null
@@ -1,2 +0,0 @@
-AF Interface State Uptime Hello Timers ac
-ipv4 r3-eth0 ACTIVE xx:xx:xx 5/15 2
diff --git a/tests/topotests/ldp-topo1/r3/show_mpls_ldp_neighbor.ref-1 b/tests/topotests/ldp-topo1/r3/show_mpls_ldp_neighbor.ref-1
deleted file mode 100644
index ee1983ac29..0000000000
--- a/tests/topotests/ldp-topo1/r3/show_mpls_ldp_neighbor.ref-1
+++ /dev/null
@@ -1,17 +0,0 @@
-Peer LDP Identifier: 2.2.2.2:0
- TCP connection: 3.3.3.3:xxx - 2.2.2.2:xxx
- Session Holdtime: 180 sec
- State: OPERATIONAL; Downstream-Unsolicited
- Up time: xx:xx:xx
- LDP Discovery Sources:
- IPv4:
- Interface: r3-eth0
-
-Peer LDP Identifier: 4.4.4.4:0
- TCP connection: 3.3.3.3:xxx - 4.4.4.4:xxx
- Session Holdtime: 180 sec
- State: OPERATIONAL; Downstream-Unsolicited
- Up time: xx:xx:xx
- LDP Discovery Sources:
- IPv4:
- Interface: r3-eth0
diff --git a/tests/topotests/ldp-topo1/r3/show_mpls_table.ref b/tests/topotests/ldp-topo1/r3/show_mpls_table.ref
index c367f240f4..3978895613 100644
--- a/tests/topotests/ldp-topo1/r3/show_mpls_table.ref
+++ b/tests/topotests/ldp-topo1/r3/show_mpls_table.ref
@@ -1,10 +1,10 @@
- Inbound Outbound
- Label Type Nexthop Label
--------- ------- --------------- --------
- XX LDP 10.0.2.2 XX
- XX LDP 10.0.2.2 implicit-null
- XX LDP 10.0.2.2 implicit-null
- XX LDP 10.0.2.4 implicit-null
- XX LDP 10.0.3.2 XX
- XX LDP 10.0.3.2 implicit-null
- XX LDP 10.0.3.2 implicit-null
+ Inbound Label Type Nexthop Outbound Label
+ -----------------------------------------------
+ XX LDP 10.0.2.2 XX
+ XX LDP 10.0.2.2 implicit-null
+ XX LDP 10.0.2.2 implicit-null
+ XX LDP 10.0.2.4 implicit-null
+ XX LDP 10.0.3.2 XX
+ XX LDP 10.0.3.2 implicit-null
+ XX LDP 10.0.3.2 implicit-null
+
diff --git a/tests/topotests/ldp-topo1/r3/show_mpls_table.ref-1 b/tests/topotests/ldp-topo1/r3/show_mpls_table.ref-1
deleted file mode 100644
index 9198969bd5..0000000000
--- a/tests/topotests/ldp-topo1/r3/show_mpls_table.ref-1
+++ /dev/null
@@ -1,10 +0,0 @@
- Inbound Outbound
- Label Type Nexthop Label
--------- ------- --------------- --------
- XX LDP 10.0.2.2 3
- XX LDP 10.0.2.2 3
- XX LDP 10.0.2.2 XX
- XX LDP 10.0.2.4 3
- XX LDP 10.0.3.2 3
- XX LDP 10.0.3.2 3
- XX LDP 10.0.3.2 XX
diff --git a/tests/topotests/ldp-topo1/r3/show_mpls_table.ref-no-impl-null b/tests/topotests/ldp-topo1/r3/show_mpls_table.ref-no-impl-null
deleted file mode 100644
index 9198969bd5..0000000000
--- a/tests/topotests/ldp-topo1/r3/show_mpls_table.ref-no-impl-null
+++ /dev/null
@@ -1,10 +0,0 @@
- Inbound Outbound
- Label Type Nexthop Label
--------- ------- --------------- --------
- XX LDP 10.0.2.2 3
- XX LDP 10.0.2.2 3
- XX LDP 10.0.2.2 XX
- XX LDP 10.0.2.4 3
- XX LDP 10.0.3.2 3
- XX LDP 10.0.3.2 3
- XX LDP 10.0.3.2 XX
diff --git a/tests/topotests/ldp-topo1/r4/show_ipv4_route.ref-1 b/tests/topotests/ldp-topo1/r4/show_ipv4_route.ref-1
deleted file mode 100644
index df2a2b585f..0000000000
--- a/tests/topotests/ldp-topo1/r4/show_ipv4_route.ref-1
+++ /dev/null
@@ -1,7 +0,0 @@
-O>* 1.1.1.1/32 [110/20] via 10.0.2.2, r4-eth0, label xxx
-O>* 2.2.2.2/32 [110/10] via 10.0.2.2, r4-eth0
-O>* 3.3.3.3/32 [110/10] via 10.0.2.3, r4-eth0
-O 4.4.4.4/32 [110/0] is directly connected, lo
-O>* 10.0.1.0/24 [110/20] via 10.0.2.2, r4-eth0
-O 10.0.2.0/24 [110/10] is directly connected, r4-eth0
-O>* 10.0.3.0/24 [110/20] via 10.0.2.2, r4-eth0
diff --git a/tests/topotests/ldp-topo1/r4/show_mpls_ldp_binding.ref-1 b/tests/topotests/ldp-topo1/r4/show_mpls_ldp_binding.ref-1
deleted file mode 100644
index 3d55805d7c..0000000000
--- a/tests/topotests/ldp-topo1/r4/show_mpls_ldp_binding.ref-1
+++ /dev/null
@@ -1,49 +0,0 @@
-1.1.1.1/32
- Local binding: label: xxx
- Remote bindings:
- Peer Label
- ----------------- ---------
- 2.2.2.2 xxx
- 3.3.3.3 xxx
-2.2.2.2/32
- Local binding: label: xxx
- Remote bindings:
- Peer Label
- ----------------- ---------
- 2.2.2.2 imp-null
- 3.3.3.3 xxx
-3.3.3.3/32
- Local binding: label: xxx
- Remote bindings:
- Peer Label
- ----------------- ---------
- 2.2.2.2 xxx
- 3.3.3.3 imp-null
-4.4.4.4/32
- Local binding: label: imp-null
- Remote bindings:
- Peer Label
- ----------------- ---------
- 2.2.2.2 xxx
- 3.3.3.3 xxx
-10.0.1.0/24
- Local binding: label: xxx
- Remote bindings:
- Peer Label
- ----------------- ---------
- 2.2.2.2 imp-null
- 3.3.3.3 xxx
-10.0.2.0/24
- Local binding: label: imp-null
- Remote bindings:
- Peer Label
- ----------------- ---------
- 2.2.2.2 imp-null
- 3.3.3.3 imp-null
-10.0.3.0/24
- Local binding: label: xxx
- Remote bindings:
- Peer Label
- ----------------- ---------
- 2.2.2.2 imp-null
- 3.3.3.3 imp-null
diff --git a/tests/topotests/ldp-topo1/r4/show_mpls_ldp_discovery.ref-1 b/tests/topotests/ldp-topo1/r4/show_mpls_ldp_discovery.ref-1
deleted file mode 100644
index 3ebddd606a..0000000000
--- a/tests/topotests/ldp-topo1/r4/show_mpls_ldp_discovery.ref-1
+++ /dev/null
@@ -1,9 +0,0 @@
-Local LDP Identifier: 4.4.4.4:0
-Discovery Sources:
- Interfaces:
- r4-eth0: xmit/recv
- LDP Id: 2.2.2.2:0, Transport address: 2.2.2.2
- Hold time: 15 sec
- LDP Id: 3.3.3.3:0, Transport address: 3.3.3.3
- Hold time: 15 sec
- Targeted Hellos:
diff --git a/tests/topotests/ldp-topo1/r4/show_mpls_ldp_interface.ref-1 b/tests/topotests/ldp-topo1/r4/show_mpls_ldp_interface.ref-1
deleted file mode 100644
index dd57656f15..0000000000
--- a/tests/topotests/ldp-topo1/r4/show_mpls_ldp_interface.ref-1
+++ /dev/null
@@ -1,2 +0,0 @@
-AF Interface State Uptime Hello Timers ac
-ipv4 r4-eth0 ACTIVE xx:xx:xx 5/15 2
diff --git a/tests/topotests/ldp-topo1/r4/show_mpls_ldp_neighbor.ref-1 b/tests/topotests/ldp-topo1/r4/show_mpls_ldp_neighbor.ref-1
deleted file mode 100644
index fb0e7d7dfa..0000000000
--- a/tests/topotests/ldp-topo1/r4/show_mpls_ldp_neighbor.ref-1
+++ /dev/null
@@ -1,17 +0,0 @@
-Peer LDP Identifier: 2.2.2.2:0
- TCP connection: 4.4.4.4:xxx - 2.2.2.2:xxx
- Session Holdtime: 180 sec
- State: OPERATIONAL; Downstream-Unsolicited
- Up time: xx:xx:xx
- LDP Discovery Sources:
- IPv4:
- Interface: r4-eth0
-
-Peer LDP Identifier: 3.3.3.3:0
- TCP connection: 4.4.4.4:xxx - 3.3.3.3:xxx
- Session Holdtime: 180 sec
- State: OPERATIONAL; Downstream-Unsolicited
- Up time: xx:xx:xx
- LDP Discovery Sources:
- IPv4:
- Interface: r4-eth0
diff --git a/tests/topotests/ldp-topo1/r4/show_mpls_table.ref b/tests/topotests/ldp-topo1/r4/show_mpls_table.ref
index 9f86cd67cc..174dcebd4d 100644
--- a/tests/topotests/ldp-topo1/r4/show_mpls_table.ref
+++ b/tests/topotests/ldp-topo1/r4/show_mpls_table.ref
@@ -1,9 +1,9 @@
- Inbound Outbound
- Label Type Nexthop Label
--------- ------- --------------- --------
- XX LDP 10.0.2.2 XX
- XX LDP 10.0.2.2 implicit-null
- XX LDP 10.0.2.2 implicit-null
- XX LDP 10.0.2.2 implicit-null
- XX LDP 10.0.2.3 implicit-null
- XX LDP 10.0.2.3 implicit-null
+ Inbound Label Type Nexthop Outbound Label
+ -----------------------------------------------
+ XX LDP 10.0.2.2 XX
+ XX LDP 10.0.2.2 implicit-null
+ XX LDP 10.0.2.2 implicit-null
+ XX LDP 10.0.2.2 implicit-null
+ XX LDP 10.0.2.3 implicit-null
+ XX LDP 10.0.2.3 implicit-null
+
diff --git a/tests/topotests/ldp-topo1/r4/show_mpls_table.ref-1 b/tests/topotests/ldp-topo1/r4/show_mpls_table.ref-1
deleted file mode 100644
index b8cf5a2702..0000000000
--- a/tests/topotests/ldp-topo1/r4/show_mpls_table.ref-1
+++ /dev/null
@@ -1,9 +0,0 @@
- Inbound Outbound
- Label Type Nexthop Label
--------- ------- --------------- --------
- XX LDP 10.0.2.2 3
- XX LDP 10.0.2.2 3
- XX LDP 10.0.2.2 3
- XX LDP 10.0.2.2 XX
- XX LDP 10.0.2.3 3
- XX LDP 10.0.2.3 3
diff --git a/tests/topotests/ldp-topo1/r4/show_mpls_table.ref-no-impl-null b/tests/topotests/ldp-topo1/r4/show_mpls_table.ref-no-impl-null
deleted file mode 100644
index b8cf5a2702..0000000000
--- a/tests/topotests/ldp-topo1/r4/show_mpls_table.ref-no-impl-null
+++ /dev/null
@@ -1,9 +0,0 @@
- Inbound Outbound
- Label Type Nexthop Label
--------- ------- --------------- --------
- XX LDP 10.0.2.2 3
- XX LDP 10.0.2.2 3
- XX LDP 10.0.2.2 3
- XX LDP 10.0.2.2 XX
- XX LDP 10.0.2.3 3
- XX LDP 10.0.2.3 3
diff --git a/tests/topotests/ldp-topo1/test_ldp_topo1.py b/tests/topotests/ldp-topo1/test_ldp_topo1.py
index 409a5f54c8..f02f4c4e21 100755
--- a/tests/topotests/ldp-topo1/test_ldp_topo1.py
+++ b/tests/topotests/ldp-topo1/test_ldp_topo1.py
@@ -77,12 +77,6 @@ from lib import topotest
fatal_error = ""
-# Expected version of CLI Output - Appendix to filename
-# empty string = current, latest output (default)
-# "-1" ... "-NNN" previous versions (incrementing with each version)
-cli_version = ""
-
-
#####################################################
##
## Network Topology Definition
@@ -164,7 +158,6 @@ def teardown_module(module):
def test_router_running():
global fatal_error
global net
- global cli_version
# Skip if previous fatal error condition is raised
if (fatal_error != ""):
@@ -179,35 +172,12 @@ def test_router_running():
fatal_error = net['r%s' % i].checkRouterRunning()
assert fatal_error == "", fatal_error
- # Detect CLI Version
- # At this time, there are only 2 possible outputs, so simple check
- output = net['r1'].cmd('vtysh -c "show mpls ldp discovery" 2> /dev/null').rstrip()
-
- # Check if old or new format of CLI Output. Default is to current format
- #
- # Old (v1) output looks like this:
- # Local LDP Identifier: 1.1.1.1:0
- # Discovery Sources:
- # Interfaces:
- # r1-eth0: xmit/recv
- # LDP Id: 2.2.2.2:0, Transport address: 2.2.2.2
- # Hold time: 15 sec
- # Targeted Hellos:
- #
- # Current (v0) output looks like this:
- # AF ID Type Source Holdtime
- # ipv4 2.2.2.2 Link r1-eth0 15
- pattern = re.compile("^Local LDP Identifier.*")
- if pattern.match(output):
- cli_version = "-1"
-
# For debugging after starting FRR/Quagga daemons, uncomment the next line
# CLI(net)
def test_mpls_interfaces():
global fatal_error
global net
- global cli_version
# Skip if previous fatal error condition is raised
if (fatal_error != ""):
@@ -220,7 +190,7 @@ def test_mpls_interfaces():
print("******************************************\n")
failures = 0
for i in range(1, 5):
- refTableFile = '%s/r%s/show_mpls_ldp_interface.ref%s' % (thisDir, i, cli_version)
+ refTableFile = '%s/r%s/show_mpls_ldp_interface.ref'
if os.path.isfile(refTableFile):
# Read expected result from file
expected = open(refTableFile).read().rstrip()
@@ -263,7 +233,6 @@ def test_mpls_interfaces():
def test_mpls_ldp_neighbor_establish():
global fatal_error
global net
- global cli_version
# Skip if previous fatal error condition is raised
if (fatal_error != ""):
@@ -279,22 +248,22 @@ def test_mpls_ldp_neighbor_establish():
# Look for any node not yet converged
for i in range(1, 5):
established = net['r%s' % i].cmd('vtysh -c "show mpls ldp neighbor" 2> /dev/null').rstrip()
- if cli_version != "-1":
- # On current version, we need to make sure they all turn to OPERATIONAL on all lines
- #
- lines = ('\n'.join(established.splitlines()) + '\n').splitlines(1)
- # Check all lines to be either table header (starting with ^AF or show OPERATIONAL)
- header = r'^AF.*'
- operational = r'^ip.*OPERATIONAL.*'
- found_operational = 0
- for j in range(1, len(lines)):
- if (not re.search(header, lines[j])) and (not re.search(operational, lines[j])):
- established = "" # Empty string shows NOT established
- if re.search(operational, lines[j]):
- found_operational += 1
- if found_operational < 1:
- # Need at least one operational neighbor
+
+ # On current version, we need to make sure they all turn to OPERATIONAL on all lines
+ #
+ lines = ('\n'.join(established.splitlines()) + '\n').splitlines(1)
+ # Check all lines to be either table header (starting with ^AF or show OPERATIONAL)
+ header = r'^AF.*'
+ operational = r'^ip.*OPERATIONAL.*'
+ found_operational = 0
+ for j in range(1, len(lines)):
+ if (not re.search(header, lines[j])) and (not re.search(operational, lines[j])):
established = "" # Empty string shows NOT established
+ if re.search(operational, lines[j]):
+ found_operational += 1
+ if found_operational < 1:
+ # Need at least one operational neighbor
+ established = "" # Empty string shows NOT established
if not established:
print('Waiting for r%s' %i)
sys.stdout.flush()
@@ -326,7 +295,6 @@ def test_mpls_ldp_neighbor_establish():
def test_mpls_ldp_discovery():
global fatal_error
global net
- global cli_version
# Skip if previous fatal error condition is raised
if (fatal_error != ""):
@@ -339,7 +307,7 @@ def test_mpls_ldp_discovery():
print("******************************************\n")
failures = 0
for i in range(1, 5):
- refTableFile = '%s/r%s/show_mpls_ldp_discovery.ref%s' % (thisDir, i, cli_version)
+ refTableFile = '%s/r%s/show_mpls_ldp_discovery.ref'
if os.path.isfile(refTableFile):
# Actual output from router
actual = net['r%s' % i].cmd('vtysh -c "show mpls ldp discovery" 2> /dev/null').rstrip()
@@ -381,7 +349,6 @@ def test_mpls_ldp_discovery():
def test_mpls_ldp_neighbor():
global fatal_error
global net
- global cli_version
# Skip if previous fatal error condition is raised
if (fatal_error != ""):
@@ -394,7 +361,7 @@ def test_mpls_ldp_neighbor():
print("******************************************\n")
failures = 0
for i in range(1, 5):
- refTableFile = '%s/r%s/show_mpls_ldp_neighbor.ref%s' % (thisDir, i, cli_version)
+ refTableFile = '%s/r%s/show_mpls_ldp_neighbor.ref'
if os.path.isfile(refTableFile):
# Read expected result from file
expected = open(refTableFile).read().rstrip()
@@ -405,17 +372,8 @@ def test_mpls_ldp_neighbor():
actual = net['r%s' % i].cmd('vtysh -c "show mpls ldp neighbor" 2> /dev/null').rstrip()
# Mask out changing parts in output
- if cli_version == "-1":
- # Mask out Timer in Uptime
- actual = re.sub(r"Up time: [0-9][0-9]:[0-9][0-9]:[0-9][0-9]", "Up time: xx:xx:xx", actual)
- # Mask out Port numbers in TCP connection
- actual = re.sub(r"TCP connection: ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]):[0-9]+ - ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]):[0-9]+",
- r"TCP connection: \1:xxx - \2:xxx", actual)
- else:
- # Current Version
- #
- # Mask out Timer in Uptime
- actual = re.sub(r"(ipv4 [0-9\.]+ +OPERATIONAL [0-9\.]+ +)[0-9][0-9]:[0-9][0-9]:[0-9][0-9]", r"\1xx:xx:xx", actual)
+ # Mask out Timer in Uptime
+ actual = re.sub(r"(ipv4 [0-9\.]+ +OPERATIONAL [0-9\.]+ +)[0-9][0-9]:[0-9][0-9]:[0-9][0-9]", r"\1xx:xx:xx", actual)
# Fix newlines (make them all the same)
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
@@ -446,7 +404,6 @@ def test_mpls_ldp_neighbor():
def test_mpls_ldp_binding():
global fatal_error
global net
- global cli_version
# Skip this test for now until proper sorting of the output
# is implemented
@@ -463,7 +420,7 @@ def test_mpls_ldp_binding():
print("******************************************\n")
failures = 0
for i in range(1, 5):
- refTableFile = '%s/r%s/show_mpls_ldp_binding.ref%s' % (thisDir, i, cli_version)
+ refTableFile = '%s/r%s/show_mpls_ldp_binding.ref'
if os.path.isfile(refTableFile):
# Read expected result from file
expected = open(refTableFile).read().rstrip()
@@ -474,16 +431,9 @@ def test_mpls_ldp_binding():
actual = net['r%s' % i].cmd('vtysh -c "show mpls ldp binding" 2> /dev/null').rstrip()
# Mask out changing parts in output
- if cli_version == "-1":
- # Mask out label
- actual = re.sub(r"label: [0-9]+", "label: xxx", actual)
- actual = re.sub(r"(\s+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[ ]+)[0-9]+", r"\1xxx", actual)
- else:
- # Current Version
- #
- # Mask out label
- actual = re.sub(r"(ipv4 [0-9\./]+ +[0-9\.]+ +)[0-9][0-9] (.*)", r"\1xxx\2", actual)
- actual = re.sub(r"(ipv4 [0-9\./]+ +[0-9\.]+ +[a-z\-]+ +)[0-9][0-9] (.*)", r"\1xxx\2", actual)
+ # Mask out label
+ actual = re.sub(r"(ipv4 [0-9\./]+ +[0-9\.]+ +)[0-9][0-9] (.*)", r"\1xxx\2", actual)
+ actual = re.sub(r"(ipv4 [0-9\./]+ +[0-9\.]+ +[a-z\-]+ +)[0-9][0-9] (.*)", r"\1xxx\2", actual)
# Fix newlines (make them all the same)
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
@@ -527,7 +477,6 @@ def test_mpls_ldp_binding():
def test_zebra_ipv4_routingTable():
global fatal_error
global net
- global cli_version
# Skip if previous fatal error condition is raised
if (fatal_error != ""):
@@ -540,7 +489,7 @@ def test_zebra_ipv4_routingTable():
print("******************************************\n")
failures = 0
for i in range(1, 5):
- refTableFile = '%s/r%s/show_ipv4_route.ref%s' % (thisDir, i, cli_version)
+ refTableFile = '%s/r%s/show_ipv4_route.ref'
if os.path.isfile(refTableFile):
# Read expected result from file
expected = open(refTableFile).read().rstrip()
@@ -562,9 +511,6 @@ def test_zebra_ipv4_routingTable():
# now fix newlines of expected (make them all the same)
expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1)
- # Add missing comma before label (for old version)
- actual = re.sub(r"([0-9]) label ", r"\1, label ", actual)
-
# Fix newlines (make them all the same)
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
@@ -594,7 +540,6 @@ def test_zebra_ipv4_routingTable():
def test_mpls_table():
global fatal_error
global net
- global cli_version
# Skip if previous fatal error condition is raised
if (fatal_error != ""):
@@ -607,23 +552,16 @@ def test_mpls_table():
print("******************************************\n")
failures = 0
- version = cli_version
- if (version == ""):
- # check for new output without implicit-null
- output = net['r1'].cmd('vtysh -c "show mpls table" 2> /dev/null').rstrip()
- if 'LDP 10.0.1.2 3' in output:
- version = "-no-impl-null"
-
for i in range(1, 5):
- refTableFile = '%s/r%s/show_mpls_table.ref%s' % (thisDir, i, version)
+ refTableFile = '%s/r%s/show_mpls_table.ref'
if os.path.isfile(refTableFile):
# Read expected result from file
- expected = open(refTableFile).read().rstrip()
+ expected = open(refTableFile).read()
# Fix newlines (make them all the same)
expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1)
# Actual output from router
- actual = net['r%s' % i].cmd('vtysh -c "show mpls table" 2> /dev/null').rstrip()
+ actual = net['r%s' % i].cmd('vtysh -c "show mpls table" 2> /dev/null')
# Fix inconsistent Label numbers at beginning of line
actual = re.sub(r"(\s+)[0-9]+(\s+LDP)", r"\1XX\2", actual)
@@ -672,7 +610,6 @@ def test_mpls_table():
def test_linux_mpls_routes():
global fatal_error
global net
- global cli_version
# Skip if previous fatal error condition is raised
if (fatal_error != ""):
diff --git a/tests/topotests/ospf-sr-topo1/r1/zebra_mpls.json b/tests/topotests/ospf-sr-topo1/r1/zebra_mpls.json
index 254c137acd..6b1fe76b6e 100644
--- a/tests/topotests/ospf-sr-topo1/r1/zebra_mpls.json
+++ b/tests/topotests/ospf-sr-topo1/r1/zebra_mpls.json
@@ -4,7 +4,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
@@ -17,7 +17,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
@@ -30,7 +30,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":8300,
"distance":150,
"installed":true,
@@ -43,7 +43,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":8400,
"distance":150,
"installed":true,
@@ -56,7 +56,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
@@ -69,7 +69,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
diff --git a/tests/topotests/ospf-sr-topo1/r2/zebra_mpls.json b/tests/topotests/ospf-sr-topo1/r2/zebra_mpls.json
index 0d73a409ed..79965d280a 100644
--- a/tests/topotests/ospf-sr-topo1/r2/zebra_mpls.json
+++ b/tests/topotests/ospf-sr-topo1/r2/zebra_mpls.json
@@ -4,7 +4,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":20100,
"distance":150,
"installed":true,
@@ -17,7 +17,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
@@ -30,7 +30,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":10400,
"distance":150,
"installed":true,
@@ -43,7 +43,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
@@ -56,7 +56,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
@@ -69,7 +69,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
@@ -82,7 +82,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
@@ -95,7 +95,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
@@ -108,7 +108,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
diff --git a/tests/topotests/ospf-sr-topo1/r3/zebra_mpls.json b/tests/topotests/ospf-sr-topo1/r3/zebra_mpls.json
index b15f90afd1..ceb2f7a0e5 100644
--- a/tests/topotests/ospf-sr-topo1/r3/zebra_mpls.json
+++ b/tests/topotests/ospf-sr-topo1/r3/zebra_mpls.json
@@ -4,7 +4,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":8100,
"distance":150,
"installed":true,
@@ -17,7 +17,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
@@ -30,7 +30,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":8400,
"distance":150,
"installed":true,
@@ -43,7 +43,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
@@ -56,7 +56,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
diff --git a/tests/topotests/ospf-sr-topo1/r4/zebra_mpls.json b/tests/topotests/ospf-sr-topo1/r4/zebra_mpls.json
index d1238517f5..d7f54b224d 100644
--- a/tests/topotests/ospf-sr-topo1/r4/zebra_mpls.json
+++ b/tests/topotests/ospf-sr-topo1/r4/zebra_mpls.json
@@ -4,7 +4,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":8100,
"distance":150,
"installed":true,
@@ -17,7 +17,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
@@ -30,7 +30,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":8300,
"distance":150,
"installed":true,
@@ -43,7 +43,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
@@ -56,7 +56,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
@@ -69,7 +69,7 @@
"installed":true,
"nexthops":[
{
- "type":"SR",
+ "type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
diff --git a/tests/topotests/pytest.ini b/tests/topotests/pytest.ini
index ade5bfd501..b65f93856f 100644
--- a/tests/topotests/pytest.ini
+++ b/tests/topotests/pytest.ini
@@ -1,6 +1,6 @@
# Skip pytests example directory
[pytest]
-norecursedirs = .git example-test example-topojson-test lib docker
+norecursedirs = .git example-test example-topojson-test lib docker bgp-ecmp-topo2
[topogen]
# Default configuration values
diff --git a/yang/libyang_plugins/frr_user_types.c b/yang/libyang_plugins/frr_user_types.c
index 4814f5bc1d..a293c3a883 100644
--- a/yang/libyang_plugins/frr_user_types.c
+++ b/yang/libyang_plugins/frr_user_types.c
@@ -20,6 +20,7 @@
#include <zebra.h>
#include "prefix.h"
+#include "ipaddr.h"
#include <libyang/user_types.h>
@@ -53,6 +54,21 @@ static int ipv6_address_store_clb(const char *type_name, const char *value_str,
return 0;
}
+static int ip_address_store_clb(const char *type_name, const char *value_str,
+ lyd_val *value, char **err_msg)
+{
+ value->ptr = malloc(sizeof(struct ipaddr));
+ if (!value->ptr)
+ return 1;
+
+ if (str2ipaddr(value_str, value->ptr)) {
+ free(value->ptr);
+ return 1;
+ }
+
+ return 0;
+}
+
static int ipv4_prefix_store_clb(const char *type_name, const char *value_str,
lyd_val *value, char **err_msg)
{
@@ -92,6 +108,8 @@ struct lytype_plugin_list frr_user_types[] = {
ipv6_address_store_clb, free},
{"ietf-inet-types", "2013-07-15", "ipv6-address-no-zone",
ipv6_address_store_clb, free},
+ {"ietf-inet-types", "2013-07-15", "ip-address", ip_address_store_clb,
+ free},
{"ietf-inet-types", "2013-07-15", "ipv4-prefix", ipv4_prefix_store_clb,
free},
{"ietf-inet-types", "2013-07-15", "ipv6-prefix", ipv6_prefix_store_clb,
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index fa6a2f62ec..826d31ef37 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -1749,88 +1749,146 @@ static void zread_vrf_unregister(ZAPI_HANDLER_ARGS)
vrf_bitmap_unset(client->ridinfo, zvrf_id(zvrf));
}
-static void zread_mpls_labels(ZAPI_HANDLER_ARGS)
+/*
+ * Handle request to create an MPLS LSP.
+ *
+ * A single message can fully specify an LSP with multiple nexthops.
+ *
+ * When the optional ZAPI_LABELS_FTN flag is set, the specified FEC (route) is
+ * updated to use the received label(s).
+ */
+static void zread_mpls_labels_add(ZAPI_HANDLER_ARGS)
{
struct stream *s;
- enum lsp_types_t type;
- struct prefix prefix;
- enum nexthop_types_t gtype;
- union g_addr gate;
- ifindex_t ifindex;
- mpls_label_t in_label, out_label;
- uint8_t distance;
+ struct zapi_labels zl;
/* Get input stream. */
s = msg;
+ if (zapi_labels_decode(s, &zl) < 0) {
+ if (IS_ZEBRA_DEBUG_RECV)
+ zlog_debug("%s: Unable to decode zapi_labels sent",
+ __PRETTY_FUNCTION__);
+ return;
+ }
- /* Get data. */
- STREAM_GETC(s, type);
- STREAM_GETL(s, prefix.family);
- switch (prefix.family) {
- case AF_INET:
- STREAM_GET(&prefix.u.prefix4.s_addr, s, IPV4_MAX_BYTELEN);
- STREAM_GETC(s, prefix.prefixlen);
- if (prefix.prefixlen > IPV4_MAX_BITLEN) {
- zlog_debug(
- "%s: Specified prefix length %d is greater than a v4 address can support",
- __PRETTY_FUNCTION__, prefix.prefixlen);
- return;
- }
- STREAM_GET(&gate.ipv4.s_addr, s, IPV4_MAX_BYTELEN);
- break;
- case AF_INET6:
- STREAM_GET(&prefix.u.prefix6, s, 16);
- STREAM_GETC(s, prefix.prefixlen);
- if (prefix.prefixlen > IPV6_MAX_BITLEN) {
- zlog_debug(
- "%s: Specified prefix length %d is greater than a v6 address can support",
- __PRETTY_FUNCTION__, prefix.prefixlen);
- return;
- }
- STREAM_GET(&gate.ipv6, s, 16);
- break;
- default:
- zlog_debug("%s: Specified AF %d is not supported for this call",
- __PRETTY_FUNCTION__, prefix.family);
+ if (!mpls_enabled)
return;
+
+ for (int i = 0; i < zl.nexthop_num; i++) {
+ struct zapi_nexthop_label *znh;
+
+ znh = &zl.nexthops[i];
+ mpls_lsp_install(zvrf, zl.type, zl.local_label, znh->label,
+ znh->type, &znh->address, znh->ifindex);
+
+ if (CHECK_FLAG(zl.message, ZAPI_LABELS_FTN))
+ mpls_ftn_update(1, zvrf, zl.type, &zl.route.prefix,
+ znh->type, &znh->address, znh->ifindex,
+ zl.route.type, zl.route.instance,
+ znh->label);
}
- STREAM_GETL(s, ifindex);
- STREAM_GETC(s, distance);
- STREAM_GETL(s, in_label);
- STREAM_GETL(s, out_label);
+}
- switch (prefix.family) {
- case AF_INET:
- if (ifindex)
- gtype = NEXTHOP_TYPE_IPV4_IFINDEX;
- else
- gtype = NEXTHOP_TYPE_IPV4;
- break;
- case AF_INET6:
- if (ifindex)
- gtype = NEXTHOP_TYPE_IPV6_IFINDEX;
- else
- gtype = NEXTHOP_TYPE_IPV6;
- break;
- default:
+/*
+ * Handle request to delete an MPLS LSP.
+ *
+ * An LSP is identified by its type and local label. When the received message
+ * doesn't contain any nexthop, the whole LSP is deleted. Otherwise, only the
+ * listed LSP nexthops (aka NHLFEs) are deleted.
+ *
+ * When the optional ZAPI_LABELS_FTN flag is set, the labels of the specified
+ * FEC (route) nexthops are deleted.
+ */
+static void zread_mpls_labels_delete(ZAPI_HANDLER_ARGS)
+{
+ struct stream *s;
+ struct zapi_labels zl;
+
+ /* Get input stream. */
+ s = msg;
+ if (zapi_labels_decode(s, &zl) < 0) {
+ if (IS_ZEBRA_DEBUG_RECV)
+ zlog_debug("%s: Unable to decode zapi_labels sent",
+ __PRETTY_FUNCTION__);
return;
}
if (!mpls_enabled)
return;
- if (hdr->command == ZEBRA_MPLS_LABELS_ADD) {
- mpls_lsp_install(zvrf, type, in_label, out_label, gtype, &gate,
- ifindex);
- mpls_ftn_update(1, zvrf, type, &prefix, gtype, &gate, ifindex,
- distance, out_label);
- } else if (hdr->command == ZEBRA_MPLS_LABELS_DELETE) {
- mpls_lsp_uninstall(zvrf, type, in_label, gtype, &gate, ifindex);
- mpls_ftn_update(0, zvrf, type, &prefix, gtype, &gate, ifindex,
- distance, out_label);
+ if (zl.nexthop_num > 0) {
+ for (int i = 0; i < zl.nexthop_num; i++) {
+ struct zapi_nexthop_label *znh;
+
+ znh = &zl.nexthops[i];
+ mpls_lsp_uninstall(zvrf, zl.type, zl.local_label,
+ znh->type, &znh->address,
+ znh->ifindex);
+
+ if (CHECK_FLAG(zl.message, ZAPI_LABELS_FTN))
+ mpls_ftn_update(0, zvrf, zl.type,
+ &zl.route.prefix, znh->type,
+ &znh->address, znh->ifindex,
+ zl.route.type,
+ zl.route.instance, znh->label);
+ }
+ } else {
+ mpls_lsp_uninstall_all_vrf(zvrf, zl.type, zl.local_label);
+
+ if (CHECK_FLAG(zl.message, ZAPI_LABELS_FTN))
+ mpls_ftn_uninstall(zvrf, zl.type, &zl.route.prefix,
+ zl.route.type, zl.route.instance);
+ }
+}
+
+/*
+ * Handle request to add an MPLS LSP or change an existing one.
+ *
+ * A single message can fully specify an LSP with multiple nexthops.
+ *
+ * When the optional ZAPI_LABELS_FTN flag is set, the specified FEC (route) is
+ * updated to use the received label(s).
+ *
+ * NOTE: zebra will use route replace semantics (make-before-break) to update
+ * the LSP in the forwarding plane if that's supported by the underlying
+ * platform.
+ */
+static void zread_mpls_labels_replace(ZAPI_HANDLER_ARGS)
+{
+ struct stream *s;
+ struct zapi_labels zl;
+
+ /* Get input stream. */
+ s = msg;
+ if (zapi_labels_decode(s, &zl) < 0) {
+ if (IS_ZEBRA_DEBUG_RECV)
+ zlog_debug("%s: Unable to decode zapi_labels sent",
+ __PRETTY_FUNCTION__);
+ return;
+ }
+
+ if (!mpls_enabled)
+ return;
+
+ mpls_lsp_uninstall_all_vrf(zvrf, zl.type, zl.local_label);
+ if (CHECK_FLAG(zl.message, ZAPI_LABELS_FTN))
+ mpls_ftn_uninstall(zvrf, zl.type, &zl.route.prefix,
+ zl.route.type, zl.route.instance);
+
+ for (int i = 0; i < zl.nexthop_num; i++) {
+ struct zapi_nexthop_label *znh;
+
+ znh = &zl.nexthops[i];
+ mpls_lsp_install(zvrf, zl.type, zl.local_label, znh->label,
+ znh->type, &znh->address, znh->ifindex);
+
+ if (CHECK_FLAG(zl.message, ZAPI_LABELS_FTN)) {
+ mpls_ftn_update(1, zvrf, zl.type, &zl.route.prefix,
+ znh->type, &znh->address, znh->ifindex,
+ zl.route.type, zl.route.instance,
+ znh->label);
+ }
}
-stream_failure:
- return;
}
/* Send response to a table manager connect request to client */
@@ -2455,8 +2513,9 @@ void (*zserv_handlers[])(ZAPI_HANDLER_ARGS) = {
[ZEBRA_INTERFACE_ENABLE_RADV] = NULL,
[ZEBRA_INTERFACE_DISABLE_RADV] = NULL,
#endif
- [ZEBRA_MPLS_LABELS_ADD] = zread_mpls_labels,
- [ZEBRA_MPLS_LABELS_DELETE] = zread_mpls_labels,
+ [ZEBRA_MPLS_LABELS_ADD] = zread_mpls_labels_add,
+ [ZEBRA_MPLS_LABELS_DELETE] = zread_mpls_labels_delete,
+ [ZEBRA_MPLS_LABELS_REPLACE] = zread_mpls_labels_replace,
[ZEBRA_IPMR_ROUTE_STATS] = zebra_ipmr_route_stats,
[ZEBRA_LABEL_MANAGER_CONNECT] = zread_label_manager_request,
[ZEBRA_LABEL_MANAGER_CONNECT_ASYNC] = zread_label_manager_request,
diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c
index 5214f1f22d..3c4497ebd2 100644
--- a/zebra/zebra_mpls.c
+++ b/zebra/zebra_mpls.c
@@ -34,6 +34,7 @@
#include "routemap.h"
#include "stream.h"
#include "nexthop.h"
+#include "termtable.h"
#include "lib/json.h"
#include "zebra/rib.h"
@@ -124,6 +125,9 @@ static zebra_snhlfe_t *snhlfe_add(zebra_slsp_t *slsp,
static int snhlfe_del(zebra_snhlfe_t *snhlfe);
static int snhlfe_del_all(zebra_slsp_t *slsp);
static char *snhlfe2str(zebra_snhlfe_t *snhlfe, char *buf, int size);
+static void mpls_lsp_uninstall_all_type(struct hash_bucket *bucket, void *ctxt);
+static void mpls_ftn_uninstall_all(struct zebra_vrf *zvrf,
+ int afi, enum lsp_types_t lsp_type);
/* Static functions */
@@ -1111,6 +1115,7 @@ static char *nhlfe2str(zebra_nhlfe_t *nhlfe, char *buf, int size)
inet_ntop(AF_INET, &nexthop->gate.ipv4, buf, size);
break;
case NEXTHOP_TYPE_IPV6:
+ case NEXTHOP_TYPE_IPV6_IFINDEX:
inet_ntop(AF_INET6, &nexthop->gate.ipv6, buf, size);
break;
case NEXTHOP_TYPE_IFINDEX:
@@ -2294,6 +2299,40 @@ static int zebra_mpls_cleanup_fecs_for_client(struct zserv *client)
return 0;
}
+struct lsp_uninstall_args {
+ struct hash *lsp_table;
+ enum lsp_types_t type;
+};
+
+/*
+ * Cleanup MPLS labels registered by this client.
+ */
+static int zebra_mpls_cleanup_zclient_labels(struct zserv *client)
+{
+ struct vrf *vrf;
+ struct zebra_vrf *zvrf;
+
+ RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) {
+ struct lsp_uninstall_args args;
+
+ zvrf = vrf->info;
+ if (!zvrf)
+ continue;
+
+ /* Cleanup LSPs. */
+ args.lsp_table = zvrf->lsp_table;
+ args.type = lsp_type_from_re_type(client->proto);
+ hash_iterate(zvrf->lsp_table, mpls_lsp_uninstall_all_type,
+ &args);
+
+ /* Cleanup FTNs. */
+ mpls_ftn_uninstall_all(zvrf, AFI_IP, client->proto);
+ mpls_ftn_uninstall_all(zvrf, AFI_IP6, client->proto);
+ }
+
+ return 0;
+}
+
/*
* Return FEC (if any) to which this label is bound.
* Note: Only works for per-prefix binding and when the label is not
@@ -2542,8 +2581,8 @@ static bool mpls_ftn_update_nexthop(int add, struct nexthop *nexthop,
*/
int mpls_ftn_update(int add, struct zebra_vrf *zvrf, enum lsp_types_t type,
struct prefix *prefix, enum nexthop_types_t gtype,
- union g_addr *gate, ifindex_t ifindex, uint8_t distance,
- mpls_label_t out_label)
+ union g_addr *gate, ifindex_t ifindex, uint8_t route_type,
+ unsigned short route_instance, mpls_label_t out_label)
{
struct route_table *table;
struct route_node *rn;
@@ -2562,7 +2601,7 @@ int mpls_ftn_update(int add, struct zebra_vrf *zvrf, enum lsp_types_t type,
RNODE_FOREACH_RE (rn, re) {
if (CHECK_FLAG(re->status, ROUTE_ENTRY_REMOVED))
continue;
- if (re->distance == distance)
+ if (re->type == route_type && re->instance == route_instance)
break;
}
@@ -2617,6 +2656,42 @@ int mpls_ftn_update(int add, struct zebra_vrf *zvrf, enum lsp_types_t type,
return 0;
}
+int mpls_ftn_uninstall(struct zebra_vrf *zvrf, enum lsp_types_t type,
+ struct prefix *prefix, uint8_t route_type,
+ unsigned short route_instance)
+{
+ struct route_table *table;
+ struct route_node *rn;
+ struct route_entry *re;
+ struct nexthop *nexthop;
+
+ /* Lookup table. */
+ table = zebra_vrf_table(family2afi(prefix->family), SAFI_UNICAST,
+ zvrf_id(zvrf));
+ if (!table)
+ return -1;
+
+ /* Lookup existing route */
+ rn = route_node_get(table, prefix);
+ RNODE_FOREACH_RE (rn, re) {
+ if (CHECK_FLAG(re->status, ROUTE_ENTRY_REMOVED))
+ continue;
+ if (re->type == route_type && re->instance == route_instance)
+ break;
+ }
+ if (re == NULL)
+ return -1;
+
+ for (nexthop = re->ng.nexthop; nexthop; nexthop = nexthop->next)
+ nexthop_del_labels(nexthop);
+
+ SET_FLAG(re->status, ROUTE_ENTRY_CHANGED);
+ SET_FLAG(re->status, ROUTE_ENTRY_LABELS_CHANGED);
+ rib_queue_add(rn);
+
+ return 0;
+}
+
/*
* Install/update a NHLFE for an LSP in the forwarding table. This may be
* a new LSP entry or a new NHLFE for an existing in-label or an update of
@@ -2749,12 +2824,34 @@ int mpls_lsp_uninstall(struct zebra_vrf *zvrf, enum lsp_types_t type,
return 0;
}
+int mpls_lsp_uninstall_all_vrf(struct zebra_vrf *zvrf, enum lsp_types_t type,
+ mpls_label_t in_label)
+{
+ struct hash *lsp_table;
+ zebra_ile_t tmp_ile;
+ zebra_lsp_t *lsp;
+
+ /* Lookup table. */
+ lsp_table = zvrf->lsp_table;
+ if (!lsp_table)
+ return -1;
+
+ /* If entry is not present, exit. */
+ tmp_ile.in_label = in_label;
+ lsp = hash_lookup(lsp_table, &tmp_ile);
+ if (!lsp)
+ return 0;
+
+ return mpls_lsp_uninstall_all(lsp_table, lsp, type);
+}
+
/*
- * Uninstall all LDP NHLFEs for a particular LSP forwarding entry.
+ * Uninstall all NHLFEs for a particular LSP forwarding entry.
* If no other NHLFEs exist, the entry would be deleted.
*/
-void mpls_ldp_lsp_uninstall_all(struct hash_bucket *bucket, void *ctxt)
+static void mpls_lsp_uninstall_all_type(struct hash_bucket *bucket, void *ctxt)
{
+ struct lsp_uninstall_args *args = ctxt;
zebra_lsp_t *lsp;
struct hash *lsp_table;
@@ -2762,17 +2859,19 @@ void mpls_ldp_lsp_uninstall_all(struct hash_bucket *bucket, void *ctxt)
if (!lsp->nhlfe_list)
return;
- lsp_table = ctxt;
+ lsp_table = args->lsp_table;
if (!lsp_table)
return;
- mpls_lsp_uninstall_all(lsp_table, lsp, ZEBRA_LSP_LDP);
+ mpls_lsp_uninstall_all(lsp_table, lsp, args->type);
}
/*
- * Uninstall all LDP FEC-To-NHLFE (FTN) bindings of the given address-family.
+ * Uninstall all FEC-To-NHLFE (FTN) bindings of the given address-family and
+ * LSP type.
*/
-void mpls_ldp_ftn_uninstall_all(struct zebra_vrf *zvrf, int afi)
+static void mpls_ftn_uninstall_all(struct zebra_vrf *zvrf,
+ int afi, enum lsp_types_t lsp_type)
{
struct route_table *table;
struct route_node *rn;
@@ -2790,7 +2889,7 @@ void mpls_ldp_ftn_uninstall_all(struct zebra_vrf *zvrf, int afi)
RNODE_FOREACH_RE (rn, re) {
for (nexthop = re->ng.nexthop; nexthop;
nexthop = nexthop->next) {
- if (nexthop->nh_label_type != ZEBRA_LSP_LDP)
+ if (nexthop->nh_label_type != lsp_type)
continue;
nexthop_del_labels(nexthop);
@@ -3047,7 +3146,6 @@ void zebra_mpls_print_lsp_table(struct vty *vty, struct zebra_vrf *zvrf,
json_object *json = NULL;
zebra_lsp_t *lsp = NULL;
zebra_nhlfe_t *nhlfe = NULL;
- struct nexthop *nexthop = NULL;
struct listnode *node = NULL;
struct list *lsp_list = hash_get_sorted_list(zvrf->lsp_table, lsp_cmp);
@@ -3063,15 +3161,23 @@ void zebra_mpls_print_lsp_table(struct vty *vty, struct zebra_vrf *zvrf,
json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else {
- vty_out(vty, " Inbound Outbound\n");
- vty_out(vty, " Label Type Nexthop Label\n");
- vty_out(vty, "-------- ------- --------------- --------\n");
+ struct ttable *tt;
+
+ /* Prepare table. */
+ tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
+ ttable_add_row(tt, "Inbound Label|Type|Nexthop|Outbound Label");
+ tt->style.cell.rpad = 2;
+ tt->style.corner = '+';
+ ttable_restyle(tt);
+ ttable_rowseps(tt, 0, BOTTOM, true, '-');
for (ALL_LIST_ELEMENTS_RO(lsp_list, node, lsp)) {
for (nhlfe = lsp->nhlfe_list; nhlfe;
nhlfe = nhlfe->next) {
- vty_out(vty, "%8d %7s ", lsp->ile.in_label,
- nhlfe_type2str(nhlfe->type));
+ struct nexthop *nexthop;
+ const char *out_label_str;
+ char nh_buf[NEXTHOP_STRLEN];
+
nexthop = nhlfe->nexthop;
switch (nexthop->type) {
@@ -3081,45 +3187,47 @@ void zebra_mpls_print_lsp_table(struct vty *vty, struct zebra_vrf *zvrf,
zns = zebra_ns_lookup(NS_DEFAULT);
ifp = if_lookup_by_index_per_ns(
- zns,
- nexthop->ifindex);
- if (ifp)
- vty_out(vty, "%15s", ifp->name);
- else
- vty_out(vty, "%15s", "Null");
-
+ zns, nexthop->ifindex);
+ snprintf(nh_buf, sizeof(nh_buf), "%s",
+ ifp ? ifp->name : "Null");
break;
}
case NEXTHOP_TYPE_IPV4:
case NEXTHOP_TYPE_IPV4_IFINDEX:
- vty_out(vty, "%15s",
- inet_ntoa(nexthop->gate.ipv4));
+ inet_ntop(AF_INET, &nexthop->gate.ipv4,
+ nh_buf, sizeof(nh_buf));
break;
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
- vty_out(vty, "%15s",
- inet_ntop(AF_INET6,
- &nexthop->gate.ipv6,
- buf, BUFSIZ));
+ inet_ntop(AF_INET6, &nexthop->gate.ipv6,
+ nh_buf, sizeof(nh_buf));
break;
default:
break;
}
if (nexthop->type != NEXTHOP_TYPE_IFINDEX)
- vty_out(vty, " %8s\n",
- mpls_label2str(
- nexthop->nh_label
- ->num_labels,
- &nexthop->nh_label
- ->label[0],
- buf, BUFSIZ, 1));
+ out_label_str = mpls_label2str(
+ nexthop->nh_label->num_labels,
+ &nexthop->nh_label->label[0],
+ buf, BUFSIZ, 1);
else
- vty_out(vty, "\n");
+ out_label_str = "-";
+
+ ttable_add_row(tt, "%u|%s|%s|%s",
+ lsp->ile.in_label,
+ nhlfe_type2str(nhlfe->type),
+ nh_buf, out_label_str);
}
}
- vty_out(vty, "\n");
+ /* Dump the generated table. */
+ if (tt->nrows > 1) {
+ char *table = ttable_dump(tt, "\n");
+ vty_out(vty, "%s\n", table);
+ XFREE(MTYPE_TMP, table);
+ }
+ ttable_del(tt);
}
list_delete(&lsp_list);
@@ -3289,4 +3397,5 @@ void zebra_mpls_init(void)
mpls_enabled = 1;
hook_register(zserv_client_close, zebra_mpls_cleanup_fecs_for_client);
+ hook_register(zserv_client_close, zebra_mpls_cleanup_zclient_labels);
}
diff --git a/zebra/zebra_mpls.h b/zebra/zebra_mpls.h
index d983221cb5..157f43ca98 100644
--- a/zebra/zebra_mpls.h
+++ b/zebra/zebra_mpls.h
@@ -269,8 +269,15 @@ void zebra_mpls_print_fec(struct vty *vty, struct zebra_vrf *zvrf,
*/
int mpls_ftn_update(int add, struct zebra_vrf *zvrf, enum lsp_types_t type,
struct prefix *prefix, enum nexthop_types_t gtype,
- union g_addr *gate, ifindex_t ifindex, uint8_t distance,
- mpls_label_t out_label);
+ union g_addr *gate, ifindex_t ifindex, uint8_t route_type,
+ unsigned short route_instance, mpls_label_t out_label);
+
+/*
+ * Uninstall all NHLFEs bound to a single FEC.
+ */
+int mpls_ftn_uninstall(struct zebra_vrf *zvrf, enum lsp_types_t type,
+ struct prefix *prefix, uint8_t route_type,
+ unsigned short route_instance);
/*
* Install/update a NHLFE for an LSP in the forwarding table. This may be
@@ -291,15 +298,10 @@ int mpls_lsp_uninstall(struct zebra_vrf *zvrf, enum lsp_types_t type,
union g_addr *gate, ifindex_t ifindex);
/*
- * Uninstall all LDP NHLFEs for a particular LSP forwarding entry.
- * If no other NHLFEs exist, the entry would be deleted.
- */
-void mpls_ldp_lsp_uninstall_all(struct hash_bucket *bucket, void *ctxt);
-
-/*
- * Uninstall all LDP FEC-To-NHLFE (FTN) bindings of the given address-family.
+ * Uninstall all NHLFEs for a particular LSP forwarding entry.
*/
-void mpls_ldp_ftn_uninstall_all(struct zebra_vrf *zvrf, int afi);
+int mpls_lsp_uninstall_all_vrf(struct zebra_vrf *zvrf, enum lsp_types_t type,
+ mpls_label_t in_label);
/*
* Uninstall all Segment Routing NHLFEs for a particular LSP forwarding entry.
@@ -426,7 +428,7 @@ static inline uint8_t lsp_distance(enum lsp_types_t type)
return (route_distance(ZEBRA_ROUTE_BGP));
case ZEBRA_LSP_NONE:
case ZEBRA_LSP_SHARP:
- case ZEBRA_LSP_SR:
+ case ZEBRA_LSP_OSPF_SR:
return 150;
}
@@ -448,8 +450,12 @@ static inline enum lsp_types_t lsp_type_from_re_type(int re_type)
switch (re_type) {
case ZEBRA_ROUTE_STATIC:
return ZEBRA_LSP_STATIC;
+ case ZEBRA_ROUTE_LDP:
+ return ZEBRA_LSP_LDP;
case ZEBRA_ROUTE_BGP:
return ZEBRA_LSP_BGP;
+ case ZEBRA_ROUTE_OSPF:
+ return ZEBRA_LSP_OSPF_SR;
case ZEBRA_ROUTE_SHARP:
return ZEBRA_LSP_SHARP;
default:
@@ -469,7 +475,7 @@ static inline int re_type_from_lsp_type(enum lsp_types_t lsp_type)
return ZEBRA_ROUTE_LDP;
case ZEBRA_LSP_BGP:
return ZEBRA_ROUTE_BGP;
- case ZEBRA_LSP_SR:
+ case ZEBRA_LSP_OSPF_SR:
return ZEBRA_ROUTE_OSPF;
case ZEBRA_LSP_NONE:
return ZEBRA_ROUTE_KERNEL;
@@ -496,8 +502,8 @@ static inline const char *nhlfe_type2str(enum lsp_types_t lsp_type)
return "LDP";
case ZEBRA_LSP_BGP:
return "BGP";
- case ZEBRA_LSP_SR:
- return "SR";
+ case ZEBRA_LSP_OSPF_SR:
+ return "SR (OSPF)";
case ZEBRA_LSP_SHARP:
return "SHARP";
case ZEBRA_LSP_NONE:
diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c
index 666ebb70e8..bcaf1b5204 100644
--- a/zebra/zebra_rnh.c
+++ b/zebra/zebra_rnh.c
@@ -1198,13 +1198,6 @@ static int zebra_client_cleanup_rnh(struct zserv *client)
RNH_IMPORT_CHECK_TYPE);
zebra_cleanup_rnh_client(zvrf_id(zvrf), AFI_IP6, client,
RNH_IMPORT_CHECK_TYPE);
- if (client->proto == ZEBRA_ROUTE_LDP) {
- hash_iterate(zvrf->lsp_table,
- mpls_ldp_lsp_uninstall_all,
- zvrf->lsp_table);
- mpls_ldp_ftn_uninstall_all(zvrf, AFI_IP);
- mpls_ldp_ftn_uninstall_all(zvrf, AFI_IP6);
- }
}
}