mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 12:25:02 +00:00
[ospfd] trivial: consolidate LSDB delete code into single function
2006-08-04 Paul Jakma <paul.jakma@sun.com> * ospf_lsdb.c: (ospf_lsdb_delete_entry) new function, consolidate exact same functionality replicated in other functions. (ospf_lsdb_add) Strip out code by using ospf_lsdb_delete_entry. (ospf_lsdb_delete) ditto. (ospf_lsdb_delete_all) ditto.
This commit is contained in:
parent
66c454f2a5
commit
ba122e779d
@ -1,3 +1,11 @@
|
|||||||
|
2006-08-04 Paul Jakma <paul.jakma@sun.com>
|
||||||
|
|
||||||
|
* ospf_lsdb.c: (ospf_lsdb_delete_entry) new function, consolidate
|
||||||
|
exact same functionality replicated in other functions.
|
||||||
|
(ospf_lsdb_add) Strip out code by using ospf_lsdb_delete_entry.
|
||||||
|
(ospf_lsdb_delete) ditto.
|
||||||
|
(ospf_lsdb_delete_all) ditto.
|
||||||
|
|
||||||
2006-07-27 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
|
2006-07-27 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
|
||||||
|
|
||||||
* ospfd.c: (ospf_router_id_update) Fix and document the algorithm for
|
* ospfd.c: (ospf_router_id_update) Fix and document the algorithm for
|
||||||
|
@ -81,6 +81,31 @@ lsdb_prefix_set (struct prefix_ls *lp, struct ospf_lsa *lsa)
|
|||||||
lp->adv_router = lsa->data->adv_router;
|
lp->adv_router = lsa->data->adv_router;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ospf_lsdb_delete_entry (struct ospf_lsdb *lsdb, struct route_node *rn)
|
||||||
|
{
|
||||||
|
struct ospf_lsa *lsa = rn->info;
|
||||||
|
|
||||||
|
if (!lsa)
|
||||||
|
return;
|
||||||
|
|
||||||
|
assert (rn->table == lsdb->type[lsa->data->type].db);
|
||||||
|
|
||||||
|
if (IS_LSA_SELF (lsa))
|
||||||
|
lsdb->type[lsa->data->type].count_self--;
|
||||||
|
lsdb->type[lsa->data->type].count--;
|
||||||
|
lsdb->type[lsa->data->type].checksum -= ntohs(lsa->data->checksum);
|
||||||
|
lsdb->total--;
|
||||||
|
rn->info = NULL;
|
||||||
|
route_unlock_node (rn);
|
||||||
|
#ifdef MONITOR_LSDB_CHANGE
|
||||||
|
if (lsdb->del_lsa_hook != NULL)
|
||||||
|
(* lsdb->del_lsa_hook)(lsa);
|
||||||
|
#endif /* MONITOR_LSDB_CHANGE */
|
||||||
|
ospf_lsa_unlock (&lsa); /* lsdb */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Add new LSA to lsdb. */
|
/* Add new LSA to lsdb. */
|
||||||
void
|
void
|
||||||
ospf_lsdb_add (struct ospf_lsdb *lsdb, struct ospf_lsa *lsa)
|
ospf_lsdb_add (struct ospf_lsdb *lsdb, struct ospf_lsa *lsa)
|
||||||
@ -88,36 +113,30 @@ ospf_lsdb_add (struct ospf_lsdb *lsdb, struct ospf_lsa *lsa)
|
|||||||
struct route_table *table;
|
struct route_table *table;
|
||||||
struct prefix_ls lp;
|
struct prefix_ls lp;
|
||||||
struct route_node *rn;
|
struct route_node *rn;
|
||||||
struct ospf_lsa *old;
|
|
||||||
|
|
||||||
table = lsdb->type[lsa->data->type].db;
|
table = lsdb->type[lsa->data->type].db;
|
||||||
lsdb_prefix_set (&lp, lsa);
|
lsdb_prefix_set (&lp, lsa);
|
||||||
rn = route_node_get (table, (struct prefix *)&lp);
|
rn = route_node_get (table, (struct prefix *)&lp);
|
||||||
if (!rn->info)
|
|
||||||
{
|
/* nothing to do? */
|
||||||
if (IS_LSA_SELF (lsa))
|
if (rn->info && rn->info == lsa)
|
||||||
lsdb->type[lsa->data->type].count_self++;
|
return;
|
||||||
lsdb->type[lsa->data->type].count++;
|
|
||||||
lsdb->total++;
|
/* purge old entry? */
|
||||||
}
|
if (rn->info)
|
||||||
else
|
ospf_lsdb_delete_entry (lsdb, rn);
|
||||||
{
|
|
||||||
if (rn->info == lsa)
|
|
||||||
return;
|
|
||||||
|
|
||||||
old = rn->info;
|
|
||||||
lsdb->type[old->data->type].checksum -= ntohs(old->data->checksum);
|
|
||||||
|
|
||||||
ospf_lsa_unlock (&rn->info);
|
if (IS_LSA_SELF (lsa))
|
||||||
route_unlock_node (rn);
|
lsdb->type[lsa->data->type].count_self++;
|
||||||
}
|
lsdb->type[lsa->data->type].count++;
|
||||||
|
lsdb->total++;
|
||||||
|
|
||||||
#ifdef MONITOR_LSDB_CHANGE
|
#ifdef MONITOR_LSDB_CHANGE
|
||||||
if (lsdb->new_lsa_hook != NULL)
|
if (lsdb->new_lsa_hook != NULL)
|
||||||
(* lsdb->new_lsa_hook)(lsa);
|
(* lsdb->new_lsa_hook)(lsa);
|
||||||
#endif /* MONITOR_LSDB_CHANGE */
|
#endif /* MONITOR_LSDB_CHANGE */
|
||||||
lsdb->type[lsa->data->type].checksum += ntohs(lsa->data->checksum);
|
lsdb->type[lsa->data->type].checksum += ntohs(lsa->data->checksum);
|
||||||
rn->info = ospf_lsa_lock (lsa);
|
rn->info = ospf_lsa_lock (lsa); /* lsdb */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -146,24 +165,11 @@ ospf_lsdb_delete (struct ospf_lsdb *lsdb, struct ospf_lsa *lsa)
|
|||||||
table = lsdb->type[lsa->data->type].db;
|
table = lsdb->type[lsa->data->type].db;
|
||||||
lsdb_prefix_set (&lp, lsa);
|
lsdb_prefix_set (&lp, lsa);
|
||||||
rn = route_node_lookup (table, (struct prefix *) &lp);
|
rn = route_node_lookup (table, (struct prefix *) &lp);
|
||||||
if (rn)
|
if (rn && (rn->info == lsa))
|
||||||
if (rn->info == lsa)
|
{
|
||||||
{
|
ospf_lsdb_delete_entry (lsdb, rn);
|
||||||
if (IS_LSA_SELF (lsa))
|
route_unlock_node (rn); /* route_node_lookup */
|
||||||
lsdb->type[lsa->data->type].count_self--;
|
}
|
||||||
lsdb->type[lsa->data->type].count--;
|
|
||||||
lsdb->type[lsa->data->type].checksum -= ntohs(lsa->data->checksum);
|
|
||||||
lsdb->total--;
|
|
||||||
rn->info = NULL;
|
|
||||||
route_unlock_node (rn);
|
|
||||||
route_unlock_node (rn);
|
|
||||||
#ifdef MONITOR_LSDB_CHANGE
|
|
||||||
if (lsdb->del_lsa_hook != NULL)
|
|
||||||
(* lsdb->del_lsa_hook)(lsa);
|
|
||||||
#endif /* MONITOR_LSDB_CHANGE */
|
|
||||||
ospf_lsa_unlock (&lsa);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -171,28 +177,14 @@ ospf_lsdb_delete_all (struct ospf_lsdb *lsdb)
|
|||||||
{
|
{
|
||||||
struct route_table *table;
|
struct route_table *table;
|
||||||
struct route_node *rn;
|
struct route_node *rn;
|
||||||
struct ospf_lsa *lsa;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = OSPF_MIN_LSA; i < OSPF_MAX_LSA; i++)
|
for (i = OSPF_MIN_LSA; i < OSPF_MAX_LSA; i++)
|
||||||
{
|
{
|
||||||
table = lsdb->type[i].db;
|
table = lsdb->type[i].db;
|
||||||
for (rn = route_top (table); rn; rn = route_next (rn))
|
for (rn = route_top (table); rn; rn = route_next (rn))
|
||||||
if ((lsa = (rn->info)) != NULL)
|
if (rn->info != NULL)
|
||||||
{
|
ospf_lsdb_delete_entry (lsdb, rn);
|
||||||
if (IS_LSA_SELF (lsa))
|
|
||||||
lsdb->type[i].count_self--;
|
|
||||||
lsdb->type[i].count--;
|
|
||||||
lsdb->type[i].checksum -= ntohs(lsa->data->checksum);
|
|
||||||
lsdb->total--;
|
|
||||||
rn->info = NULL;
|
|
||||||
route_unlock_node (rn);
|
|
||||||
#ifdef MONITOR_LSDB_CHANGE
|
|
||||||
if (lsdb->del_lsa_hook != NULL)
|
|
||||||
(* lsdb->del_lsa_hook)(lsa);
|
|
||||||
#endif /* MONITOR_LSDB_CHANGE */
|
|
||||||
ospf_lsa_unlock (&lsa);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user