ospf6d: Review comment fixes

This commit is ease reviewing the review comment fixes.

Signed:-off-by: Mobashshera Rasool <mrasool@vmware.com>
This commit is contained in:
Mobashshera Rasool 2021-07-14 17:55:43 +00:00
parent 8440558257
commit 789828186e
3 changed files with 213 additions and 201 deletions

View File

@ -1328,22 +1328,21 @@ ospf6_external_aggr_match(struct ospf6 *ospf6, struct prefix *p)
{
struct route_node *node;
node = route_node_match(ospf6->rt_aggr_tbl, (struct prefix *)p);
if (node) {
node = route_node_match(ospf6->rt_aggr_tbl, p);
if (node == NULL)
return NULL;
if (IS_OSPF6_DEBUG_AGGR) {
if (node->info) {
struct ospf6_external_aggr_rt *ag = node->info;
zlog_debug("%s: Matching aggregator found.prefix: %pFX Aggregator %pFX",
__func__,
p,
&ag->p);
}
}
route_unlock_node(node);
return node->info;
}
return NULL;
}
void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
@ -2942,8 +2941,7 @@ ospf6_originate_summary_lsa(struct ospf6 *ospf6,
* then it need to be refreshed and originate bit should
* be set.
*/
if (lsa && prefix_same((struct prefix *)&aggr->p,
(struct prefix *)&rt->prefix)) {
if (lsa && prefix_same(&aggr->p, &rt->prefix)) {
if (IS_OSPF6_DEBUG_AGGR)
zlog_debug("%s: External route prefix is same as aggr so refreshing LSA(%pFX)",
__PRETTY_FUNCTION__,
@ -3034,47 +3032,16 @@ ospf6_asbr_summary_config_delete(struct ospf6 *ospf6, struct route_node *rn)
route_unlock_node(rn);
}
static void ospf6_handle_external_aggr_update(struct ospf6 *ospf6)
static int
ospf6_handle_external_aggr_modify(struct ospf6 *ospf6,
struct ospf6_external_aggr_rt *aggr)
{
struct route_node *rn = NULL;
unsigned int metric = 0;
int mtype;
if (IS_OSPF6_DEBUG_AGGR)
zlog_debug("%s: Process modified aggregators.", __func__);
for (rn = route_top(ospf6->rt_aggr_tbl); rn; rn = route_next(rn)) {
struct ospf6_external_aggr_rt *aggr;
struct ospf6_lsa *lsa = NULL;
struct ospf6_as_external_lsa *asel = NULL;
struct ospf6_route *rt_aggr;
unsigned int metric = 0;
route_tag_t tag = 0;
if (!rn->info)
continue;
aggr = rn->info;
if (aggr->action == OSPF6_ROUTE_AGGR_DEL) {
aggr->action = OSPF6_ROUTE_AGGR_NONE;
ospf6_asbr_summary_config_delete(ospf6, rn);
if (OSPF6_EXTERNAL_RT_COUNT(aggr))
hash_clean(aggr->match_extnl_hash,
(void *)ospf6_aggr_handle_external_info);
hash_free(aggr->match_extnl_hash);
XFREE(MTYPE_OSPF6_EXTERNAL_RT_AGGR, aggr);
} else if (aggr->action == OSPF6_ROUTE_AGGR_MODIFY) {
aggr->action = OSPF6_ROUTE_AGGR_NONE;
/* Check if tag/metric/metric-type modified */
if (CHECK_FLAG(aggr->aggrflags,
OSPF6_EXTERNAL_AGGRT_ORIGINATED)
&& !CHECK_FLAG(aggr->aggrflags,
OSPF6_EXTERNAL_AGGRT_NO_ADVERTISE)) {
int mtype;
lsa = ospf6_lsdb_lookup(
htons(OSPF6_LSTYPE_AS_EXTERNAL),
@ -3086,7 +3053,7 @@ static void ospf6_handle_external_aggr_update(struct ospf6 *ospf6)
__func__,
&aggr->p);
continue;
return OSPF6_FAILURE;
}
asel = (struct ospf6_as_external_lsa *)
@ -3122,6 +3089,51 @@ static void ospf6_handle_external_aggr_update(struct ospf6 *ospf6)
aggr->route,
ospf6);
}
return OSPF6_SUCCESS;
}
static void ospf6_handle_external_aggr_update(struct ospf6 *ospf6)
{
struct route_node *rn = NULL;
int ret;
if (IS_OSPF6_DEBUG_AGGR)
zlog_debug("%s: Process modified aggregators.", __func__);
for (rn = route_top(ospf6->rt_aggr_tbl); rn; rn = route_next(rn)) {
struct ospf6_external_aggr_rt *aggr;
if (!rn->info)
continue;
aggr = rn->info;
if (aggr->action == OSPF6_ROUTE_AGGR_DEL) {
aggr->action = OSPF6_ROUTE_AGGR_NONE;
ospf6_asbr_summary_config_delete(ospf6, rn);
if (OSPF6_EXTERNAL_RT_COUNT(aggr))
hash_clean(aggr->match_extnl_hash,
ospf6_aggr_handle_external_info);
hash_free(aggr->match_extnl_hash);
XFREE(MTYPE_OSPF6_EXTERNAL_RT_AGGR, aggr);
} else if (aggr->action == OSPF6_ROUTE_AGGR_MODIFY) {
aggr->action = OSPF6_ROUTE_AGGR_NONE;
/* Check if tag/metric/metric-type modified */
if (CHECK_FLAG(aggr->aggrflags,
OSPF6_EXTERNAL_AGGRT_ORIGINATED)
&& !CHECK_FLAG(aggr->aggrflags,
OSPF6_EXTERNAL_AGGRT_NO_ADVERTISE)) {
ret = ospf6_handle_external_aggr_modify(ospf6,
aggr);
if (ret == OSPF6_FAILURE)
continue;
}
/* Advertise option modified ?
@ -3145,7 +3157,7 @@ void ospf6_external_aggregator_free(struct ospf6_external_aggr_rt *aggr)
{
if (OSPF6_EXTERNAL_RT_COUNT(aggr))
hash_clean(aggr->match_extnl_hash,
(void *)ospf6_aggr_unlink_external_info);
ospf6_aggr_unlink_external_info);
if (IS_OSPF6_DEBUG_AGGR)
zlog_debug("%s: Release the aggregator Address(%pFX)",
@ -3168,8 +3180,10 @@ ospf6_delete_all_marked_aggregators(struct ospf6 *ospf6)
* which are marked as DELETE. Set action to NONE for remaining
* aggregators
*/
for (rn = route_top(ospf6->rt_aggr_tbl); rn; rn = route_next(rn))
if (rn->info) {
for (rn = route_top(ospf6->rt_aggr_tbl); rn; rn = route_next(rn)) {
if (!rn->info)
continue;
aggr = rn->info;
if (aggr->action != OSPF6_ROUTE_AGGR_DEL) {
@ -3223,8 +3237,7 @@ static void ospf6_handle_aggregated_exnl_rt(struct ospf6 *ospf6,
* and aggegate prefix is same
* If same dont flush the originated external LSA.
*/
if (prefix_same((struct prefix *)&aggr->p,
(struct prefix *)&rt->prefix)) {
if (prefix_same(&aggr->p, &rt->prefix)) {
if (IS_OSPF6_DEBUG_AGGR)
zlog_debug("%s: External Route prefix same as Aggregator(%pFX), so dont flush.",
__func__,
@ -3269,7 +3282,9 @@ ospf6_handle_external_aggr_add(struct ospf6 *ospf6)
for (rt = ospf6_route_head(ospf6->external_table); rt;
rt = ospf6_route_next(rt)) {
ei = rt->route_option;
if (ei != NULL) {
if (ei == NULL)
continue;
if (is_default_prefix(&rt->prefix))
continue;
@ -3301,7 +3316,6 @@ ospf6_handle_external_aggr_add(struct ospf6 *ospf6)
ospf6_handle_exnl_rt_after_aggr_del(
ospf6, rt);
}
}
}
static int ospf6_asbr_summary_process(struct thread *thread)
@ -3373,7 +3387,7 @@ int ospf6_asbr_external_rt_advertise(struct ospf6 *ospf6,
struct route_node *rn;
struct ospf6_external_aggr_rt *aggr;
rn = route_node_lookup(ospf6->rt_aggr_tbl, (struct prefix *)p);
rn = route_node_lookup(ospf6->rt_aggr_tbl, p);
if (!rn)
return OSPF6_INVALID;
@ -3417,8 +3431,7 @@ static bool ospf6_external_rt_hash_cmp(const void *d1, const void *d2)
const struct ospf6_route *rt1 = d1;
const struct ospf6_route *rt2 = d2;
return prefix_same((struct prefix *)&rt1->prefix,
(struct prefix *)&rt2->prefix);
return prefix_same(&rt1->prefix, &rt2->prefix);
}
static struct ospf6_external_aggr_rt *
@ -3426,16 +3439,10 @@ ospf6_external_aggr_new(struct prefix *p)
{
struct ospf6_external_aggr_rt *aggr;
aggr = (struct ospf6_external_aggr_rt *)XCALLOC(
MTYPE_OSPF6_EXTERNAL_RT_AGGR,
aggr = XCALLOC(MTYPE_OSPF6_EXTERNAL_RT_AGGR,
sizeof(struct ospf6_external_aggr_rt));
if (!aggr)
return NULL;
aggr->p.family = p->family;
prefix_copy(&aggr->p, p);
aggr->p.prefixlen = p->prefixlen;
aggr->metric = -1;
aggr->mtype = DEFAULT_METRIC_TYPE;
aggr->match_extnl_hash = hash_create(ospf6_external_rt_hash_key,
@ -3454,7 +3461,7 @@ static void ospf6_external_aggr_add(struct ospf6 *ospf6,
__func__,
&aggr->p);
rn = route_node_get(ospf6->rt_aggr_tbl, (struct prefix *)&aggr->p);
rn = route_node_get(ospf6->rt_aggr_tbl, &aggr->p);
if (rn->info)
route_unlock_node(rn);
else
@ -3503,7 +3510,7 @@ ospf6_external_aggr_config_lookup(struct ospf6 *ospf6, struct prefix *p)
{
struct route_node *rn;
rn = route_node_lookup(ospf6->rt_aggr_tbl, (struct prefix *)p);
rn = route_node_lookup(ospf6->rt_aggr_tbl, p);
if (rn) {
route_unlock_node(rn);
return rn->info;
@ -3559,7 +3566,7 @@ int ospf6_external_aggr_config_unset(struct ospf6 *ospf6,
struct route_node *rn;
struct ospf6_external_aggr_rt *aggr;
rn = route_node_lookup(ospf6->rt_aggr_tbl, (struct prefix *)p);
rn = route_node_lookup(ospf6->rt_aggr_tbl, p);
if (!rn)
return OSPF6_INVALID;

View File

@ -209,7 +209,7 @@ struct ospf6_lsa *ospf6_find_external_lsa(struct ospf6 *ospf6, struct prefix *p)
return NULL;
}
info = (struct ospf6_external_info *)(match->route_option);
info = match->route_option;
assert(info);
lsa = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_AS_EXTERNAL),

View File

@ -1929,7 +1929,7 @@ ospf6_print_json_external_routes_walkcb(struct hash_bucket *bucket, void *arg)
prefix2str(&rt->prefix, buf, sizeof(buf));
snprintf(exnalbuf, 20, "Exnl Addr-%d", count);
snprintf(exnalbuf, sizeof(exnalbuf), "Exnl Addr-%d", count);
json_object_string_add(json, exnalbuf, buf);
@ -1958,8 +1958,10 @@ ospf6_show_summary_address(struct vty *vty, struct ospf6 *ospf6,
ospf6->aggr_delay_interval);
}
for (rn = route_top(ospf6->rt_aggr_tbl); rn; rn = route_next(rn))
if (rn->info) {
for (rn = route_top(ospf6->rt_aggr_tbl); rn; rn = route_next(rn)) {
if (!rn->info)
continue;
struct ospf6_external_aggr_rt *aggr = rn->info;
json_object *json_aggr = NULL;
char buf[PREFIX2STR_BUFFER];
@ -2129,19 +2131,22 @@ static int ospf6_asbr_summary_config_write(struct vty *vty, struct ospf6 *ospf6)
ospf6->aggr_delay_interval);
/* print 'summary-address A:B::C:D/M' */
for (rn = route_top(ospf6->rt_aggr_tbl); rn; rn = route_next(rn))
if (rn->info) {
for (rn = route_top(ospf6->rt_aggr_tbl); rn; rn = route_next(rn)) {
if (!rn->info)
continue;
aggr = rn->info;
prefix2str(&aggr->p, buf, sizeof(buf));
vty_out(vty, " summary-address %s ", buf);
vty_out(vty, " summary-address %s", buf);
if (aggr->tag)
vty_out(vty, " tag %u ", aggr->tag);
vty_out(vty, " tag %u", aggr->tag);
if (aggr->metric != -1)
vty_out(vty, " metric %d ", aggr->metric);
vty_out(vty, " metric %d", aggr->metric);
if (aggr->mtype != DEFAULT_METRIC_TYPE)
vty_out(vty, " metric-type %d ", aggr->mtype);
vty_out(vty, " metric-type %d", aggr->mtype);
if (CHECK_FLAG(aggr->aggrflags,
OSPF6_EXTERNAL_AGGRT_NO_ADVERTISE))