mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 09:41:54 +00:00
Nest: Fix route lookup
This commit is contained in:
parent
97e48b6a18
commit
7ee07a3c39
@ -284,6 +284,8 @@ void rt_lock_table(rtable *);
|
|||||||
void rt_unlock_table(rtable *);
|
void rt_unlock_table(rtable *);
|
||||||
void rt_setup(pool *, rtable *, char *, struct rtable_config *);
|
void rt_setup(pool *, rtable *, char *, struct rtable_config *);
|
||||||
static inline net *net_find(rtable *tab, const net_addr *addr) { return (net *) fib_find(&tab->fib, addr); }
|
static inline net *net_find(rtable *tab, const net_addr *addr) { return (net *) fib_find(&tab->fib, addr); }
|
||||||
|
static inline net *net_find_valid(rtable *tab, const net_addr *addr)
|
||||||
|
{ net *n = net_find(tab, addr); return (n && rte_is_valid(n->routes)) ? n : NULL; }
|
||||||
static inline net *net_get(rtable *tab, const net_addr *addr) { return (net *) fib_get(&tab->fib, addr); }
|
static inline net *net_get(rtable *tab, const net_addr *addr) { return (net *) fib_get(&tab->fib, addr); }
|
||||||
void *net_route(rtable *tab, const net_addr *n);
|
void *net_route(rtable *tab, const net_addr *n);
|
||||||
int net_roa_check(rtable *tab, const net_addr *n, u32 asn);
|
int net_roa_check(rtable *tab, const net_addr *n, u32 asn);
|
||||||
|
@ -68,12 +68,11 @@ make_tmp_attrs(struct rte *rt, struct linpool *pool)
|
|||||||
|
|
||||||
/* Like fib_route(), but skips empty net entries */
|
/* Like fib_route(), but skips empty net entries */
|
||||||
static inline void *
|
static inline void *
|
||||||
net_route_ip4(struct fib *f, net_addr_ip4 *n)
|
net_route_ip4(rtable *t, net_addr_ip4 *n)
|
||||||
{
|
{
|
||||||
net *r;
|
net *r;
|
||||||
|
|
||||||
while (r = fib_find(f, (net_addr *) n),
|
while (r = net_find_valid(t, (net_addr *) n), (!r) && (n->pxlen > 0))
|
||||||
!(r && rte_is_valid(r->routes)) && (n->pxlen > 0))
|
|
||||||
{
|
{
|
||||||
n->pxlen--;
|
n->pxlen--;
|
||||||
ip4_clrbit(&n->prefix, n->pxlen);
|
ip4_clrbit(&n->prefix, n->pxlen);
|
||||||
@ -83,12 +82,11 @@ net_route_ip4(struct fib *f, net_addr_ip4 *n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void *
|
static inline void *
|
||||||
net_route_ip6(struct fib *f, net_addr_ip6 *n)
|
net_route_ip6(rtable *t, net_addr_ip6 *n)
|
||||||
{
|
{
|
||||||
net *r;
|
net *r;
|
||||||
|
|
||||||
while (r = fib_find(f, (net_addr *) n),
|
while (r = net_find_valid(t, (net_addr *) n), (!r) && (n->pxlen > 0))
|
||||||
!(r && rte_is_valid(r->routes)) && (n->pxlen > 0))
|
|
||||||
{
|
{
|
||||||
n->pxlen--;
|
n->pxlen--;
|
||||||
ip6_clrbit(&n->prefix, n->pxlen);
|
ip6_clrbit(&n->prefix, n->pxlen);
|
||||||
@ -110,12 +108,12 @@ net_route(rtable *tab, const net_addr *n)
|
|||||||
case NET_IP4:
|
case NET_IP4:
|
||||||
case NET_VPN4:
|
case NET_VPN4:
|
||||||
case NET_ROA4:
|
case NET_ROA4:
|
||||||
return net_route_ip4(&tab->fib, (net_addr_ip4 *) n0);
|
return net_route_ip4(tab, (net_addr_ip4 *) n0);
|
||||||
|
|
||||||
case NET_IP6:
|
case NET_IP6:
|
||||||
case NET_VPN6:
|
case NET_VPN6:
|
||||||
case NET_ROA6:
|
case NET_ROA6:
|
||||||
return net_route_ip6(&tab->fib, (net_addr_ip6 *) n0);
|
return net_route_ip6(tab, (net_addr_ip6 *) n0);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user