diff options
Diffstat (limited to 'nest/rt-fib.c')
-rw-r--r-- | nest/rt-fib.c | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/nest/rt-fib.c b/nest/rt-fib.c index 24a7facc..18ccbfc3 100644 --- a/nest/rt-fib.c +++ b/nest/rt-fib.c @@ -92,8 +92,7 @@ fib_ht_free(struct fib_node **h) } -static u32 -fib_hash(struct fib *f, const net_addr *a); +static inline u32 fib_hash(struct fib *f, const net_addr *a); /** * fib_init - initialize a new FIB @@ -198,24 +197,11 @@ fib_rehash(struct fib *f, int step) }) -static u32 +static inline u32 fib_hash(struct fib *f, const net_addr *a) { - ASSERT(f->addr_type == a->type); - - switch (f->addr_type) - { - case NET_IP4: return FIB_HASH(f, a, ip4); - case NET_IP6: return FIB_HASH(f, a, ip6); - case NET_VPN4: return FIB_HASH(f, a, vpn4); - case NET_VPN6: return FIB_HASH(f, a, vpn6); - case NET_ROA4: return FIB_HASH(f, a, roa4); - case NET_ROA6: return FIB_HASH(f, a, roa6); - case NET_FLOW4: return FIB_HASH(f, a, flow4); - case NET_FLOW6: return FIB_HASH(f, a, flow6); - case NET_MPLS: return FIB_HASH(f, a, mpls); - default: bug("invalid type"); - } + /* Same as FIB_HASH() */ + return net_hash(a) >> f->hash_shift; } void * @@ -250,6 +236,7 @@ fib_find(struct fib *f, const net_addr *a) case NET_ROA6: return FIB_FIND(f, a, roa6); case NET_FLOW4: return FIB_FIND(f, a, flow4); case NET_FLOW6: return FIB_FIND(f, a, flow6); + case NET_IP6_SADR: return FIB_FIND(f, a, ip6_sadr); case NET_MPLS: return FIB_FIND(f, a, mpls); default: bug("invalid type"); } @@ -270,6 +257,7 @@ fib_insert(struct fib *f, const net_addr *a, struct fib_node *e) case NET_ROA6: FIB_INSERT(f, a, e, roa6); return; case NET_FLOW4: FIB_INSERT(f, a, e, flow4); return; case NET_FLOW6: FIB_INSERT(f, a, e, flow6); return; + case NET_IP6_SADR: FIB_INSERT(f, a, e, ip6_sadr); return; case NET_MPLS: FIB_INSERT(f, a, e, mpls); return; default: bug("invalid type"); } @@ -617,7 +605,7 @@ fib_histogram(struct fib *f) for (e = f->hash_table[i]; e != NULL; e = e->next) j++; if (j > 0) - log(L_WARN "Histogram line %d: %d", i, j); + log(L_WARN "Histogram line %d: %d", i, j); } log(L_WARN "Histogram dump end"); |