mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2025-01-15 13:31:54 +00:00
rtes from bgp without bgp nexthop
This commit is contained in:
parent
c39c47d82c
commit
0b713e60c3
@ -80,11 +80,12 @@ 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);
|
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;
|
||||||
|
|
||||||
|
log("desc returned");
|
||||||
return (const union bgp_attr_desc *) class;
|
return (const union bgp_attr_desc *) class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -543,6 +544,7 @@ bgp_encode_next_hop(struct bgp_write_state *s, eattr *a, byte *buf, uint size)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
log("mp next hop set %x", a);
|
||||||
s->mp_next_hop = a;
|
s->mp_next_hop = a;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1210,6 +1212,7 @@ static union bgp_attr_desc bgp_attr_table[BGP_ATTR_MAX] = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
eattr *
|
eattr *
|
||||||
bgp_find_attr(ea_list *attrs, uint code)
|
bgp_find_attr(ea_list *attrs, uint code)
|
||||||
{
|
{
|
||||||
@ -1317,7 +1320,7 @@ bgp_export_attrs(struct bgp_export_state *s, ea_list *a)
|
|||||||
static inline int
|
static inline int
|
||||||
bgp_encode_attr(struct bgp_write_state *s, eattr *a, byte *buf, uint size)
|
bgp_encode_attr(struct bgp_write_state *s, eattr *a, byte *buf, uint size)
|
||||||
{
|
{
|
||||||
log("size %i", size);
|
log("size %i %x", size, a->type);
|
||||||
const union bgp_attr_desc *desc = bgp_find_attr_desc(a);
|
const union bgp_attr_desc *desc = bgp_find_attr_desc(a);
|
||||||
if (s->ignore_non_bgp_attrs == 0)
|
if (s->ignore_non_bgp_attrs == 0)
|
||||||
ASSERT_DIE(desc);
|
ASSERT_DIE(desc);
|
||||||
|
@ -2364,10 +2364,12 @@ bgp_create_mp_reach(struct bgp_write_state *s, struct bgp_bucket *buck, byte *bu
|
|||||||
put_u16(buf+6, 0); /* Will be fixed later */
|
put_u16(buf+6, 0); /* Will be fixed later */
|
||||||
put_af3(buf+8, s->ptx->c->afi);
|
put_af3(buf+8, s->ptx->c->afi);
|
||||||
byte *pos = buf+11;
|
byte *pos = buf+11;
|
||||||
|
log("in reach next hop %i", s->mp_next_hop);
|
||||||
|
|
||||||
/* Encode attributes to temporary buffer */
|
/* Encode attributes to temporary buffer */
|
||||||
byte *abuf = alloca(MAX_ATTRS_LENGTH);
|
byte *abuf = alloca(MAX_ATTRS_LENGTH);
|
||||||
la = bgp_encode_attrs(s, buck->eattrs, abuf, abuf + MAX_ATTRS_LENGTH);
|
la = bgp_encode_attrs(s, buck->eattrs, abuf, abuf + MAX_ATTRS_LENGTH);
|
||||||
|
log("in reach next hop %i encode", s->mp_next_hop);
|
||||||
if (la < 0)
|
if (la < 0)
|
||||||
{
|
{
|
||||||
/* Attribute list too long */
|
/* Attribute list too long */
|
||||||
@ -2486,8 +2488,9 @@ bgp_create_update_bmp(ea_list *channel_ea, struct bgp_proto *bgp_p, byte *buf, s
|
|||||||
.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.
|
.ignore_non_bgp_attrs = 1,
|
||||||
};
|
};
|
||||||
|
log("next hop %x (0)", s.mp_next_hop);
|
||||||
log("check there is no next hop %i, channel fce %i", s.mp_next_hop, c->desc->encode_next_hop);
|
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);
|
log("desc %x, bgp_af_desc bgp_af_table %x", c->desc, bgp_af_table);
|
||||||
|
|
||||||
@ -2542,7 +2545,7 @@ bgp_bmp_encode_rte(ea_list *c, struct bgp_proto *bgp_p, byte *buf, const net_add
|
|||||||
struct bgp_prefix *px = tmp_allocz(prefix_size);
|
struct bgp_prefix *px = tmp_allocz(prefix_size);
|
||||||
px->src = tmp_allocz(sizeof(struct rte_src));
|
px->src = tmp_allocz(sizeof(struct rte_src));
|
||||||
memcpy(px->src, src, sizeof(struct rte_src));
|
memcpy(px->src, src, sizeof(struct rte_src));
|
||||||
//FIXME net_copy(px->net, n);
|
px->ni = NET_TO_INDEX(n);
|
||||||
add_tail(&b->prefixes, &px->buck_node); // why was there _xx ?
|
add_tail(&b->prefixes, &px->buck_node); // why was there _xx ?
|
||||||
|
|
||||||
byte *end = bgp_create_update_bmp(c, bgp_p, pkt, b, !!new);
|
byte *end = bgp_create_update_bmp(c, bgp_p, pkt, b, !!new);
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
#include "lib/lists.h"
|
#include "lib/lists.h"
|
||||||
#include "lib/resource.h"
|
#include "lib/resource.h"
|
||||||
#include "lib/unaligned.h"
|
#include "lib/unaligned.h"
|
||||||
|
#include "lib/tlists.h"
|
||||||
#include "nest/iface.h"
|
#include "nest/iface.h"
|
||||||
#include "nest/route.h"
|
#include "nest/route.h"
|
||||||
|
|
||||||
@ -534,19 +535,19 @@ bmp_add_table_exp_req(struct bmp_proto *p, rtable *tab)
|
|||||||
struct bmp_table *bt = mb_allocz(p->p.pool, sizeof(struct bmp_table));
|
struct bmp_table *bt = mb_allocz(p->p.pool, sizeof(struct bmp_table));
|
||||||
log("adding table %x", bt);
|
log("adding table %x", bt);
|
||||||
bt->table = tab;
|
bt->table = tab;
|
||||||
|
bt->p = p;
|
||||||
rt_lock_table(bt->table);
|
rt_lock_table(bt->table);
|
||||||
|
|
||||||
HASH_INSERT(p->table_map, HASH_TABLE, bt);
|
HASH_INSERT(p->table_map, HASH_TABLE, bt);
|
||||||
|
|
||||||
event *e = mb_allocz(p->p.pool, sizeof(struct event));
|
bt->event.hook = bmp_rt_notify_exp_req;
|
||||||
e->hook = bmp_rt_notify_exp_req;
|
bt->event.data = bt;
|
||||||
e->data = p;
|
|
||||||
|
|
||||||
bt->out_req = (struct rt_export_request) {
|
bt->out_req = (struct rt_export_request) {
|
||||||
.name = mb_sprintf(p->p.pool, "%s.exp_request", p->p.name),
|
.name = mb_sprintf(p->p.pool, "%s.exp_request", p->p.name),
|
||||||
.r = (struct lfjour_recipient) {
|
.r = (struct lfjour_recipient) {
|
||||||
.target = &p->p.loop->event_list,
|
.target = proto_event_list(&p->p),//&p->p.loop->event_list,
|
||||||
.event = e,
|
.event = &bt->event,
|
||||||
},
|
},
|
||||||
.pool = p->p.pool,
|
.pool = p->p.pool,
|
||||||
//.feeder.prefilter = {
|
//.feeder.prefilter = {
|
||||||
@ -585,7 +586,7 @@ bmp_remove_table_rt(struct bmp_proto *p, struct bmp_table *bt)
|
|||||||
log("removing table - bmp table %x chann %x, (subscr %x uc %x)",bt, bt->channel, &bt->channel->roa_subscriptions, &bt->uc);
|
log("removing table - bmp table %x chann %x, (subscr %x uc %x)",bt, bt->channel, &bt->channel->roa_subscriptions, &bt->uc);
|
||||||
channel_set_state(bt->channel, CS_STOP);
|
channel_set_state(bt->channel, CS_STOP);
|
||||||
channel_set_state(bt->channel, CS_DOWN);
|
channel_set_state(bt->channel, CS_DOWN);
|
||||||
rt_export_unsubscribe(all, &p->out_req);
|
rt_export_unsubscribe(all, &bt->out_req);
|
||||||
|
|
||||||
HASH_REMOVE(p->table_map, HASH_TABLE, bt);
|
HASH_REMOVE(p->table_map, HASH_TABLE, bt);
|
||||||
|
|
||||||
@ -691,12 +692,12 @@ bmp_add_peer(struct bmp_proto *p, ea_list *bgp_attr)
|
|||||||
|
|
||||||
HASH_INSERT(p->peer_map, HASH_PEER, bp);
|
HASH_INSERT(p->peer_map, HASH_PEER, bp);
|
||||||
|
|
||||||
//int proto_id = ea_get_int(bgp_attr, &ea_proto_id, 0);
|
int proto_id = ea_get_int(bgp_attr, &ea_proto_id, 0);
|
||||||
|
|
||||||
|
|
||||||
#if 0 /* XXXXX FIXME */
|
|
||||||
struct channel_attrs *chan_attr;
|
struct channel_attrs *chan_attr;
|
||||||
log("before while id %i, eattrs %i", proto_id, proto_state_table->channels_attrs[proto_id]);
|
log("before while id %i, eattrs %i", proto_id, proto_state_table->channels_attrs[proto_id]);
|
||||||
WALK_LIST(chan_attr, proto_state_table->channels_attrs[proto_id])
|
WALK_TLIST(channel_attrs, chan_attr, &proto_state_table->channels_attrs[proto_id])
|
||||||
{
|
{
|
||||||
log("chan_attr in bmp_add_peer %i, attrs %i", chan_attr, chan_attr->attrs);
|
log("chan_attr in bmp_add_peer %i, attrs %i", chan_attr, chan_attr->attrs);
|
||||||
rtable *ch_table = (rtable *) ea_get_ptr(chan_attr->attrs, &ea_rtable, 0);
|
rtable *ch_table = (rtable *) ea_get_ptr(chan_attr->attrs, &ea_rtable, 0);
|
||||||
@ -708,7 +709,6 @@ bmp_add_peer(struct bmp_proto *p, ea_list *bgp_attr)
|
|||||||
if (p->monitoring_rib.in_post_policy && ch_table)
|
if (p->monitoring_rib.in_post_policy && ch_table)
|
||||||
bmp_add_stream(p, bp, ea_get_int(chan_attr->attrs, &ea_bgp_afi, 0), true, ch_table, chan_attr->attrs, 0);
|
bmp_add_stream(p, bp, ea_get_int(chan_attr->attrs, &ea_bgp_afi, 0), true, ch_table, chan_attr->attrs, 0);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return bp;
|
return bp;
|
||||||
}
|
}
|
||||||
@ -1145,12 +1145,27 @@ bmp_rt_notify(struct proto *P, struct channel *c, const net_addr *net,
|
|||||||
bmp_route_monitor_notify(p, bgp, bs, net, new, (new ?: old)->src);
|
bmp_route_monitor_notify(p, bgp, bs, net, new, (new ?: old)->src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
bgp_next_hop_present(rte *n)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < n->attrs->count; i++)
|
||||||
|
{
|
||||||
|
eattr a = n->attrs->attrs[i];
|
||||||
|
const struct ea_class *class = ea_class_find(a.id);
|
||||||
|
log("ea class %s", class->name);
|
||||||
|
//if (class == &(get_bgp_attr_table()[BA_NEXT_HOP].class)) //TODO
|
||||||
|
// return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
bmp_rt_notify_exp_req(void *p_)
|
bmp_rt_notify_exp_req(void *bt_)
|
||||||
{
|
{
|
||||||
log("ok in notify exp req");
|
log("ok in notify exp req");
|
||||||
struct bmp_proto *p = (struct bmp_proto*) p_;
|
struct bmp_table *bt = (struct bmp_table *)bt_;
|
||||||
RT_EXPORT_WALK(&p->out_req, u) //const struct rt_export_union *_u;
|
struct bmp_proto *p = bt->p;
|
||||||
|
RT_EXPORT_WALK(&bt->out_req, u) //const struct rt_export_union *_u;
|
||||||
{
|
{
|
||||||
switch (u->kind)
|
switch (u->kind)
|
||||||
{
|
{
|
||||||
@ -1158,6 +1173,7 @@ bmp_rt_notify_exp_req(void *p_)
|
|||||||
bug("Main table export stopped");
|
bug("Main table export stopped");
|
||||||
|
|
||||||
case RT_EXPORT_FEED:
|
case RT_EXPORT_FEED:
|
||||||
|
log("export feed");
|
||||||
uint oldpos = 0;
|
uint oldpos = 0;
|
||||||
while ((oldpos < u->feed->count_routes) && !(u->feed->block[oldpos].flags & REF_OBSOLETE))
|
while ((oldpos < u->feed->count_routes) && !(u->feed->block[oldpos].flags & REF_OBSOLETE))
|
||||||
oldpos++;
|
oldpos++;
|
||||||
@ -1166,7 +1182,10 @@ bmp_rt_notify_exp_req(void *p_)
|
|||||||
for (uint i = 0; i < oldpos; i++)
|
for (uint i = 0; i < oldpos; i++)
|
||||||
{
|
{
|
||||||
rte *new = &u->feed->block[i];
|
rte *new = &u->feed->block[i];
|
||||||
struct bgp_proto *bgp = (struct bgp_proto*) SKIP_BACK(struct proto, sources, new->src->owner);
|
struct proto *rte_proto = (struct proto*) SKIP_BACK(struct proto, sources, new->src->owner);
|
||||||
|
if (rte_proto->proto != &proto_bgp)
|
||||||
|
break;
|
||||||
|
struct bgp_proto *bgp = (struct bgp_proto *) rte_proto;
|
||||||
struct bgp_channel *bc = (struct bgp_channel *) SKIP_BACK(struct channel, in_req, new->sender->req);
|
struct bgp_channel *bc = (struct bgp_channel *) SKIP_BACK(struct channel, in_req, new->sender->req);
|
||||||
struct bgp_channel *src = SKIP_BACK(struct bgp_channel, c.in_req, new->sender->req);
|
struct bgp_channel *src = SKIP_BACK(struct bgp_channel, c.in_req, new->sender->req);
|
||||||
bool policy = (bc->c.table == src->c.table); //TODO?
|
bool policy = (bc->c.table == src->c.table); //TODO?
|
||||||
@ -1176,14 +1195,18 @@ bmp_rt_notify_exp_req(void *p_)
|
|||||||
log("bmp stream not found in p %i", p);
|
log("bmp stream not found in p %i", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log("bmp stream found");
|
log("bmp stream found feed, policy %i", bs->in_pre_policy);
|
||||||
bmp_route_monitor_notify(p, bgp, bs, new->net, new, new->src);
|
bmp_route_monitor_notify(p, bgp, bs, new->net, new, new->src);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RT_EXPORT_UPDATE:
|
case RT_EXPORT_UPDATE:
|
||||||
|
log("export update");
|
||||||
const rte *new = u->update->new;
|
const rte *new = u->update->new;
|
||||||
const rte *old = u->update->old;
|
const rte *old = u->update->old;
|
||||||
struct bgp_proto *bgp = (struct bgp_proto*) SKIP_BACK(struct proto, sources, new->src->owner);
|
struct proto *rte_proto = (struct proto*) SKIP_BACK(struct proto, sources, new->src->owner);
|
||||||
|
if (rte_proto->proto != &proto_bgp)
|
||||||
|
break;
|
||||||
|
struct bgp_proto *bgp = (struct bgp_proto *) rte_proto;
|
||||||
struct bgp_channel *bc = (struct bgp_channel *) SKIP_BACK(struct channel, in_req, new->sender->req);
|
struct bgp_channel *bc = (struct bgp_channel *) SKIP_BACK(struct channel, in_req, new->sender->req);
|
||||||
struct bgp_channel *src = SKIP_BACK(struct bgp_channel, c.in_req, (new ?: old)->sender->req);
|
struct bgp_channel *src = SKIP_BACK(struct bgp_channel, c.in_req, (new ?: old)->sender->req);
|
||||||
bool policy = (bc->c.table == src->c.table); //TODO?
|
bool policy = (bc->c.table == src->c.table); //TODO?
|
||||||
@ -1193,10 +1216,11 @@ bmp_rt_notify_exp_req(void *p_)
|
|||||||
log("bmp stream not found in p %i", p);
|
log("bmp stream not found in p %i", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log("bmp stream found");
|
log("bmp stream found update");
|
||||||
bmp_route_monitor_notify(p, bgp, bs, new->net, new, (new ?: old)->src);
|
bmp_route_monitor_notify(p, bgp, bs, new->net, new, (new ?: old)->src);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log("end of notify fce");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1300,7 +1324,7 @@ bmp_down(struct bmp_proto *p)
|
|||||||
}
|
}
|
||||||
HASH_WALK_END;
|
HASH_WALK_END;
|
||||||
|
|
||||||
/* Removing peers should also remove all streams and tables */
|
/* Removing peers should also remove all streams and tables */ //TODO
|
||||||
ASSERT(!p->peer_map.count && !p->stream_map.count && !p->table_map.count);
|
ASSERT(!p->peer_map.count && !p->stream_map.count && !p->table_map.count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +100,8 @@ struct bmp_table {
|
|||||||
struct bmp_table *next;
|
struct bmp_table *next;
|
||||||
struct channel *channel;
|
struct channel *channel;
|
||||||
struct rt_export_request out_req;
|
struct rt_export_request out_req;
|
||||||
|
struct bmp_proto *p;
|
||||||
|
event event;
|
||||||
u32 uc;
|
u32 uc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user