struct rta *attrs; /* Attributes of this route */
const net_addr *net; /* Network this RTE belongs to */
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 pflags; /* Protocol-specific flags */
} rte;
struct rta *attrs; /* Attributes of this route */
net *net; /* Network this RTE belongs to */
struct rte_src *src; /* Route source that created the route */
-
struct channel *sender; /* Channel used to send the route to the routing table */
+
u32 id; /* Table specific route id */
byte flags; /* Flags (REF_...) */
byte pflags; /* Protocol-specific flags */
/**
* rte_update - enter a new update to a routing table
- * @c: channel doing the update
* @rte: a &rte representing the new route
*
* This function imports a new route to the appropriate table (via the channel).
* All memory used for temporary allocations is taken from a special linpool
* @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)
{
- 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;
.attrs = r->attrs,
.net = r->net->n.addr,
.src = r->src,
+ .sender = r->sender,
.flags = r->flags,
.pflags = r->pflags
} : (rte) {};
.attrs = r->attrs,
.net = n,
.src = r->src,
+ .sender = r->sender,
};
rt_lock_source(e->src);
void
rte_copy_metadata(struct rte_storage *dest, struct rte_storage *src)
{
- dest->sender = src->sender;
dest->flags = src->flags & REF_FILTERED;
dest->pflags = src->pflags;
dest->lastmod = src->lastmod;
rte_is_filtered(x) == fy;
}
-static void NONNULL(1,2,3)
-rte_recalculate(struct channel *c, net *net, rte *new, _Bool filtered)
+static void NONNULL(1,2)
+rte_recalculate(net *net, rte *new, _Bool filtered)
{
+ struct channel *c = new->sender;
struct proto *p = c->proto;
struct rtable *table = c->table;
struct proto_stats *stats = &c->stats;
if (new->attrs) {
new_stored = rte_store(new, net);
- new_stored->sender = c;
if (filtered)
new_stored->flags |= REF_FILTERED;
lp_flush(rte_update_pool);
}
-static int NONNULL(1,2) rte_update_in(struct channel *c, rte *new);
-static void NONNULL(1,2) rte_update2(struct channel *c, rte *new);
+static int NONNULL(1) rte_update_in(rte *new);
+static void NONNULL(1) rte_update2(rte *new);
-void NONNULL(1,2)
-rte_update(struct channel *c, rte *new)
+void NONNULL(1)
+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->src);
if (new->attrs && !new->attrs->pref)
{
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;
- rte_update2(c, new);
+ rte_update2(new);
}
-static void NONNULL(1,2)
-rte_update2(struct channel *c, rte *new)
+static void NONNULL(1)
+rte_update2(rte *new)
{
+ struct channel *c = new->sender;
// struct proto *p = c->proto;
struct proto_stats *stats = &c->stats;
const struct filter *filter = c->in_filter;
}
/* And recalculate the best route */
- rte_recalculate(c, nn, new, filtered);
+ rte_recalculate(nn, new, filtered);
rte_update_unlock();
return;
.net = old->net->n.addr,
.src = old->src,
.attrs = old->sender->proto->rte_modify(old, rte_update_pool),
+ .sender = old->sender,
};
if (new.attrs != old->attrs)
- rte_recalculate(old->sender, old->net, &new, old->src);
+ rte_recalculate(old->net, &new, old->src);
rte_update_unlock();
}
/* Discard the route */
rte_update_lock();
- rte ew = { .net = e->net->n.addr, .src = e->src };
- rte_recalculate(e->sender, e->net, &ew, 0);
+ rte ew = { .net = e->net->n.addr, .src = e->src, .sender = e->sender, };
+ rte_recalculate(e->net, &ew, 0);
rte_update_unlock();
limit--;
.attrs = a,
.net = old->net->n.addr,
.src = old->src,
+ .sender = old->sender,
};
rte_trace_in(D_ROUTES, old->sender, &e, "updated");
*/
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 rte_storage *old, **pos;
net *net;
/* Insert the new rte */
struct rte_storage *e = rte_store(new, net);
- e->sender = c;
e->lastmod = current_time();
e->next = *pos;
*pos = e;
}
rte eloc = rte_copy(e);
- rte_update2(c, &eloc);
+ rte_update2(&eloc);
}
c->reload_next_rte = NULL;
if (new->attrs)
{
struct rte_storage *es = rte_store(new, net);
- es->sender = c;
es->lastmod = current_time();
es->id = e->new->id;
es->next = *pos;