summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/table.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/table.c b/lib/table.c
index e40e6707..fcb7ecc0 100644
--- a/lib/table.c
+++ b/lib/table.c
@@ -258,16 +258,18 @@ struct route_node *
route_node_lookup (struct route_table *table, struct prefix *p)
{
struct route_node *node;
+ u_char prefixlen = p->prefixlen;
+ const u_char *prefix = &p->u.prefix;
node = table->top;
- while (node && node->p.prefixlen <= p->prefixlen &&
+ while (node && node->p.prefixlen <= prefixlen &&
prefix_match (&node->p, p))
{
- if (node->p.prefixlen == p->prefixlen)
+ if (node->p.prefixlen == prefixlen)
return node->info ? route_lock_node (node) : NULL;
- node = node->link[prefix_bit(&p->u.prefix, node->p.prefixlen)];
+ node = node->link[prefix_bit(prefix, node->p.prefixlen)];
}
return NULL;
@@ -280,17 +282,19 @@ route_node_get (struct route_table *table, struct prefix *p)
struct route_node *new;
struct route_node *node;
struct route_node *match;
+ u_char prefixlen = p->prefixlen;
+ const u_char *prefix = &p->u.prefix;
match = NULL;
node = table->top;
- while (node && node->p.prefixlen <= p->prefixlen &&
+ while (node && node->p.prefixlen <= prefixlen &&
prefix_match (&node->p, p))
{
- if (node->p.prefixlen == p->prefixlen)
+ if (node->p.prefixlen == prefixlen)
return route_lock_node (node);
-
+
match = node;
- node = node->link[prefix_bit(&p->u.prefix, node->p.prefixlen)];
+ node = node->link[prefix_bit(prefix, node->p.prefixlen)];
}
if (node == NULL)