summaryrefslogtreecommitdiff
path: root/proto/pipe
diff options
context:
space:
mode:
authorMaria Matejka <mq@jmq.cz>2020-01-28 11:42:46 +0100
committerMaria Matejka <mq@ucw.cz>2021-11-09 19:20:41 +0100
commit69d1ffde4c724882398b3b630ea1199f12c0c288 (patch)
treea7567e07bcd0aa3f9365da83ed2ac23a10e869b6 /proto/pipe
parent60880b539b8886f76961125d89a265c6e1112b7a (diff)
Split route data structure to storage (ro) / manipulation (rw) structures.
Routes are now allocated only when they are just to be inserted to the table. Updating a route needs a locally allocated route structure. Ownership of the attributes is also now not transfered from protocols to tables and vice versa but just borrowed which should be easier to handle in a multithreaded environment.
Diffstat (limited to 'proto/pipe')
-rw-r--r--proto/pipe/pipe.c38
1 files changed, 14 insertions, 24 deletions
diff --git a/proto/pipe/pipe.c b/proto/pipe/pipe.c
index 97862780..3caa85d0 100644
--- a/proto/pipe/pipe.c
+++ b/proto/pipe/pipe.c
@@ -48,14 +48,10 @@
#endif
static void
-pipe_rt_notify(struct proto *P, struct channel *src_ch, net *n, rte *new, rte *old)
+pipe_rt_notify(struct proto *P, struct channel *src_ch, const net_addr *n, rte *new, const rte *old)
{
struct pipe_proto *p = (void *) P;
struct channel *dst = (src_ch == p->pri) ? p->sec : p->pri;
- struct rte_src *src;
-
- rte *e;
- rta *a;
if (!new && !old)
return;
@@ -63,45 +59,39 @@ pipe_rt_notify(struct proto *P, struct channel *src_ch, net *n, rte *new, rte *o
if (dst->table->pipe_busy)
{
log(L_ERR "Pipe loop detected when sending %N to table %s",
- n->n.addr, dst->table->name);
+ n, dst->table->name);
return;
}
+ src_ch->table->pipe_busy = 1;
+
if (new)
{
- src = new->src;
-
- a = alloca(rta_size(new->attrs));
+ rta *a = alloca(rta_size(new->attrs));
memcpy(a, new->attrs, rta_size(new->attrs));
a->cached = 0;
a->hostentry = NULL;
- e = rte_get_temp(a, src);
- e->pflags = new->pflags;
-#ifdef CONFIG_BGP
- /* Hack to cleanup cached value */
- if (e->src->proto->proto == &proto_bgp)
- e->pflags &= ~(BGP_REF_STALE | BGP_REF_NOT_STALE);
-#endif
+ rte e0 = {
+ .attrs = a,
+ .src = new->src,
+ };
+
+ rte_update(dst, n, &e0, new->src);
}
else
- {
- e = NULL;
- src = old->src;
- }
+ rte_update(dst, n, NULL, old->src);
- src_ch->table->pipe_busy = 1;
- rte_update2(dst, n->n.addr, e, src);
src_ch->table->pipe_busy = 0;
}
static int
-pipe_preexport(struct proto *P, rte *e)
+pipe_preexport(struct channel *c, rte *e)
{
struct proto *pp = e->sender->proto;
- if (pp == P)
+ if (pp == c->proto)
return -1; /* Avoid local loops automatically */
return 0;