summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_table.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgp_table.c')
-rw-r--r--bgpd/bgp_table.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/bgpd/bgp_table.c b/bgpd/bgp_table.c
index a249c23d..5d1ebf3d 100644
--- a/bgpd/bgp_table.c
+++ b/bgpd/bgp_table.c
@@ -30,7 +30,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
static void bgp_node_delete (struct bgp_node *);
static void bgp_table_free (struct bgp_table *);
-
+
struct bgp_table *
bgp_table_init (afi_t afi, safi_t safi)
{
@@ -42,7 +42,7 @@ bgp_table_init (afi_t afi, safi_t safi)
rt->type = BGP_TABLE_MAIN;
rt->afi = afi;
rt->safi = safi;
-
+
return rt;
}
@@ -83,7 +83,7 @@ static struct bgp_node *
bgp_node_set (struct bgp_table *table, struct prefix *prefix)
{
struct bgp_node *node;
-
+
node = bgp_node_create ();
prefix_copy (&node->p, prefix);
@@ -96,6 +96,7 @@ bgp_node_set (struct bgp_table *table, struct prefix *prefix)
static void
bgp_node_free (struct bgp_node *node)
{
+ node->lock = -54321 ;
XFREE (MTYPE_BGP_NODE, node);
}
@@ -105,7 +106,7 @@ bgp_table_free (struct bgp_table *rt)
{
struct bgp_node *tmp_node;
struct bgp_node *node;
-
+
if (rt == NULL)
return;
@@ -128,11 +129,17 @@ bgp_table_free (struct bgp_table *rt)
continue;
}
+ assert( (node->info == NULL)
+ && (node->adj_out == NULL)
+ && (node->adj_in == NULL)
+ && (node->on_wq == 0) ) ;
+
tmp_node = node;
node = node->parent;
tmp_node->table->count--;
tmp_node->lock = 0; /* to cause assert if unlocked after this */
+
bgp_node_free (tmp_node);
if (node != NULL)
@@ -147,21 +154,22 @@ bgp_table_free (struct bgp_table *rt)
break;
}
}
-
+
assert (rt->count == 0);
if (rt->owner)
{
- peer_unlock (rt->owner);
+ bgp_peer_unlock (rt->owner);
rt->owner = NULL;
}
+ rt->lock = -54321 ;
XFREE (MTYPE_BGP_TABLE, rt);
return;
}
/* Utility mask array. */
-static u_char maskbit[] =
+static const u_char maskbit[] =
{
0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff
};
@@ -241,7 +249,7 @@ bgp_node_match (const struct bgp_table *table, struct prefix *p)
/* Walk down tree. If there is matched route then store it to
matched. */
- while (node && node->p.prefixlen <= p->prefixlen &&
+ while (node && node->p.prefixlen <= p->prefixlen &&
prefix_match (&node->p, p))
{
if (node->info)
@@ -292,7 +300,7 @@ bgp_node_lookup (const struct bgp_table *table, struct prefix *p)
node = table->top;
- while (node && node->p.prefixlen <= p->prefixlen &&
+ while (node && node->p.prefixlen <= p->prefixlen &&
prefix_match (&node->p, p))
{
if (node->p.prefixlen == p->prefixlen && node->info)
@@ -314,7 +322,7 @@ bgp_node_get (struct bgp_table *const table, struct prefix *p)
match = NULL;
node = table->top;
- while (node && node->p.prefixlen <= p->prefixlen &&
+ while (node && node->p.prefixlen <= p->prefixlen &&
prefix_match (&node->p, p))
{
if (node->p.prefixlen == p->prefixlen)
@@ -357,7 +365,7 @@ bgp_node_get (struct bgp_table *const table, struct prefix *p)
}
table->count++;
bgp_lock_node (new);
-
+
return new;
}
@@ -370,6 +378,7 @@ bgp_node_delete (struct bgp_node *node)
assert (node->lock == 0);
assert (node->info == NULL);
+ assert (node->on_wq == 0) ;
if (node->l_left && node->l_right)
return;
@@ -393,9 +402,9 @@ bgp_node_delete (struct bgp_node *node)
}
else
node->table->top = child;
-
+
node->table->count--;
-
+
bgp_node_free (node);
/* If parent node is stub then delete it also. */