mirror of
https://gitlab.labs.nic.cz/labs/bird.git
synced 2024-05-11 16:54:54 +00:00
Merge commit 'f2e725a76882ba6b75c3ce4fb3c760bd83462410' into haugesund
This commit is contained in:
@@ -980,15 +980,18 @@ bgp_apply_next_hop(struct bgp_parse_state *s, rta *a, ip_addr gw, ip_addr ll)
|
||||
s->hostentry = rt_get_hostentry(tab, gw, ll, c->c.table);
|
||||
|
||||
if (!s->mpls)
|
||||
rta_apply_hostentry(a, s->hostentry, NULL);
|
||||
rta_apply_hostentry(a, s->hostentry);
|
||||
|
||||
/* With MPLS, hostentry is applied later in bgp_apply_mpls_labels() */
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
bgp_apply_mpls_labels(struct bgp_parse_state *s, rta *a, u32 *labels, uint lnum)
|
||||
bgp_apply_mpls_labels(struct bgp_parse_state *s, rta *a)
|
||||
{
|
||||
u32 *labels = (u32 *) s->mpls_labels->data;
|
||||
u32 lnum = s->mpls_labels->length / sizeof(u32);
|
||||
|
||||
if (lnum > MPLS_MAX_LABEL_STACK)
|
||||
{
|
||||
REPORT("Too many MPLS labels ($u)", lnum);
|
||||
@@ -1001,7 +1004,7 @@ bgp_apply_mpls_labels(struct bgp_parse_state *s, rta *a, u32 *labels, uint lnum)
|
||||
|
||||
/* Handle implicit NULL as empty MPLS stack */
|
||||
if ((lnum == 1) && (labels[0] == BGP_MPLS_NULL))
|
||||
lnum = 0;
|
||||
lnum = s->mpls_labels->length = 0;
|
||||
|
||||
if (s->channel->cf->gw_mode == GW_DIRECT)
|
||||
{
|
||||
@@ -1009,13 +1012,7 @@ bgp_apply_mpls_labels(struct bgp_parse_state *s, rta *a, u32 *labels, uint lnum)
|
||||
memcpy(a->nh.label, labels, 4*lnum);
|
||||
}
|
||||
else /* GW_RECURSIVE */
|
||||
{
|
||||
mpls_label_stack ms;
|
||||
|
||||
ms.len = lnum;
|
||||
memcpy(ms.stack, labels, 4*lnum);
|
||||
rta_apply_hostentry(a, s->hostentry, &ms);
|
||||
}
|
||||
rta_apply_hostentry(a, s->hostentry);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1419,7 +1416,13 @@ bgp_encode_mpls_labels(struct bgp_write_state *s UNUSED, const adata *mpls, byte
|
||||
static void
|
||||
bgp_decode_mpls_labels(struct bgp_parse_state *s, byte **pos, uint *len, uint *pxlen, rta *a)
|
||||
{
|
||||
u32 labels[BGP_MPLS_MAX], label;
|
||||
struct {
|
||||
struct adata ad;
|
||||
u32 labels[BGP_MPLS_MAX];
|
||||
} labels_adata;
|
||||
|
||||
u32 *labels = labels_adata.labels;
|
||||
u32 label;
|
||||
uint lnum = 0;
|
||||
|
||||
do {
|
||||
@@ -1441,19 +1444,19 @@ bgp_decode_mpls_labels(struct bgp_parse_state *s, byte **pos, uint *len, uint *p
|
||||
if (!a)
|
||||
return;
|
||||
|
||||
labels_adata.ad.length = lnum * sizeof(u32);
|
||||
|
||||
/* Attach MPLS attribute unless we already have one */
|
||||
if (!s->mpls_labels)
|
||||
{
|
||||
s->mpls_labels = lp_alloc_adata(s->pool, 4*BGP_MPLS_MAX);
|
||||
bgp_set_attr_ptr(&(a->eattrs), BA_MPLS_LABEL_STACK, 0, s->mpls_labels);
|
||||
}
|
||||
|
||||
/* Overwrite data in the attribute */
|
||||
s->mpls_labels->length = 4*lnum;
|
||||
memcpy(s->mpls_labels->data, labels, 4*lnum);
|
||||
ea_set_attr(&(a->eattrs),
|
||||
EA_LITERAL_DIRECT_ADATA(&ea_mpls_labels, 0,
|
||||
(s->mpls_labels = tmp_store_adata(labels, BGP_MPLS_MAX * sizeof(u32)))));
|
||||
else
|
||||
/* Overwrite data in the attribute */
|
||||
memcpy(s->mpls_labels, &labels_adata, sizeof labels_adata);
|
||||
|
||||
/* Update next hop entry in rta */
|
||||
bgp_apply_mpls_labels(s, a, labels, lnum);
|
||||
bgp_apply_mpls_labels(s, a);
|
||||
|
||||
/* Attributes were changed, invalidate cached entry */
|
||||
rta_free(s->cached_rta);
|
||||
|
||||
@@ -76,8 +76,8 @@ static_announce_rte(struct static_proto *p, struct static_route *r)
|
||||
nh->weight = r2->weight;
|
||||
if (r2->mls)
|
||||
{
|
||||
nh->labels = r2->mls->len;
|
||||
memcpy(nh->label, r2->mls->stack, r2->mls->len * sizeof(u32));
|
||||
nh->labels = r2->mls->length / sizeof(u32);
|
||||
memcpy(nh->label, r2->mls->data, r2->mls->length);
|
||||
}
|
||||
|
||||
nexthop_insert(&nhs, nh);
|
||||
@@ -92,7 +92,11 @@ static_announce_rte(struct static_proto *p, struct static_route *r)
|
||||
if (r->dest == RTDX_RECURSIVE)
|
||||
{
|
||||
rtable *tab = ipa_is_ip4(r->via) ? p->igp_table_ip4 : p->igp_table_ip6;
|
||||
rta_set_recursive_next_hop(p->p.main_channel->table, a, tab, r->via, IPA_NONE, r->mls);
|
||||
if (r->mls)
|
||||
ea_set_attr(&a->eattrs,
|
||||
EA_LITERAL_DIRECT_ADATA(&ea_mpls_labels, 0, r->mls));
|
||||
|
||||
rta_set_recursive_next_hop(p->p.main_channel->table, a, tab, r->via, IPA_NONE);
|
||||
}
|
||||
|
||||
/* Already announced */
|
||||
@@ -303,31 +307,17 @@ static_same_dest(struct static_route *x, struct static_route *y)
|
||||
(x->weight != y->weight) ||
|
||||
(x->use_bfd != y->use_bfd) ||
|
||||
(!x->mls != !y->mls) ||
|
||||
((x->mls) && (y->mls) && (x->mls->len != y->mls->len)))
|
||||
((x->mls) && (y->mls) && adata_same(x->mls, y->mls)))
|
||||
return 0;
|
||||
|
||||
if (!x->mls)
|
||||
continue;
|
||||
|
||||
for (uint i = 0; i < x->mls->len; i++)
|
||||
if (x->mls->stack[i] != y->mls->stack[i])
|
||||
return 0;
|
||||
}
|
||||
return !x && !y;
|
||||
|
||||
case RTDX_RECURSIVE:
|
||||
if (!ipa_equal(x->via, y->via) ||
|
||||
(!x->mls != !y->mls) ||
|
||||
((x->mls) && (y->mls) && (x->mls->len != y->mls->len)))
|
||||
((x->mls) && (y->mls) && adata_same(x->mls, y->mls)))
|
||||
return 0;
|
||||
|
||||
if (!x->mls)
|
||||
return 1;
|
||||
|
||||
for (uint i = 0; i < x->mls->len; i++)
|
||||
if (x->mls->stack[i] != y->mls->stack[i])
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
|
||||
default:
|
||||
|
||||
@@ -49,7 +49,7 @@ struct static_route {
|
||||
byte weight; /* Multipath next hop weight */
|
||||
byte use_bfd; /* Configured to use BFD */
|
||||
struct bfd_request *bfd_req; /* BFD request, if BFD is used */
|
||||
mpls_label_stack *mls; /* MPLS label stack; may be NULL */
|
||||
struct adata *mls; /* MPLS label stack; may be NULL */
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user