mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 09:41:54 +00:00
Nest: moved sender channel to the route rw structure
It is needed for early pipe collision detection and it also reduces the calling convention of rte_update() to one argument.
This commit is contained in:
parent
a89cf0525a
commit
28e81229a8
@ -231,6 +231,7 @@ typedef struct rte {
|
|||||||
struct rta *attrs; /* Attributes of this route */
|
struct rta *attrs; /* Attributes of this route */
|
||||||
const net_addr *net; /* Network this RTE belongs to */
|
const net_addr *net; /* Network this RTE belongs to */
|
||||||
struct rte_src *src; /* Route source that created the route */
|
struct rte_src *src; /* Route source that created the route */
|
||||||
|
struct channel *sender; /* Channel used to send the route to the routing table */
|
||||||
byte flags; /* Flags (REF_...) */
|
byte flags; /* Flags (REF_...) */
|
||||||
byte pflags; /* Protocol-specific flags */
|
byte pflags; /* Protocol-specific flags */
|
||||||
} rte;
|
} rte;
|
||||||
@ -241,8 +242,8 @@ struct rte_storage {
|
|||||||
struct rta *attrs; /* Attributes of this route */
|
struct rta *attrs; /* Attributes of this route */
|
||||||
net *net; /* Network this RTE belongs to */
|
net *net; /* Network this RTE belongs to */
|
||||||
struct rte_src *src; /* Route source that created the route */
|
struct rte_src *src; /* Route source that created the route */
|
||||||
|
|
||||||
struct channel *sender; /* Channel used to send the route to the routing table */
|
struct channel *sender; /* Channel used to send the route to the routing table */
|
||||||
|
|
||||||
u32 id; /* Table specific route id */
|
u32 id; /* Table specific route id */
|
||||||
byte flags; /* Flags (REF_...) */
|
byte flags; /* Flags (REF_...) */
|
||||||
byte pflags; /* Protocol-specific flags */
|
byte pflags; /* Protocol-specific flags */
|
||||||
@ -300,7 +301,6 @@ struct rte_export {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* rte_update - enter a new update to a routing table
|
* rte_update - enter a new update to a routing table
|
||||||
* @c: channel doing the update
|
|
||||||
* @rte: a &rte representing the new route
|
* @rte: a &rte representing the new route
|
||||||
*
|
*
|
||||||
* This function imports a new route to the appropriate table (via the channel).
|
* This function imports a new route to the appropriate table (via the channel).
|
||||||
@ -326,10 +326,10 @@ struct rte_export {
|
|||||||
* All memory used for temporary allocations is taken from a special linpool
|
* All memory used for temporary allocations is taken from a special linpool
|
||||||
* @rte_update_pool and freed when rte_update() finishes.
|
* @rte_update_pool and freed when rte_update() finishes.
|
||||||
*/
|
*/
|
||||||
void rte_update(struct channel *c, struct rte *rte) NONNULL(1,2);
|
void rte_update(struct rte *rte) NONNULL(1);
|
||||||
static inline void rte_withdraw(struct channel *c, const net_addr *net, struct rte_src *src)
|
static inline void rte_withdraw(struct channel *c, const net_addr *net, struct rte_src *src)
|
||||||
{
|
{
|
||||||
rte e = { .net = net, .src = src}; rte_update(c, &e);
|
rte e = { .sender = c, .net = net, .src = src}; rte_update(&e);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern list routing_tables;
|
extern list routing_tables;
|
||||||
@ -365,6 +365,7 @@ static inline rte rte_copy(const struct rte_storage *r)
|
|||||||
.attrs = r->attrs,
|
.attrs = r->attrs,
|
||||||
.net = r->net->n.addr,
|
.net = r->net->n.addr,
|
||||||
.src = r->src,
|
.src = r->src,
|
||||||
|
.sender = r->sender,
|
||||||
.flags = r->flags,
|
.flags = r->flags,
|
||||||
.pflags = r->pflags
|
.pflags = r->pflags
|
||||||
} : (rte) {};
|
} : (rte) {};
|
||||||
|
@ -87,8 +87,9 @@ dev_ifa_notify(struct proto *P, uint flags, struct ifa *ad)
|
|||||||
.src = rt_get_source(P, ad->iface->index),
|
.src = rt_get_source(P, ad->iface->index),
|
||||||
.net = net,
|
.net = net,
|
||||||
.attrs = &a0,
|
.attrs = &a0,
|
||||||
|
.sender = c,
|
||||||
};
|
};
|
||||||
rte_update(c, &e0);
|
rte_update(&e0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,6 +291,7 @@ rte_store(const rte *r, net *n)
|
|||||||
.attrs = r->attrs,
|
.attrs = r->attrs,
|
||||||
.net = n,
|
.net = n,
|
||||||
.src = r->src,
|
.src = r->src,
|
||||||
|
.sender = r->sender,
|
||||||
};
|
};
|
||||||
|
|
||||||
rt_lock_source(e->src);
|
rt_lock_source(e->src);
|
||||||
@ -306,7 +307,6 @@ rte_store(const rte *r, net *n)
|
|||||||
void
|
void
|
||||||
rte_copy_metadata(struct rte_storage *dest, struct rte_storage *src)
|
rte_copy_metadata(struct rte_storage *dest, struct rte_storage *src)
|
||||||
{
|
{
|
||||||
dest->sender = src->sender;
|
|
||||||
dest->flags = src->flags & REF_FILTERED;
|
dest->flags = src->flags & REF_FILTERED;
|
||||||
dest->pflags = src->pflags;
|
dest->pflags = src->pflags;
|
||||||
dest->lastmod = src->lastmod;
|
dest->lastmod = src->lastmod;
|
||||||
@ -891,9 +891,10 @@ rte_same(struct rte_storage *x, rte *y, _Bool fy)
|
|||||||
rte_is_filtered(x) == fy;
|
rte_is_filtered(x) == fy;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void NONNULL(1,2,3)
|
static void NONNULL(1,2)
|
||||||
rte_recalculate(struct channel *c, net *net, rte *new, _Bool filtered)
|
rte_recalculate(net *net, rte *new, _Bool filtered)
|
||||||
{
|
{
|
||||||
|
struct channel *c = new->sender;
|
||||||
struct proto *p = c->proto;
|
struct proto *p = c->proto;
|
||||||
struct rtable *table = c->table;
|
struct rtable *table = c->table;
|
||||||
struct proto_stats *stats = &c->stats;
|
struct proto_stats *stats = &c->stats;
|
||||||
@ -1028,7 +1029,6 @@ rte_recalculate(struct channel *c, net *net, rte *new, _Bool filtered)
|
|||||||
|
|
||||||
if (new->attrs) {
|
if (new->attrs) {
|
||||||
new_stored = rte_store(new, net);
|
new_stored = rte_store(new, net);
|
||||||
new_stored->sender = c;
|
|
||||||
|
|
||||||
if (filtered)
|
if (filtered)
|
||||||
new_stored->flags |= REF_FILTERED;
|
new_stored->flags |= REF_FILTERED;
|
||||||
@ -1184,31 +1184,33 @@ rte_update_unlock(void)
|
|||||||
lp_flush(rte_update_pool);
|
lp_flush(rte_update_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int NONNULL(1,2) rte_update_in(struct channel *c, rte *new);
|
static int NONNULL(1) rte_update_in(rte *new);
|
||||||
static void NONNULL(1,2) rte_update2(struct channel *c, rte *new);
|
static void NONNULL(1) rte_update2(rte *new);
|
||||||
|
|
||||||
void NONNULL(1,2)
|
void NONNULL(1)
|
||||||
rte_update(struct channel *c, rte *new)
|
rte_update(rte *new)
|
||||||
{
|
{
|
||||||
ASSERT(c->channel_state == CS_UP);
|
ASSERT(new->sender);
|
||||||
|
ASSERT(new->sender->channel_state == CS_UP);
|
||||||
ASSERT(new->net);
|
ASSERT(new->net);
|
||||||
ASSERT(new->src);
|
ASSERT(new->src);
|
||||||
|
|
||||||
if (new->attrs && !new->attrs->pref)
|
if (new->attrs && !new->attrs->pref)
|
||||||
{
|
{
|
||||||
ASSERT(!new->attrs->cached);
|
ASSERT(!new->attrs->cached);
|
||||||
new->attrs->pref = c->preference;
|
new->attrs->pref = new->sender->preference;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->in_table && !rte_update_in(c, new))
|
if (new->sender->in_table && !rte_update_in(new))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rte_update2(c, new);
|
rte_update2(new);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void NONNULL(1,2)
|
static void NONNULL(1)
|
||||||
rte_update2(struct channel *c, rte *new)
|
rte_update2(rte *new)
|
||||||
{
|
{
|
||||||
|
struct channel *c = new->sender;
|
||||||
// struct proto *p = c->proto;
|
// struct proto *p = c->proto;
|
||||||
struct proto_stats *stats = &c->stats;
|
struct proto_stats *stats = &c->stats;
|
||||||
const struct filter *filter = c->in_filter;
|
const struct filter *filter = c->in_filter;
|
||||||
@ -1288,7 +1290,7 @@ rte_update2(struct channel *c, rte *new)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* And recalculate the best route */
|
/* And recalculate the best route */
|
||||||
rte_recalculate(c, nn, new, filtered);
|
rte_recalculate(nn, new, filtered);
|
||||||
rte_update_unlock();
|
rte_update_unlock();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1327,10 +1329,11 @@ rte_modify(struct rte_storage *old)
|
|||||||
.net = old->net->n.addr,
|
.net = old->net->n.addr,
|
||||||
.src = old->src,
|
.src = old->src,
|
||||||
.attrs = old->sender->proto->rte_modify(old, rte_update_pool),
|
.attrs = old->sender->proto->rte_modify(old, rte_update_pool),
|
||||||
|
.sender = old->sender,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (new.attrs != old->attrs)
|
if (new.attrs != old->attrs)
|
||||||
rte_recalculate(old->sender, old->net, &new, old->src);
|
rte_recalculate(old->net, &new, old->src);
|
||||||
|
|
||||||
rte_update_unlock();
|
rte_update_unlock();
|
||||||
}
|
}
|
||||||
@ -1682,8 +1685,8 @@ again:
|
|||||||
|
|
||||||
/* Discard the route */
|
/* Discard the route */
|
||||||
rte_update_lock();
|
rte_update_lock();
|
||||||
rte ew = { .net = e->net->n.addr, .src = e->src };
|
rte ew = { .net = e->net->n.addr, .src = e->src, .sender = e->sender, };
|
||||||
rte_recalculate(e->sender, e->net, &ew, 0);
|
rte_recalculate(e->net, &ew, 0);
|
||||||
rte_update_unlock();
|
rte_update_unlock();
|
||||||
|
|
||||||
limit--;
|
limit--;
|
||||||
@ -1880,6 +1883,7 @@ rt_next_hop_update_rte(struct rte_storage *old)
|
|||||||
.attrs = a,
|
.attrs = a,
|
||||||
.net = old->net->n.addr,
|
.net = old->net->n.addr,
|
||||||
.src = old->src,
|
.src = old->src,
|
||||||
|
.sender = old->sender,
|
||||||
};
|
};
|
||||||
|
|
||||||
rte_trace_in(D_ROUTES, old->sender, &e, "updated");
|
rte_trace_in(D_ROUTES, old->sender, &e, "updated");
|
||||||
@ -2240,8 +2244,9 @@ rt_feed_channel_abort(struct channel *c)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rte_update_in(struct channel *c, rte *new)
|
rte_update_in(rte *new)
|
||||||
{
|
{
|
||||||
|
struct channel *c = new->sender;
|
||||||
struct rtable *tab = c->in_table;
|
struct rtable *tab = c->in_table;
|
||||||
struct rte_storage *old, **pos;
|
struct rte_storage *old, **pos;
|
||||||
net *net;
|
net *net;
|
||||||
@ -2312,7 +2317,6 @@ rte_update_in(struct channel *c, rte *new)
|
|||||||
|
|
||||||
/* Insert the new rte */
|
/* Insert the new rte */
|
||||||
struct rte_storage *e = rte_store(new, net);
|
struct rte_storage *e = rte_store(new, net);
|
||||||
e->sender = c;
|
|
||||||
e->lastmod = current_time();
|
e->lastmod = current_time();
|
||||||
e->next = *pos;
|
e->next = *pos;
|
||||||
*pos = e;
|
*pos = e;
|
||||||
@ -2356,7 +2360,7 @@ rt_reload_channel(struct channel *c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rte eloc = rte_copy(e);
|
rte eloc = rte_copy(e);
|
||||||
rte_update2(c, &eloc);
|
rte_update2(&eloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
c->reload_next_rte = NULL;
|
c->reload_next_rte = NULL;
|
||||||
@ -2508,7 +2512,6 @@ rte_update_out(struct channel *c, struct rte_export_internal *e)
|
|||||||
if (new->attrs)
|
if (new->attrs)
|
||||||
{
|
{
|
||||||
struct rte_storage *es = rte_store(new, net);
|
struct rte_storage *es = rte_store(new, net);
|
||||||
es->sender = c;
|
|
||||||
es->lastmod = current_time();
|
es->lastmod = current_time();
|
||||||
es->id = e->new->id;
|
es->id = e->new->id;
|
||||||
es->next = *pos;
|
es->next = *pos;
|
||||||
|
@ -674,10 +674,11 @@ babel_announce_rte(struct babel_proto *p, struct babel_entry *e)
|
|||||||
.net = e->n.addr,
|
.net = e->n.addr,
|
||||||
.src = p->p.main_source,
|
.src = p->p.main_source,
|
||||||
.attrs = &a0,
|
.attrs = &a0,
|
||||||
|
.sender = c,
|
||||||
};
|
};
|
||||||
|
|
||||||
e->unreachable = 0;
|
e->unreachable = 0;
|
||||||
rte_update(c, &e0);
|
rte_update(&e0);
|
||||||
}
|
}
|
||||||
else if (e->valid && (e->router_id != p->router_id))
|
else if (e->valid && (e->router_id != p->router_id))
|
||||||
{
|
{
|
||||||
@ -693,10 +694,11 @@ babel_announce_rte(struct babel_proto *p, struct babel_entry *e)
|
|||||||
.net = e->n.addr,
|
.net = e->n.addr,
|
||||||
.src = p->p.main_source,
|
.src = p->p.main_source,
|
||||||
.attrs = &a0,
|
.attrs = &a0,
|
||||||
|
.sender = c,
|
||||||
};
|
};
|
||||||
|
|
||||||
e->unreachable = 1;
|
e->unreachable = 1;
|
||||||
rte_update(c, &e0);
|
rte_update(&e0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1362,9 +1362,10 @@ bgp_rte_update(struct bgp_parse_state *s, net_addr *n, u32 path_id, rta *a0)
|
|||||||
.net = n,
|
.net = n,
|
||||||
.src = s->last_src,
|
.src = s->last_src,
|
||||||
.attrs = s->cached_rta,
|
.attrs = s->cached_rta,
|
||||||
|
.sender = &(s->channel->c),
|
||||||
};
|
};
|
||||||
|
|
||||||
rte_update(&(s->channel->c), &e0);
|
rte_update(&e0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2098,7 +2098,8 @@ again1:
|
|||||||
rte e0 = {
|
rte e0 = {
|
||||||
.attrs = rta_lookup(&a0),
|
.attrs = rta_lookup(&a0),
|
||||||
.src = p->p.main_source,
|
.src = p->p.main_source,
|
||||||
.net = nf->fn.addr,
|
.net = nf->fn.addr,
|
||||||
|
.sender = p->p.main_channel,
|
||||||
};
|
};
|
||||||
|
|
||||||
rta_free(nf->old_rta);
|
rta_free(nf->old_rta);
|
||||||
@ -2107,7 +2108,7 @@ again1:
|
|||||||
DBG("Mod rte type %d - %N via %I on iface %s, met %d\n",
|
DBG("Mod rte type %d - %N via %I on iface %s, met %d\n",
|
||||||
a0.source, nf->fn.addr, a0.gw, a0.iface ? a0.iface->name : "(none)", nf->n.metric1);
|
a0.source, nf->fn.addr, a0.gw, a0.iface ? a0.iface->name : "(none)", nf->n.metric1);
|
||||||
|
|
||||||
rte_update(p->p.main_channel, &e0);
|
rte_update(&e0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (nf->old_rta)
|
else if (nf->old_rta)
|
||||||
|
@ -166,8 +166,9 @@ perf_loop(void *data)
|
|||||||
.attrs = p->data[i].a,
|
.attrs = p->data[i].a,
|
||||||
.src = p->p.main_source,
|
.src = p->p.main_source,
|
||||||
.net = &(p->data[i].net),
|
.net = &(p->data[i].net),
|
||||||
|
.sender = P->main_channel,
|
||||||
};
|
};
|
||||||
rte_update(P->main_channel, &e0);
|
rte_update(&e0);
|
||||||
}
|
}
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts_update);
|
clock_gettime(CLOCK_MONOTONIC, &ts_update);
|
||||||
|
@ -78,10 +78,11 @@ pipe_rt_notify(struct channel *src_ch, struct rte_export *export)
|
|||||||
.attrs = a,
|
.attrs = a,
|
||||||
.src = export->new.src,
|
.src = export->new.src,
|
||||||
.net = net,
|
.net = net,
|
||||||
|
.sender = dst,
|
||||||
};
|
};
|
||||||
|
|
||||||
src_ch->table->pipe_busy = 1;
|
src_ch->table->pipe_busy = 1;
|
||||||
rte_update(dst, &e0);
|
rte_update(&e0);
|
||||||
src_ch->table->pipe_busy = 0;
|
src_ch->table->pipe_busy = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -93,7 +94,7 @@ pipe_rt_notify(struct channel *src_ch, struct rte_export *export)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
pipe_preexport(struct channel *src_ch, rte *e UNUSED)
|
pipe_preexport(struct channel *src_ch, rte *e)
|
||||||
{
|
{
|
||||||
struct pipe_proto *p = (void *) src_ch->proto;
|
struct pipe_proto *p = (void *) src_ch->proto;
|
||||||
struct channel *dst = (src_ch == p->pri) ? p->sec : p->pri;
|
struct channel *dst = (src_ch == p->pri) ? p->sec : p->pri;
|
||||||
@ -102,6 +103,10 @@ pipe_preexport(struct channel *src_ch, rte *e UNUSED)
|
|||||||
if (dst->table->pipe_busy)
|
if (dst->table->pipe_busy)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
/* Avoid direct loopbacks */
|
||||||
|
if (e->sender == src_ch)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,10 +210,11 @@ rip_announce_rte(struct rip_proto *p, struct rip_entry *en)
|
|||||||
rte e0 = {
|
rte e0 = {
|
||||||
.attrs = &a0,
|
.attrs = &a0,
|
||||||
.src = p->p.main_source,
|
.src = p->p.main_source,
|
||||||
.net = en->n.addr,
|
.net = en->n.addr,
|
||||||
|
.sender = p->p.main_channel,
|
||||||
};
|
};
|
||||||
|
|
||||||
rte_update(p->p.main_channel, &e0);
|
rte_update(&e0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
rte_withdraw(p->p.main_channel, en->n.addr, p->p.main_source);
|
rte_withdraw(p->p.main_channel, en->n.addr, p->p.main_source);
|
||||||
|
@ -130,10 +130,11 @@ rpki_table_add_roa(struct rpki_cache *cache, struct channel *channel, const net_
|
|||||||
rte e0 = {
|
rte e0 = {
|
||||||
.attrs = &a0,
|
.attrs = &a0,
|
||||||
.src = p->p.main_source,
|
.src = p->p.main_source,
|
||||||
.net = &pfxr->n,
|
.net = &pfxr->n,
|
||||||
|
.sender = channel,
|
||||||
};
|
};
|
||||||
|
|
||||||
rte_update(channel, &e0);
|
rte_update(&e0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -105,12 +105,13 @@ static_announce_rte(struct static_proto *p, struct static_route *r)
|
|||||||
.attrs = a,
|
.attrs = a,
|
||||||
.src = static_get_source(p, r->index),
|
.src = static_get_source(p, r->index),
|
||||||
.net = r->net,
|
.net = r->net,
|
||||||
|
.sender = p->p.main_channel,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (r->cmds)
|
if (r->cmds)
|
||||||
f_eval_rte(r->cmds, &e0, static_lp);
|
f_eval_rte(r->cmds, &e0, static_lp);
|
||||||
|
|
||||||
rte_update(p->p.main_channel, &e0);
|
rte_update(&e0);
|
||||||
r->state = SRS_CLEAN;
|
r->state = SRS_CLEAN;
|
||||||
|
|
||||||
if (r->cmds)
|
if (r->cmds)
|
||||||
|
@ -303,9 +303,10 @@ krt_learn_announce_update(struct krt_proto *p, struct rte_storage *e)
|
|||||||
.attrs = e->attrs,
|
.attrs = e->attrs,
|
||||||
.src = p->p.main_source,
|
.src = p->p.main_source,
|
||||||
.net = e->net->n.addr,
|
.net = e->net->n.addr,
|
||||||
|
.sender = p->p.main_channel,
|
||||||
};
|
};
|
||||||
|
|
||||||
rte_update(p->p.main_channel, &e0);
|
rte_update(&e0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user