mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-17 08:38:42 +00:00
Added everything protocols need to know about multiple routing tables,
i.e. struct proto now contains field 'table' pointing to routing table the protocol is attached to. Use this instead of &master_table. Modified all protocols except the kernel syncer to use this field.
This commit is contained in:
parent
7e5f5ffdda
commit
7dc4827c96
@ -86,6 +86,7 @@ proto_new(struct proto_config *c, unsigned size)
|
|||||||
p->preference = c->preference;
|
p->preference = c->preference;
|
||||||
p->disabled = c->disabled;
|
p->disabled = c->disabled;
|
||||||
p->proto = pr;
|
p->proto = pr;
|
||||||
|
p->table = &master_table;
|
||||||
p->in_filter = c->in_filter;
|
p->in_filter = c->in_filter;
|
||||||
p->out_filter = c->out_filter;
|
p->out_filter = c->out_filter;
|
||||||
return p;
|
return p;
|
||||||
|
@ -99,11 +99,10 @@ struct proto {
|
|||||||
void (*rte_insert)(struct network *, struct rte *);
|
void (*rte_insert)(struct network *, struct rte *);
|
||||||
void (*rte_remove)(struct network *, struct rte *);
|
void (*rte_remove)(struct network *, struct rte *);
|
||||||
|
|
||||||
|
struct rtable *table; /* Routing table we're connected to */
|
||||||
struct filter *in_filter; /* Input filter */
|
struct filter *in_filter; /* Input filter */
|
||||||
struct filter *out_filter; /* Output filter */
|
struct filter *out_filter; /* Output filter */
|
||||||
|
|
||||||
/* Connection to routing tables? */
|
|
||||||
|
|
||||||
/* Hic sunt protocol-specific data */
|
/* Hic sunt protocol-specific data */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ dev_if_notify(struct proto *p, unsigned c, struct iface *new, struct iface *old)
|
|||||||
net *n;
|
net *n;
|
||||||
|
|
||||||
debug("dev_if_notify: %s going down\n", old->name);
|
debug("dev_if_notify: %s going down\n", old->name);
|
||||||
n = net_find(&master_table, 0, old->prefix, old->pxlen);
|
n = net_find(p->table, 0, old->prefix, old->pxlen);
|
||||||
if (!n)
|
if (!n)
|
||||||
{
|
{
|
||||||
debug("dev_if_notify: device shutdown: prefix not found\n");
|
debug("dev_if_notify: device shutdown: prefix not found\n");
|
||||||
@ -56,9 +56,9 @@ dev_if_notify(struct proto *p, unsigned c, struct iface *new, struct iface *old)
|
|||||||
A.attrs = NULL;
|
A.attrs = NULL;
|
||||||
a = rta_lookup(&A);
|
a = rta_lookup(&A);
|
||||||
if (new->flags & IF_UNNUMBERED)
|
if (new->flags & IF_UNNUMBERED)
|
||||||
n = net_get(&master_table, 0, new->opposite, new->pxlen);
|
n = net_get(p->table, 0, new->opposite, new->pxlen);
|
||||||
else
|
else
|
||||||
n = net_get(&master_table, 0, new->prefix, new->pxlen);
|
n = net_get(p->table, 0, new->prefix, new->pxlen);
|
||||||
e = rte_get_temp(a);
|
e = rte_get_temp(a);
|
||||||
e->net = n;
|
e->net = n;
|
||||||
e->pflags = 0;
|
e->pflags = 0;
|
||||||
|
@ -226,7 +226,7 @@ advertise_entry( struct proto *p, struct rip_block *b, ip_addr whotoldme )
|
|||||||
log( L_ERR "%I asked me to route %I/%I, but that is not valid netmask.", A.from, b->network, b->netmask );
|
log( L_ERR "%I asked me to route %I/%I, but that is not valid netmask.", A.from, b->network, b->netmask );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
n = net_get( &master_table, 0, b->network, ipa_mklen( b->netmask ));
|
n = net_get( p->table, 0, b->network, ipa_mklen( b->netmask ));
|
||||||
r = rte_get_temp(a);
|
r = rte_get_temp(a);
|
||||||
r->u.rip.metric = ntohl(b->metric) + rif->metric;
|
r->u.rip.metric = ntohl(b->metric) + rif->metric;
|
||||||
if (r->u.rip.metric > P_CF->infinity) r->u.rip.metric = P_CF->infinity;
|
if (r->u.rip.metric > P_CF->infinity) r->u.rip.metric = P_CF->infinity;
|
||||||
|
@ -37,7 +37,7 @@ static_install(struct proto *p, struct static_route *r, struct iface *ifa)
|
|||||||
a.iface = ifa;
|
a.iface = ifa;
|
||||||
aa = rta_lookup(&a);
|
aa = rta_lookup(&a);
|
||||||
|
|
||||||
n = net_get(&master_table, a.tos, r->net, r->masklen);
|
n = net_get(p->table, a.tos, r->net, r->masklen);
|
||||||
e = rte_get_temp(aa);
|
e = rte_get_temp(aa);
|
||||||
e->net = n;
|
e->net = n;
|
||||||
e->pflags = 0;
|
e->pflags = 0;
|
||||||
@ -50,7 +50,7 @@ static_remove(struct proto *p, struct static_route *r)
|
|||||||
net *n;
|
net *n;
|
||||||
|
|
||||||
DBG("Removing static route %I/%d\n", r->net, r->masklen);
|
DBG("Removing static route %I/%d\n", r->net, r->masklen);
|
||||||
n = net_find(&master_table, 0, r->net, r->masklen);
|
n = net_find(p->table, 0, r->net, r->masklen);
|
||||||
if (n)
|
if (n)
|
||||||
rte_update(n, p, NULL);
|
rte_update(n, p, NULL);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user