Merge pull request #11863 from sri-mohan1/sri-ospf-dbg1

ospfd: changes for code maintainability
This commit is contained in:
Donald Sharp 2022-08-26 10:50:21 -04:00 committed by GitHub
commit 43bb6fc8d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -371,13 +371,12 @@ void ospf_intra_add_router(struct route_table *rt, struct vertex *v,
struct router_lsa *lsa; struct router_lsa *lsa;
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug("ospf_intra_add_router: Start"); zlog_debug("%s: Start", __func__);
lsa = (struct router_lsa *)v->lsa; lsa = (struct router_lsa *)v->lsa;
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug("ospf_intra_add_router: LS ID: %pI4", zlog_debug("%s: LS ID: %pI4", __func__, &lsa->header.id);
&lsa->header.id);
if (!OSPF_IS_AREA_BACKBONE(area)) if (!OSPF_IS_AREA_BACKBONE(area))
ospf_vl_up_check(area, lsa->header.id, v); ospf_vl_up_check(area, lsa->header.id, v);
@ -392,7 +391,8 @@ void ospf_intra_add_router(struct route_table *rt, struct vertex *v,
!IS_ROUTER_LSA_EXTERNAL(lsa)) { !IS_ROUTER_LSA_EXTERNAL(lsa)) {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug(
"ospf_intra_add_router: this router is neither ASBR nor ABR, skipping it"); "%s: this router is neither ASBR nor ABR, skipping it",
__func__);
return; return;
} }
@ -434,7 +434,7 @@ void ospf_intra_add_router(struct route_table *rt, struct vertex *v,
apply_mask_ipv4(&p); apply_mask_ipv4(&p);
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug("ospf_intra_add_router: talking about %pFX", &p); zlog_debug("%s: talking about %pFX", __func__, &p);
rn = route_node_get(rt, (struct prefix *)&p); rn = route_node_get(rt, (struct prefix *)&p);
@ -449,7 +449,7 @@ void ospf_intra_add_router(struct route_table *rt, struct vertex *v,
listnode_add(rn->info, or); listnode_add(rn->info, or);
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug("ospf_intra_add_router: Stop"); zlog_debug("%s: Stop", __func__);
} }
/* RFC2328 16.1. (4). For transit network. */ /* RFC2328 16.1. (4). For transit network. */
@ -526,7 +526,7 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link,
struct ospf_path *path; struct ospf_path *path;
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug("ospf_intra_add_stub(): Start"); zlog_debug("%s: Start", __func__);
lsa = (struct router_lsa *)v->lsa; lsa = (struct router_lsa *)v->lsa;
@ -536,8 +536,7 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link,
apply_mask_ipv4(&p); apply_mask_ipv4(&p);
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug("ospf_intra_add_stub(): processing route to %pFX", zlog_debug("%s: processing route to %pFX", __func__, &p);
&p);
/* (1) Calculate the distance D of stub network from the root. D is /* (1) Calculate the distance D of stub network from the root. D is
equal to the distance from the root to the router vertex equal to the distance from the root to the router vertex
@ -546,9 +545,8 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link,
cost = v->distance + ntohs(link->m[0].metric); cost = v->distance + ntohs(link->m[0].metric);
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug("%s: calculated cost is %d + %d = %d", __func__,
"ospf_intra_add_stub(): calculated cost is %d + %d = %d", v->distance, ntohs(link->m[0].metric), cost);
v->distance, ntohs(link->m[0].metric), cost);
/* PtP links with /32 masks adds host routes to remote, directly /* PtP links with /32 masks adds host routes to remote, directly
* connected hosts, see RFC 2328, 12.4.1.1, Option 1. * connected hosts, see RFC 2328, 12.4.1.1, Option 1.
@ -574,8 +572,8 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link,
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug(
"ospf_intra_add_stub(): another route to the same prefix found with cost %u", "%s: another route to the same prefix found with cost %u",
cur_or->cost); __func__, cur_or->cost);
/* Compare this distance to the current best cost to the stub /* Compare this distance to the current best cost to the stub
network. This is done by looking up the stub network's network. This is done by looking up the stub network's
@ -584,8 +582,8 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link,
LSA. */ LSA. */
if (cost > cur_or->cost) { if (cost > cur_or->cost) {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug("%s: old route is better, exit",
"ospf_intra_add_stub(): old route is better, exit"); __func__);
return; return;
} }
@ -604,8 +602,8 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link,
if (cost == cur_or->cost) { if (cost == cur_or->cost) {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug("%s: routes are equal, merge",
"ospf_intra_add_stub(): routes are equal, merge"); __func__);
ospf_route_copy_nexthops_from_vertex(area, cur_or, v); ospf_route_copy_nexthops_from_vertex(area, cur_or, v);
@ -625,8 +623,8 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link,
if (cost < cur_or->cost) { if (cost < cur_or->cost) {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug("%s: new route is better, set it",
"ospf_intra_add_stub(): new route is better, set it"); __func__);
cur_or->cost = cost; cur_or->cost = cost;
@ -640,7 +638,7 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link,
} }
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug("ospf_intra_add_stub(): installing new route"); zlog_debug("%s: installing new route", __func__);
or = ospf_route_new(); or = ospf_route_new();
@ -655,13 +653,13 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link,
/* Nexthop is depend on connection type. */ /* Nexthop is depend on connection type. */
if (v != area->spf) { if (v != area->spf) {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug("%s: this network is on remote router",
"ospf_intra_add_stub(): this network is on remote router"); __func__);
ospf_route_copy_nexthops_from_vertex(area, or, v); ospf_route_copy_nexthops_from_vertex(area, or, v);
} else { } else {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug("%s: this network is on this router",
"ospf_intra_add_stub(): this network is on this router"); __func__);
/* /*
* Only deal with interface data when we * Only deal with interface data when we
@ -672,9 +670,8 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link,
if (oi || area->spf_dry_run) { if (oi || area->spf_dry_run) {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug("%s: the lsa pos is %d", __func__,
"ospf_intra_add_stub(): the lsa pos is %d", lsa_pos);
lsa_pos);
path = ospf_path_new(); path = ospf_path_new();
path->nexthop.s_addr = INADDR_ANY; path->nexthop.s_addr = INADDR_ANY;
@ -689,15 +686,15 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link,
listnode_add(or->paths, path); listnode_add(or->paths, path);
} else { } else {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug("%s: where's the interface ?",
"ospf_intra_add_stub(): where's the interface ?"); __func__);
} }
} }
rn->info = or ; rn->info = or ;
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug("ospf_intra_add_stub(): Stop"); zlog_debug("%s: Stop", __func__);
} }
static const char *const ospf_path_type_str[] = { static const char *const ospf_path_type_str[] = {
@ -931,7 +928,7 @@ void ospf_route_add(struct route_table *rt, struct prefix_ipv4 *p,
if (rn->info) { if (rn->info) {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug("ospf_route_add(): something's wrong !"); zlog_debug("%s: something's wrong !", __func__);
route_unlock_node(rn); route_unlock_node(rn);
return; return;
} }
@ -1016,8 +1013,7 @@ int ospf_add_discard_route(struct ospf *ospf, struct route_table *rt,
if (rn == NULL) { if (rn == NULL) {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug("%s: router installation error", __func__);
"ospf_add_discard_route(): router installation error");
return 0; return 0;
} }
@ -1029,15 +1025,16 @@ int ospf_add_discard_route(struct ospf *ospf, struct route_table *rt,
if (or->path_type == OSPF_PATH_INTRA_AREA) { if (or->path_type == OSPF_PATH_INTRA_AREA) {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug("%s: an intra-area route exists",
"ospf_add_discard_route(): an intra-area route exists"); __func__);
return 0; return 0;
} }
if (or->type == OSPF_DESTINATION_DISCARD) { if (or->type == OSPF_DESTINATION_DISCARD) {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug(
"ospf_add_discard_route(): discard entry already installed"); "%s: discard entry already installed",
__func__);
return 0; return 0;
} }
@ -1045,7 +1042,7 @@ int ospf_add_discard_route(struct ospf *ospf, struct route_table *rt,
} }
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug("ospf_add_discard_route(): adding %pFX", p); zlog_debug("%s: adding %pFX", __func__, p);
new_or = ospf_route_new(); new_or = ospf_route_new();
new_or->type = OSPF_DESTINATION_DISCARD; new_or->type = OSPF_DESTINATION_DISCARD;
@ -1068,14 +1065,13 @@ void ospf_delete_discard_route(struct ospf *ospf, struct route_table *rt,
struct ospf_route * or ; struct ospf_route * or ;
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug("ospf_delete_discard_route(): deleting %pFX", p); zlog_debug("%s: deleting %pFX", __func__, p);
rn = route_node_lookup(rt, (struct prefix *)p); rn = route_node_lookup(rt, (struct prefix *)p);
if (rn == NULL) { if (rn == NULL) {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug("%s: no route found", __func__);
"ospf_delete_discard_route(): no route found");
return; return;
} }
@ -1083,15 +1079,13 @@ void ospf_delete_discard_route(struct ospf *ospf, struct route_table *rt,
if (or->path_type == OSPF_PATH_INTRA_AREA) { if (or->path_type == OSPF_PATH_INTRA_AREA) {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug("%s: an intra-area route exists", __func__);
"ospf_delete_discard_route(): an intra-area route exists");
return; return;
} }
if (or->type != OSPF_DESTINATION_DISCARD) { if (or->type != OSPF_DESTINATION_DISCARD) {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug( zlog_debug("%s: not a discard entry", __func__);
"ospf_delete_discard_route(): not a discard entry");
return; return;
} }