mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 23:53:28 +00:00
zebra: include backup nexthops for pseudowires
Include any installed backup nexthops when installing pseudowires; include installed backups in vty and json pw show output. Signed-off-by: Mark Stapp <mjs@voltanet.io>
This commit is contained in:
parent
3c0e16228d
commit
8b117ff02b
@ -2116,6 +2116,12 @@ static int dplane_ctx_pw_init(struct zebra_dplane_ctx *ctx,
|
|||||||
if (nhg && nhg->nexthop)
|
if (nhg && nhg->nexthop)
|
||||||
copy_nexthops(&(ctx->u.pw.nhg.nexthop),
|
copy_nexthops(&(ctx->u.pw.nhg.nexthop),
|
||||||
nhg->nexthop, NULL);
|
nhg->nexthop, NULL);
|
||||||
|
|
||||||
|
/* Include any installed backup nexthops */
|
||||||
|
nhg = rib_get_fib_backup_nhg(re);
|
||||||
|
if (nhg && nhg->nexthop)
|
||||||
|
copy_nexthops(&(ctx->u.pw.nhg.nexthop),
|
||||||
|
nhg->nexthop, NULL);
|
||||||
}
|
}
|
||||||
route_unlock_node(rn);
|
route_unlock_node(rn);
|
||||||
}
|
}
|
||||||
|
@ -518,6 +518,7 @@ static void vty_show_mpls_pseudowire_detail(struct vty *vty)
|
|||||||
struct zebra_pw *pw;
|
struct zebra_pw *pw;
|
||||||
struct route_entry *re;
|
struct route_entry *re;
|
||||||
struct nexthop *nexthop;
|
struct nexthop *nexthop;
|
||||||
|
struct nexthop_group *nhg;
|
||||||
|
|
||||||
zvrf = vrf_info_lookup(VRF_DEFAULT);
|
zvrf = vrf_info_lookup(VRF_DEFAULT);
|
||||||
if (!zvrf)
|
if (!zvrf)
|
||||||
@ -549,8 +550,28 @@ static void vty_show_mpls_pseudowire_detail(struct vty *vty)
|
|||||||
: "Down");
|
: "Down");
|
||||||
re = rib_match(family2afi(pw->af), SAFI_UNICAST, pw->vrf_id,
|
re = rib_match(family2afi(pw->af), SAFI_UNICAST, pw->vrf_id,
|
||||||
&pw->nexthop, NULL);
|
&pw->nexthop, NULL);
|
||||||
if (re) {
|
if (re == NULL)
|
||||||
for (ALL_NEXTHOPS_PTR(rib_get_fib_nhg(re), nexthop)) {
|
continue;
|
||||||
|
|
||||||
|
nhg = rib_get_fib_nhg(re);
|
||||||
|
for (ALL_NEXTHOPS_PTR(nhg, nexthop)) {
|
||||||
|
snprintfrr(buf_nh, sizeof(buf_nh), "%pNHv",
|
||||||
|
nexthop);
|
||||||
|
vty_out(vty, " Next Hop: %s\n", buf_nh);
|
||||||
|
if (nexthop->nh_label)
|
||||||
|
vty_out(vty, " Next Hop label: %u\n",
|
||||||
|
nexthop->nh_label->label[0]);
|
||||||
|
else
|
||||||
|
vty_out(vty, " Next Hop label: %s\n",
|
||||||
|
"-");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Include any installed backups */
|
||||||
|
nhg = rib_get_fib_backup_nhg(re);
|
||||||
|
if (nhg == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (ALL_NEXTHOPS_PTR(nhg, nexthop)) {
|
||||||
snprintfrr(buf_nh, sizeof(buf_nh), "%pNHv",
|
snprintfrr(buf_nh, sizeof(buf_nh), "%pNHv",
|
||||||
nexthop);
|
nexthop);
|
||||||
vty_out(vty, " Next Hop: %s\n", buf_nh);
|
vty_out(vty, " Next Hop: %s\n", buf_nh);
|
||||||
@ -563,12 +584,12 @@ static void vty_show_mpls_pseudowire_detail(struct vty *vty)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void vty_show_mpls_pseudowire(struct zebra_pw *pw, json_object *json_pws)
|
static void vty_show_mpls_pseudowire(struct zebra_pw *pw, json_object *json_pws)
|
||||||
{
|
{
|
||||||
struct route_entry *re;
|
struct route_entry *re;
|
||||||
struct nexthop *nexthop;
|
struct nexthop *nexthop;
|
||||||
|
struct nexthop_group *nhg;
|
||||||
char buf_nbr[INET6_ADDRSTRLEN];
|
char buf_nbr[INET6_ADDRSTRLEN];
|
||||||
char buf_nh[100];
|
char buf_nh[100];
|
||||||
json_object *json_pw = NULL;
|
json_object *json_pw = NULL;
|
||||||
@ -603,8 +624,11 @@ static void vty_show_mpls_pseudowire(struct zebra_pw *pw, json_object *json_pws)
|
|||||||
: "Down");
|
: "Down");
|
||||||
re = rib_match(family2afi(pw->af), SAFI_UNICAST, pw->vrf_id,
|
re = rib_match(family2afi(pw->af), SAFI_UNICAST, pw->vrf_id,
|
||||||
&pw->nexthop, NULL);
|
&pw->nexthop, NULL);
|
||||||
if (re) {
|
if (re == NULL)
|
||||||
for (ALL_NEXTHOPS_PTR(rib_get_fib_nhg(re), nexthop)) {
|
goto done;
|
||||||
|
|
||||||
|
nhg = rib_get_fib_nhg(re);
|
||||||
|
for (ALL_NEXTHOPS_PTR(nhg, nexthop)) {
|
||||||
json_nexthop = json_object_new_object();
|
json_nexthop = json_object_new_object();
|
||||||
snprintfrr(buf_nh, sizeof(buf_nh), "%pNHv", nexthop);
|
snprintfrr(buf_nh, sizeof(buf_nh), "%pNHv", nexthop);
|
||||||
json_object_string_add(json_nexthop, "nexthop", buf_nh);
|
json_object_string_add(json_nexthop, "nexthop", buf_nh);
|
||||||
@ -618,8 +642,30 @@ static void vty_show_mpls_pseudowire(struct zebra_pw *pw, json_object *json_pws)
|
|||||||
|
|
||||||
json_object_array_add(json_nexthops, json_nexthop);
|
json_object_array_add(json_nexthops, json_nexthop);
|
||||||
}
|
}
|
||||||
json_object_object_add(json_pw, "nexthops", json_nexthops);
|
|
||||||
|
/* Include installed backup nexthops also */
|
||||||
|
nhg = rib_get_fib_backup_nhg(re);
|
||||||
|
if (nhg == NULL)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
for (ALL_NEXTHOPS_PTR(nhg, nexthop)) {
|
||||||
|
json_nexthop = json_object_new_object();
|
||||||
|
snprintfrr(buf_nh, sizeof(buf_nh), "%pNHv", nexthop);
|
||||||
|
json_object_string_add(json_nexthop, "nexthop", buf_nh);
|
||||||
|
if (nexthop->nh_label)
|
||||||
|
json_object_int_add(
|
||||||
|
json_nexthop, "nhLabel",
|
||||||
|
nexthop->nh_label->label[0]);
|
||||||
|
else
|
||||||
|
json_object_string_add(json_nexthop, "nhLabel",
|
||||||
|
"-");
|
||||||
|
|
||||||
|
json_object_array_add(json_nexthops, json_nexthop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
|
||||||
|
json_object_object_add(json_pw, "nexthops", json_nexthops);
|
||||||
json_object_array_add(json_pws, json_pw);
|
json_object_array_add(json_pws, json_pw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user