0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-01-15 21:41:56 +00:00

bmp at the moment we gave up sending routes

This commit is contained in:
Katerina Kubecova 2024-08-20 12:18:20 +02:00 committed by Maria Matejka
parent 1e6bc69502
commit ef2f4422e9
4 changed files with 23 additions and 6 deletions

View File

@ -80,6 +80,7 @@ static union bgp_attr_desc bgp_attr_table[];
static inline const union bgp_attr_desc *bgp_find_attr_desc(eattr *a) static inline const union bgp_attr_desc *bgp_find_attr_desc(eattr *a)
{ {
const struct ea_class *class = ea_class_find(a->id); const struct ea_class *class = ea_class_find(a->id);
//log("ea %x class %s", a, class->name);
if ((class < &bgp_attr_table[0].class) || (class >= &bgp_attr_table[BGP_ATTR_MAX].class)) if ((class < &bgp_attr_table[0].class) || (class >= &bgp_attr_table[BGP_ATTR_MAX].class))
return NULL; return NULL;

View File

@ -448,6 +448,8 @@ struct bgp_ptx_private {
slab *prefix_slab; /* Slab holding prefix nodes */ slab *prefix_slab; /* Slab holding prefix nodes */
slab *bucket_slab; /* Slab holding buckets to send */ slab *bucket_slab; /* Slab holding buckets to send */
char bmp; /* This is a fake ptx for BMP encoding */
}; };
typedef union bgp_ptx { typedef union bgp_ptx {

View File

@ -2332,10 +2332,12 @@ bgp_create_ip_reach(struct bgp_write_state *s, struct bgp_bucket *buck, byte *bu
return buf+4+la+lr; return buf+4+la+lr;
} }
static byte * static byte *
bgp_create_mp_reach(struct bgp_write_state *s, struct bgp_bucket *buck, byte *buf, byte *end) bgp_create_mp_reach(struct bgp_write_state *s, struct bgp_bucket *buck, byte *buf, byte *end)
{ {
ASSERT_DIE(s->ptx->withdraw_bucket != buck); log("in reach check there is no next hop %i", s->mp_next_hop);
ASSERT_DIE((s->ptx->bmp) || (s->ptx->withdraw_bucket != buck));
/* /*
* 2 B IPv4 Withdrawn Routes Length (zero) * 2 B IPv4 Withdrawn Routes Length (zero)
@ -2374,6 +2376,7 @@ bgp_create_mp_reach(struct bgp_write_state *s, struct bgp_bucket *buck, byte *bu
} }
/* Encode the next hop */ /* Encode the next hop */
log("before next hop fn check there is no next hop %i", s->mp_next_hop);
lh = bgp_encode_next_hop(s, s->mp_next_hop, pos+1); lh = bgp_encode_next_hop(s, s->mp_next_hop, pos+1);
*pos = lh; *pos = lh;
pos += 1+lh; pos += 1+lh;
@ -2420,6 +2423,7 @@ bgp_create_ip_unreach(struct bgp_write_state *s, struct bgp_bucket *buck, byte *
return buf+4+len; return buf+4+len;
} }
static byte * static byte *
bgp_create_mp_unreach(struct bgp_write_state *s, struct bgp_bucket *buck, byte *buf, byte *end) bgp_create_mp_unreach(struct bgp_write_state *s, struct bgp_bucket *buck, byte *buf, byte *end)
{ {
@ -2469,14 +2473,23 @@ bgp_create_update_bmp(ea_list *channel_ea, struct bgp_proto *bgp_p, byte *buf, s
struct bgp_caps *peer = bgp_p->conn->remote_caps; struct bgp_caps *peer = bgp_p->conn->remote_caps;
const struct bgp_af_caps *rem = bgp_find_af_caps(peer, c->afi); const struct bgp_af_caps *rem = bgp_find_af_caps(peer, c->afi);
struct bgp_ptx_private ptx = {
.bmp = 1,
.c = c,
};
struct bgp_write_state s = { struct bgp_write_state s = {
.proto = bgp_p, .proto = bgp_p,
.ptx = &ptx,
.pool = tmp_linpool, .pool = tmp_linpool,
.mp_reach = (c->afi != BGP_AF_IPV4) || rem->ext_next_hop, .mp_reach = (c->afi != BGP_AF_IPV4) || rem->ext_next_hop,
.as4_session = 1, .as4_session = 1,
.add_path = c->add_path_rx, .add_path = c->add_path_rx,
.mpls = c->desc->mpls, //this is problem, but we can have proto. What about find correct channel in proto? TODO .mpls = c->desc->mpls, //this is problem, but we can have proto. What about find correct channel in proto? TODO
.ignore_non_bgp_attrs = 1, // TODO this is... maybe logical, but the eattr, which forced me to write this, was nexthop.
}; };
log("check there is no next hop %i, channel fce %i", s.mp_next_hop, c->desc->encode_next_hop);
log("desc %x, bgp_af_desc bgp_af_table %x", c->desc, bgp_af_table);
if (!update) if (!update)
{ {
@ -2513,13 +2526,13 @@ bgp_bmp_encode_rte(ea_list *c, struct bgp_proto *bgp_p, byte *buf, const net_add
ea_list *attrs = new ? new->attrs : NULL; ea_list *attrs = new ? new->attrs : NULL;
uint ea_size = new ? (sizeof(ea_list) + attrs->count * sizeof(eattr)) : 0; uint ea_size = new ? (sizeof(ea_list) + attrs->count * sizeof(eattr)) : 0;
uint bucket_size = sizeof(struct bgp_bucket) + ea_size;
uint prefix_size = sizeof(struct bgp_prefix) + n->length; uint prefix_size = sizeof(struct bgp_prefix) + n->length;
struct lp_state *tmpp = lp_save(tmp_linpool); struct lp_state *tmpp = lp_save(tmp_linpool);
/* Temporary bucket */ /* Temporary bucket */
struct bgp_bucket *b = tmp_allocz(bucket_size); struct bgp_bucket *b = tmp_allocz(sizeof(struct bgp_bucket));
b->attrs = tmp_allocz(ea_size);
b->bmp = 1; b->bmp = 1;
init_list(&b->prefixes); init_list(&b->prefixes);

View File

@ -1047,10 +1047,11 @@ static void
bmp_rt_notify(struct proto *P, struct channel *c, const net_addr *net, bmp_rt_notify(struct proto *P, struct channel *c, const net_addr *net,
struct rte *new, const struct rte *old) struct rte *new, const struct rte *old)
{ {
struct bmp_proto *p = (void *) P; return; //TODO The next code is complete mess. It counts with both v2 and v3 functions, does respect only some changes in structs (and retype v3 structs with (void *) just because it was possible in v2), contains forgotten hacks how to make it compilable, uses journal eatters where they (at first or second glance) looked useful and do strange things in general.
struct bmp_proto *p = SKIP_BACK(struct bmp_proto, p, P);
struct bgp_channel *src = (void *) (new ?: old)->sender; struct bgp_channel *src = SKIP_BACK(struct bgp_channel, c.in_req, (new ?: old)->sender->req);
struct bgp_proto *bgp = (void *) src->c.proto; struct bgp_proto *bgp = SKIP_BACK(struct bgp_proto, p, src->c.proto);
bool policy = (c->table == src->c.table); bool policy = (c->table == src->c.table);
/* /*