mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-06-15 09:42:36 +00:00
Merge pull request #4849 from sworleys/Label-Append-Resolve_2
zebra: Append rparent labels when resolving nexthop
This commit is contained in:
commit
1cd89e8370
@ -1019,33 +1019,28 @@ static void _netlink_route_build_singlepath(const char *routedesc, int bytelen,
|
|||||||
label_buf[0] = '\0';
|
label_buf[0] = '\0';
|
||||||
|
|
||||||
assert(nexthop);
|
assert(nexthop);
|
||||||
for (const struct nexthop *nh = nexthop; nh; nh = nh->rparent) {
|
char label_buf1[20];
|
||||||
char label_buf1[20];
|
|
||||||
|
|
||||||
nh_label = nh->nh_label;
|
nh_label = nexthop->nh_label;
|
||||||
if (!nh_label || !nh_label->num_labels)
|
|
||||||
|
for (int i = 0; nh_label && i < nh_label->num_labels; i++) {
|
||||||
|
if (nh_label->label[i] == MPLS_LABEL_IMPLICIT_NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (int i = 0; i < nh_label->num_labels; i++) {
|
if (IS_ZEBRA_DEBUG_KERNEL) {
|
||||||
if (nh_label->label[i] == MPLS_LABEL_IMPLICIT_NULL)
|
if (!num_labels)
|
||||||
continue;
|
sprintf(label_buf, "label %u",
|
||||||
|
nh_label->label[i]);
|
||||||
if (IS_ZEBRA_DEBUG_KERNEL) {
|
else {
|
||||||
if (!num_labels)
|
sprintf(label_buf1, "/%u", nh_label->label[i]);
|
||||||
sprintf(label_buf, "label %u",
|
strlcat(label_buf, label_buf1,
|
||||||
nh_label->label[i]);
|
sizeof(label_buf));
|
||||||
else {
|
|
||||||
sprintf(label_buf1, "/%u",
|
|
||||||
nh_label->label[i]);
|
|
||||||
strlcat(label_buf, label_buf1,
|
|
||||||
sizeof(label_buf));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out_lse[num_labels] =
|
|
||||||
mpls_lse_encode(nh_label->label[i], 0, 0, 0);
|
|
||||||
num_labels++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out_lse[num_labels] =
|
||||||
|
mpls_lse_encode(nh_label->label[i], 0, 0, 0);
|
||||||
|
num_labels++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_labels) {
|
if (num_labels) {
|
||||||
@ -1210,33 +1205,28 @@ static void _netlink_route_build_multipath(const char *routedesc, int bytelen,
|
|||||||
label_buf[0] = '\0';
|
label_buf[0] = '\0';
|
||||||
|
|
||||||
assert(nexthop);
|
assert(nexthop);
|
||||||
for (const struct nexthop *nh = nexthop; nh; nh = nh->rparent) {
|
char label_buf1[20];
|
||||||
char label_buf1[20];
|
|
||||||
|
|
||||||
nh_label = nh->nh_label;
|
nh_label = nexthop->nh_label;
|
||||||
if (!nh_label || !nh_label->num_labels)
|
|
||||||
|
for (int i = 0; nh_label && i < nh_label->num_labels; i++) {
|
||||||
|
if (nh_label->label[i] == MPLS_LABEL_IMPLICIT_NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (int i = 0; i < nh_label->num_labels; i++) {
|
if (IS_ZEBRA_DEBUG_KERNEL) {
|
||||||
if (nh_label->label[i] == MPLS_LABEL_IMPLICIT_NULL)
|
if (!num_labels)
|
||||||
continue;
|
sprintf(label_buf, "label %u",
|
||||||
|
nh_label->label[i]);
|
||||||
if (IS_ZEBRA_DEBUG_KERNEL) {
|
else {
|
||||||
if (!num_labels)
|
sprintf(label_buf1, "/%u", nh_label->label[i]);
|
||||||
sprintf(label_buf, "label %u",
|
strlcat(label_buf, label_buf1,
|
||||||
nh_label->label[i]);
|
sizeof(label_buf));
|
||||||
else {
|
|
||||||
sprintf(label_buf1, "/%u",
|
|
||||||
nh_label->label[i]);
|
|
||||||
strlcat(label_buf, label_buf1,
|
|
||||||
sizeof(label_buf));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out_lse[num_labels] =
|
|
||||||
mpls_lse_encode(nh_label->label[i], 0, 0, 0);
|
|
||||||
num_labels++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out_lse[num_labels] =
|
||||||
|
mpls_lse_encode(nh_label->label[i], 0, 0, 0);
|
||||||
|
num_labels++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_labels) {
|
if (num_labels) {
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "lib/nexthop.h"
|
#include "lib/nexthop.h"
|
||||||
#include "lib/nexthop_group_private.h"
|
#include "lib/nexthop_group_private.h"
|
||||||
#include "lib/routemap.h"
|
#include "lib/routemap.h"
|
||||||
|
#include "lib/mpls.h"
|
||||||
|
|
||||||
#include "zebra/connected.h"
|
#include "zebra/connected.h"
|
||||||
#include "zebra/debug.h"
|
#include "zebra/debug.h"
|
||||||
@ -38,6 +39,10 @@ static void nexthop_set_resolved(afi_t afi, const struct nexthop *newhop,
|
|||||||
struct nexthop *nexthop)
|
struct nexthop *nexthop)
|
||||||
{
|
{
|
||||||
struct nexthop *resolved_hop;
|
struct nexthop *resolved_hop;
|
||||||
|
uint8_t num_labels = 0;
|
||||||
|
mpls_label_t labels[MPLS_MAX_LABELS];
|
||||||
|
enum lsp_types_t label_type = ZEBRA_LSP_NONE;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
resolved_hop = nexthop_new();
|
resolved_hop = nexthop_new();
|
||||||
SET_FLAG(resolved_hop->flags, NEXTHOP_FLAG_ACTIVE);
|
SET_FLAG(resolved_hop->flags, NEXTHOP_FLAG_ACTIVE);
|
||||||
@ -94,11 +99,24 @@ static void nexthop_set_resolved(afi_t afi, const struct nexthop *newhop,
|
|||||||
if (newhop->flags & NEXTHOP_FLAG_ONLINK)
|
if (newhop->flags & NEXTHOP_FLAG_ONLINK)
|
||||||
resolved_hop->flags |= NEXTHOP_FLAG_ONLINK;
|
resolved_hop->flags |= NEXTHOP_FLAG_ONLINK;
|
||||||
|
|
||||||
/* Copy labels of the resolved route */
|
/* Copy labels of the resolved route and the parent resolving to it */
|
||||||
if (newhop->nh_label)
|
if (newhop->nh_label) {
|
||||||
nexthop_add_labels(resolved_hop, newhop->nh_label_type,
|
for (i = 0; i < newhop->nh_label->num_labels; i++)
|
||||||
newhop->nh_label->num_labels,
|
labels[num_labels++] = newhop->nh_label->label[i];
|
||||||
&newhop->nh_label->label[0]);
|
label_type = newhop->nh_label_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nexthop->nh_label) {
|
||||||
|
for (i = 0; i < nexthop->nh_label->num_labels; i++)
|
||||||
|
labels[num_labels++] = nexthop->nh_label->label[i];
|
||||||
|
|
||||||
|
/* If the parent has labels, use its type */
|
||||||
|
label_type = nexthop->nh_label_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (num_labels)
|
||||||
|
nexthop_add_labels(resolved_hop, label_type, num_labels,
|
||||||
|
labels);
|
||||||
|
|
||||||
resolved_hop->rparent = nexthop;
|
resolved_hop->rparent = nexthop;
|
||||||
_nexthop_add(&nexthop->resolved, resolved_hop);
|
_nexthop_add(&nexthop->resolved, resolved_hop);
|
||||||
|
Loading…
Reference in New Issue
Block a user