diff options
author | whitespace / reindent <invalid@invalid.invalid> | 2017-08-09 11:49:42 +0200 |
---|---|---|
committer | whitespace / reindent <invalid@invalid.invalid> | 2017-08-09 12:03:17 +0200 |
commit | ac4d0be5874fafd14212d6007fff7495edc9b152 (patch) | |
tree | 5e2f0d3189de928c849f9983406389ade3b098cb /ospfd/ospf_lsdb.c | |
parent | Merge pull request #920 from opensourcerouting/static-routes-ifindex-update-3.0 (diff) | |
download | frr-ac4d0be5874fafd14212d6007fff7495edc9b152.tar.xz frr-ac4d0be5874fafd14212d6007fff7495edc9b152.zip |
*: reindentreindent-3.0-after
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'ospfd/ospf_lsdb.c')
-rw-r--r-- | ospfd/ospf_lsdb.c | 447 |
1 files changed, 211 insertions, 236 deletions
diff --git a/ospfd/ospf_lsdb.c b/ospfd/ospf_lsdb.c index b92e7494a..2de4318a8 100644 --- a/ospfd/ospf_lsdb.c +++ b/ospfd/ospf_lsdb.c @@ -32,299 +32,274 @@ #include "ospfd/ospf_lsa.h" #include "ospfd/ospf_lsdb.h" -struct ospf_lsdb * -ospf_lsdb_new () +struct ospf_lsdb *ospf_lsdb_new() { - struct ospf_lsdb *new; + struct ospf_lsdb *new; - new = XCALLOC (MTYPE_OSPF_LSDB, sizeof (struct ospf_lsdb)); - ospf_lsdb_init (new); + new = XCALLOC(MTYPE_OSPF_LSDB, sizeof(struct ospf_lsdb)); + ospf_lsdb_init(new); - return new; + return new; } -void -ospf_lsdb_init (struct ospf_lsdb *lsdb) +void ospf_lsdb_init(struct ospf_lsdb *lsdb) { - int i; - - for (i = OSPF_MIN_LSA; i < OSPF_MAX_LSA; i++) - lsdb->type[i].db = route_table_init (); + int i; + + for (i = OSPF_MIN_LSA; i < OSPF_MAX_LSA; i++) + lsdb->type[i].db = route_table_init(); } -void -ospf_lsdb_free (struct ospf_lsdb *lsdb) +void ospf_lsdb_free(struct ospf_lsdb *lsdb) { - ospf_lsdb_cleanup (lsdb); - XFREE (MTYPE_OSPF_LSDB, lsdb); + ospf_lsdb_cleanup(lsdb); + XFREE(MTYPE_OSPF_LSDB, lsdb); } -void -ospf_lsdb_cleanup (struct ospf_lsdb *lsdb) +void ospf_lsdb_cleanup(struct ospf_lsdb *lsdb) { - int i; - assert (lsdb); - assert (lsdb->total == 0); - - ospf_lsdb_delete_all (lsdb); - - for (i = OSPF_MIN_LSA; i < OSPF_MAX_LSA; i++) - route_table_finish (lsdb->type[i].db); + int i; + assert(lsdb); + assert(lsdb->total == 0); + + ospf_lsdb_delete_all(lsdb); + + for (i = OSPF_MIN_LSA; i < OSPF_MAX_LSA; i++) + route_table_finish(lsdb->type[i].db); } -void -ls_prefix_set (struct prefix_ls *lp, struct ospf_lsa *lsa) +void ls_prefix_set(struct prefix_ls *lp, struct ospf_lsa *lsa) { - if (lp && lsa && lsa->data) - { - lp->family = 0; - lp->prefixlen = 64; - lp->id = lsa->data->id; - lp->adv_router = lsa->data->adv_router; - } + if (lp && lsa && lsa->data) { + lp->family = 0; + lp->prefixlen = 64; + lp->id = lsa->data->id; + lp->adv_router = lsa->data->adv_router; + } } -static void -ospf_lsdb_delete_entry (struct ospf_lsdb *lsdb, struct route_node *rn) +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); + 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; + 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. */ -void -ospf_lsdb_add (struct ospf_lsdb *lsdb, struct ospf_lsa *lsa) +void ospf_lsdb_add(struct ospf_lsdb *lsdb, struct ospf_lsa *lsa) { - struct route_table *table; - struct prefix_ls lp; - struct route_node *rn; - - table = lsdb->type[lsa->data->type].db; - ls_prefix_set (&lp, lsa); - rn = route_node_get (table, (struct prefix *)&lp); - - /* nothing to do? */ - if (rn->info && rn->info == lsa) - { - route_unlock_node (rn); - return; - } - - /* purge old entry? */ - if (rn->info) - ospf_lsdb_delete_entry (lsdb, rn); - - if (IS_LSA_SELF (lsa)) - lsdb->type[lsa->data->type].count_self++; - lsdb->type[lsa->data->type].count++; - lsdb->total++; + struct route_table *table; + struct prefix_ls lp; + struct route_node *rn; + + table = lsdb->type[lsa->data->type].db; + ls_prefix_set(&lp, lsa); + rn = route_node_get(table, (struct prefix *)&lp); + + /* nothing to do? */ + if (rn->info && rn->info == lsa) { + route_unlock_node(rn); + return; + } + + /* purge old entry? */ + if (rn->info) + ospf_lsdb_delete_entry(lsdb, rn); + + if (IS_LSA_SELF(lsa)) + lsdb->type[lsa->data->type].count_self++; + lsdb->type[lsa->data->type].count++; + lsdb->total++; #ifdef MONITOR_LSDB_CHANGE - if (lsdb->new_lsa_hook != NULL) - (* lsdb->new_lsa_hook)(lsa); + if (lsdb->new_lsa_hook != NULL) + (*lsdb->new_lsa_hook)(lsa); #endif /* MONITOR_LSDB_CHANGE */ - lsdb->type[lsa->data->type].checksum += ntohs(lsa->data->checksum); - rn->info = ospf_lsa_lock (lsa); /* lsdb */ + lsdb->type[lsa->data->type].checksum += ntohs(lsa->data->checksum); + rn->info = ospf_lsa_lock(lsa); /* lsdb */ } -void -ospf_lsdb_delete (struct ospf_lsdb *lsdb, struct ospf_lsa *lsa) +void ospf_lsdb_delete(struct ospf_lsdb *lsdb, struct ospf_lsa *lsa) { - struct route_table *table; - struct prefix_ls lp; - struct route_node *rn; - - if (!lsdb) - { - zlog_warn ("%s: Called with NULL LSDB", __func__); - if (lsa) - zlog_warn ("LSA[Type%d:%s]: LSA %p, lsa->lsdb %p", - lsa->data->type, inet_ntoa (lsa->data->id), - (void *)lsa, (void *)lsa->lsdb); - return; - } - - if (!lsa) - { - zlog_warn ("%s: Called with NULL LSA", __func__); - return; - } - - assert (lsa->data->type < OSPF_MAX_LSA); - table = lsdb->type[lsa->data->type].db; - ls_prefix_set (&lp, lsa); - if ((rn = route_node_lookup (table, (struct prefix *) &lp))) - { - if (rn->info == lsa) - ospf_lsdb_delete_entry (lsdb, rn); - route_unlock_node (rn); /* route_node_lookup */ - } + struct route_table *table; + struct prefix_ls lp; + struct route_node *rn; + + if (!lsdb) { + zlog_warn("%s: Called with NULL LSDB", __func__); + if (lsa) + zlog_warn("LSA[Type%d:%s]: LSA %p, lsa->lsdb %p", + lsa->data->type, inet_ntoa(lsa->data->id), + (void *)lsa, (void *)lsa->lsdb); + return; + } + + if (!lsa) { + zlog_warn("%s: Called with NULL LSA", __func__); + return; + } + + assert(lsa->data->type < OSPF_MAX_LSA); + table = lsdb->type[lsa->data->type].db; + ls_prefix_set(&lp, lsa); + if ((rn = route_node_lookup(table, (struct prefix *)&lp))) { + if (rn->info == lsa) + ospf_lsdb_delete_entry(lsdb, rn); + route_unlock_node(rn); /* route_node_lookup */ + } } -void -ospf_lsdb_delete_all (struct ospf_lsdb *lsdb) +void ospf_lsdb_delete_all(struct ospf_lsdb *lsdb) { - struct route_table *table; - struct route_node *rn; - int i; - - for (i = OSPF_MIN_LSA; i < OSPF_MAX_LSA; i++) - { - table = lsdb->type[i].db; - for (rn = route_top (table); rn; rn = route_next (rn)) - if (rn->info != NULL) - ospf_lsdb_delete_entry (lsdb, rn); - } + struct route_table *table; + struct route_node *rn; + int i; + + for (i = OSPF_MIN_LSA; i < OSPF_MAX_LSA; i++) { + table = lsdb->type[i].db; + for (rn = route_top(table); rn; rn = route_next(rn)) + if (rn->info != NULL) + ospf_lsdb_delete_entry(lsdb, rn); + } } -void -ospf_lsdb_clean_stat (struct ospf_lsdb *lsdb) +void ospf_lsdb_clean_stat(struct ospf_lsdb *lsdb) { - struct route_table *table; - struct route_node *rn; - struct ospf_lsa *lsa; - int i; - - for (i = OSPF_MIN_LSA; i < OSPF_MAX_LSA; i++) - { - table = lsdb->type[i].db; - for (rn = route_top (table); rn; rn = route_next (rn)) - if ((lsa = (rn->info)) != NULL) - lsa->stat = LSA_SPF_NOT_EXPLORED; - } + struct route_table *table; + struct route_node *rn; + struct ospf_lsa *lsa; + int i; + + for (i = OSPF_MIN_LSA; i < OSPF_MAX_LSA; i++) { + table = lsdb->type[i].db; + for (rn = route_top(table); rn; rn = route_next(rn)) + if ((lsa = (rn->info)) != NULL) + lsa->stat = LSA_SPF_NOT_EXPLORED; + } } -struct ospf_lsa * -ospf_lsdb_lookup (struct ospf_lsdb *lsdb, struct ospf_lsa *lsa) +struct ospf_lsa *ospf_lsdb_lookup(struct ospf_lsdb *lsdb, struct ospf_lsa *lsa) { - struct route_table *table; - struct prefix_ls lp; - struct route_node *rn; - struct ospf_lsa *find; - - table = lsdb->type[lsa->data->type].db; - ls_prefix_set (&lp, lsa); - rn = route_node_lookup (table, (struct prefix *) &lp); - if (rn) - { - find = rn->info; - route_unlock_node (rn); - return find; - } - return NULL; + struct route_table *table; + struct prefix_ls lp; + struct route_node *rn; + struct ospf_lsa *find; + + table = lsdb->type[lsa->data->type].db; + ls_prefix_set(&lp, lsa); + rn = route_node_lookup(table, (struct prefix *)&lp); + if (rn) { + find = rn->info; + route_unlock_node(rn); + return find; + } + return NULL; } -struct ospf_lsa * -ospf_lsdb_lookup_by_id (struct ospf_lsdb *lsdb, u_char type, - struct in_addr id, struct in_addr adv_router) +struct ospf_lsa *ospf_lsdb_lookup_by_id(struct ospf_lsdb *lsdb, u_char type, + struct in_addr id, + struct in_addr adv_router) { - struct route_table *table; - struct prefix_ls lp; - struct route_node *rn; - struct ospf_lsa *find; - - table = lsdb->type[type].db; - - memset (&lp, 0, sizeof (struct prefix_ls)); - lp.family = 0; - lp.prefixlen = 64; - lp.id = id; - lp.adv_router = adv_router; - - rn = route_node_lookup (table, (struct prefix *) &lp); - if (rn) - { - find = rn->info; - route_unlock_node (rn); - return find; - } - return NULL; + struct route_table *table; + struct prefix_ls lp; + struct route_node *rn; + struct ospf_lsa *find; + + table = lsdb->type[type].db; + + memset(&lp, 0, sizeof(struct prefix_ls)); + lp.family = 0; + lp.prefixlen = 64; + lp.id = id; + lp.adv_router = adv_router; + + rn = route_node_lookup(table, (struct prefix *)&lp); + if (rn) { + find = rn->info; + route_unlock_node(rn); + return find; + } + return NULL; } -struct ospf_lsa * -ospf_lsdb_lookup_by_id_next (struct ospf_lsdb *lsdb, u_char type, - struct in_addr id, struct in_addr adv_router, - int first) +struct ospf_lsa *ospf_lsdb_lookup_by_id_next(struct ospf_lsdb *lsdb, + u_char type, struct in_addr id, + struct in_addr adv_router, + int first) { - struct route_table *table; - struct prefix_ls lp; - struct route_node *rn; - struct ospf_lsa *find; - - table = lsdb->type[type].db; - - memset (&lp, 0, sizeof (struct prefix_ls)); - lp.family = 0; - lp.prefixlen = 64; - lp.id = id; - lp.adv_router = adv_router; - - if (first) - rn = route_top (table); - else - { - if ((rn = route_node_lookup (table, (struct prefix *) &lp)) == NULL) - return NULL; - rn = route_next (rn); - } - - for (; rn; rn = route_next (rn)) - if (rn->info) - break; - - if (rn && rn->info) - { - find = rn->info; - route_unlock_node (rn); - return find; - } - return NULL; + struct route_table *table; + struct prefix_ls lp; + struct route_node *rn; + struct ospf_lsa *find; + + table = lsdb->type[type].db; + + memset(&lp, 0, sizeof(struct prefix_ls)); + lp.family = 0; + lp.prefixlen = 64; + lp.id = id; + lp.adv_router = adv_router; + + if (first) + rn = route_top(table); + else { + if ((rn = route_node_lookup(table, (struct prefix *)&lp)) + == NULL) + return NULL; + rn = route_next(rn); + } + + for (; rn; rn = route_next(rn)) + if (rn->info) + break; + + if (rn && rn->info) { + find = rn->info; + route_unlock_node(rn); + return find; + } + return NULL; } -unsigned long -ospf_lsdb_count_all (struct ospf_lsdb *lsdb) +unsigned long ospf_lsdb_count_all(struct ospf_lsdb *lsdb) { - return lsdb->total; + return lsdb->total; } -unsigned long -ospf_lsdb_count (struct ospf_lsdb *lsdb, int type) +unsigned long ospf_lsdb_count(struct ospf_lsdb *lsdb, int type) { - return lsdb->type[type].count; + return lsdb->type[type].count; } -unsigned long -ospf_lsdb_count_self (struct ospf_lsdb *lsdb, int type) +unsigned long ospf_lsdb_count_self(struct ospf_lsdb *lsdb, int type) { - return lsdb->type[type].count_self; + return lsdb->type[type].count_self; } -unsigned int -ospf_lsdb_checksum (struct ospf_lsdb *lsdb, int type) +unsigned int ospf_lsdb_checksum(struct ospf_lsdb *lsdb, int type) { - return lsdb->type[type].checksum; + return lsdb->type[type].checksum; } -unsigned long -ospf_lsdb_isempty (struct ospf_lsdb *lsdb) +unsigned long ospf_lsdb_isempty(struct ospf_lsdb *lsdb) { - return (lsdb->total == 0); + return (lsdb->total == 0); } |