mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-29 06:29:40 +00:00
Merge pull request #11845 from sri-mohan1/sri-ospf-dbg1
ospfd: changes for code maintainability
This commit is contained in:
commit
d69d7a615a
113
ospfd/ospf_ia.c
113
ospfd/ospf_ia.c
@ -75,9 +75,7 @@ static void ospf_ia_network_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(
|
zlog_debug("%s: processing summary route to %pFX", __func__, p);
|
||||||
"ospf_ia_network_route(): processing summary route to %pFX",
|
|
||||||
p);
|
|
||||||
|
|
||||||
/* Find a route to the same dest */
|
/* Find a route to the same dest */
|
||||||
if ((rn1 = route_node_lookup(rt, (struct prefix *)p))) {
|
if ((rn1 = route_node_lookup(rt, (struct prefix *)p))) {
|
||||||
@ -88,7 +86,8 @@ static void ospf_ia_network_route(struct ospf *ospf, struct route_table *rt,
|
|||||||
if ((or = rn1->info)) {
|
if ((or = rn1->info)) {
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug(
|
||||||
"ospf_ia_network_route(): Found a route to the same network");
|
"%s: Found a route to the same network",
|
||||||
|
__func__);
|
||||||
/* Check the existing route. */
|
/* Check the existing route. */
|
||||||
if ((res = ospf_route_cmp(ospf, new_or, or)) < 0) {
|
if ((res = ospf_route_cmp(ospf, new_or, or)) < 0) {
|
||||||
/* New route is better, so replace old one. */
|
/* New route is better, so replace old one. */
|
||||||
@ -112,9 +111,7 @@ static void ospf_ia_network_route(struct ospf *ospf, struct route_table *rt,
|
|||||||
} /*if (rn1)*/
|
} /*if (rn1)*/
|
||||||
else { /* no route */
|
else { /* no route */
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug("%s: add new route to %pFX", __func__, p);
|
||||||
"ospf_ia_network_route(): add new route to %pFX",
|
|
||||||
p);
|
|
||||||
ospf_route_add(rt, p, new_or, abr_or);
|
ospf_route_add(rt, p, new_or, abr_or);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,7 +126,7 @@ static void ospf_ia_router_route(struct ospf *ospf, struct route_table *rtrs,
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug("ospf_ia_router_route(): considering %pFX", p);
|
zlog_debug("%s: considering %pFX", __func__, p);
|
||||||
|
|
||||||
/* Find a route to the same dest */
|
/* Find a route to the same dest */
|
||||||
rn = route_node_get(rtrs, (struct prefix *)p);
|
rn = route_node_get(rtrs, (struct prefix *)p);
|
||||||
@ -150,7 +147,8 @@ static void ospf_ia_router_route(struct ospf *ospf, struct route_table *rtrs,
|
|||||||
if (or) {
|
if (or) {
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug(
|
||||||
"ospf_ia_router_route(): a route to the same ABR through the same area exists");
|
"%s: a route to the same ABR through the same area exists",
|
||||||
|
__func__);
|
||||||
/* New route is better */
|
/* New route is better */
|
||||||
if ((ret = ospf_route_cmp(ospf, new_or, or)) < 0) {
|
if ((ret = ospf_route_cmp(ospf, new_or, or)) < 0) {
|
||||||
listnode_delete(rn->info, or);
|
listnode_delete(rn->info, or);
|
||||||
@ -160,8 +158,8 @@ static void ospf_ia_router_route(struct ospf *ospf, struct route_table *rtrs,
|
|||||||
/* Routes are the same */
|
/* Routes are the same */
|
||||||
else if (ret == 0) {
|
else if (ret == 0) {
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug("%s: merging the new route",
|
||||||
"ospf_ia_router_route(): merging the new route");
|
__func__);
|
||||||
|
|
||||||
ospf_route_copy_nexthops(or, abr_or->paths);
|
ospf_route_copy_nexthops(or, abr_or->paths);
|
||||||
ospf_route_free(new_or);
|
ospf_route_free(new_or);
|
||||||
@ -170,8 +168,8 @@ static void ospf_ia_router_route(struct ospf *ospf, struct route_table *rtrs,
|
|||||||
/* New route is worse */
|
/* New route is worse */
|
||||||
else {
|
else {
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug("%s: skipping the new route",
|
||||||
"ospf_ia_router_route(): skipping the new route");
|
__func__);
|
||||||
ospf_route_free(new_or);
|
ospf_route_free(new_or);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -180,7 +178,7 @@ static void ospf_ia_router_route(struct ospf *ospf, struct route_table *rtrs,
|
|||||||
ospf_route_copy_nexthops(new_or, abr_or->paths);
|
ospf_route_copy_nexthops(new_or, abr_or->paths);
|
||||||
|
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug("ospf_ia_router_route(): adding the new route");
|
zlog_debug("%s: adding the new route", __func__);
|
||||||
|
|
||||||
listnode_add(rn->info, new_or);
|
listnode_add(rn->info, new_or);
|
||||||
}
|
}
|
||||||
@ -202,8 +200,7 @@ static int process_summary_lsa(struct ospf_area *area, struct route_table *rt,
|
|||||||
sl = (struct summary_lsa *)lsa->data;
|
sl = (struct summary_lsa *)lsa->data;
|
||||||
|
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug("process_summary_lsa(): LS ID: %pI4",
|
zlog_debug("%s: LS ID: %pI4", __func__, &sl->header.id);
|
||||||
&sl->header.id);
|
|
||||||
|
|
||||||
metric = GET_METRIC(sl->metric);
|
metric = GET_METRIC(sl->metric);
|
||||||
|
|
||||||
@ -311,8 +308,8 @@ static void ospf_update_network_route(struct ospf *ospf, struct route_table *rt,
|
|||||||
|
|
||||||
if (abr_or == NULL) {
|
if (abr_or == NULL) {
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug("%s: can't find a route to the ABR",
|
||||||
"ospf_update_network_route(): can't find a route to the ABR");
|
__func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,8 +323,8 @@ static void ospf_update_network_route(struct ospf *ospf, struct route_table *rt,
|
|||||||
installed
|
installed
|
||||||
backbone paths */
|
backbone paths */
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug("%s: Allowing Shortcut ABR to add new route",
|
||||||
"ospf_update_network_route(): Allowing Shortcut ABR to add new route");
|
__func__);
|
||||||
new_or = ospf_route_new();
|
new_or = ospf_route_new();
|
||||||
new_or->type = OSPF_DESTINATION_NETWORK;
|
new_or->type = OSPF_DESTINATION_NETWORK;
|
||||||
new_or->id = lsa->header.id;
|
new_or->id = lsa->header.id;
|
||||||
@ -352,8 +349,7 @@ static void ospf_update_network_route(struct ospf *ospf, struct route_table *rt,
|
|||||||
if (or->path_type != OSPF_PATH_INTRA_AREA &&
|
if (or->path_type != OSPF_PATH_INTRA_AREA &&
|
||||||
or->path_type != OSPF_PATH_INTER_AREA) {
|
or->path_type != OSPF_PATH_INTER_AREA) {
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug("%s: ERR: path type is wrong", __func__);
|
||||||
"ospf_update_network_route(): ERR: path type is wrong");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,37 +360,39 @@ static void ospf_update_network_route(struct ospf *ospf, struct route_table *rt,
|
|||||||
or->u.std.area_id)) {
|
or->u.std.area_id)) {
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug(
|
||||||
"ospf_update_network_route(): Shortcut: this intra-area path is not backbone");
|
"%s: Shortcut: this intra-area path is not backbone",
|
||||||
|
__func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else /* Not Shortcut ABR */
|
} else /* Not Shortcut ABR */
|
||||||
{
|
{
|
||||||
if (!OSPF_IS_AREA_ID_BACKBONE(or->u.std.area_id)) {
|
if (!OSPF_IS_AREA_ID_BACKBONE(or->u.std.area_id)) {
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug("%s: route is not BB-associated",
|
||||||
"ospf_update_network_route(): route is not BB-associated");
|
__func__);
|
||||||
return; /* We can update only BB routes */
|
return; /* We can update only BB routes */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (or->cost < cost) {
|
if (or->cost < cost) {
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug("%s: new route is worse", __func__);
|
||||||
"ospf_update_network_route(): new route is worse");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (or->cost == cost) {
|
if (or->cost == cost) {
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug(
|
||||||
"ospf_update_network_route(): new route is same distance, adding nexthops");
|
"%s: new route is same distance, adding nexthops",
|
||||||
|
__func__);
|
||||||
ospf_route_copy_nexthops(or, abr_or->paths);
|
ospf_route_copy_nexthops(or, abr_or->paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (or->cost > cost) {
|
if (or->cost > cost) {
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug(
|
||||||
"ospf_update_network_route(): new route is better, overriding nexthops");
|
"%s: new route is better, overriding nexthops",
|
||||||
|
__func__);
|
||||||
ospf_route_subst_nexthops(or, abr_or->paths);
|
ospf_route_subst_nexthops(or, abr_or->paths);
|
||||||
or->cost = cost;
|
or->cost = cost;
|
||||||
|
|
||||||
@ -431,8 +429,8 @@ static void ospf_update_router_route(struct ospf *ospf,
|
|||||||
|
|
||||||
if (abr_or == NULL) {
|
if (abr_or == NULL) {
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug("%s: can't find a route to the ABR",
|
||||||
"ospf_update_router_route(): can't find a route to the ABR");
|
__func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,8 +479,8 @@ static void ospf_update_router_route(struct ospf *ospf,
|
|||||||
|
|
||||||
if (!(or->u.std.flags & ROUTER_LSA_EXTERNAL)) {
|
if (!(or->u.std.flags & ROUTER_LSA_EXTERNAL)) {
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug("%s: the remote router is not an ASBR",
|
||||||
"ospf_upd_router_route(): the remote router is not an ASBR");
|
__func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,28 +522,24 @@ static int process_transit_summary_lsa(struct ospf_area *area,
|
|||||||
sl = (struct summary_lsa *)lsa->data;
|
sl = (struct summary_lsa *)lsa->data;
|
||||||
|
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug("process_transit_summaries(): LS ID: %pI4",
|
zlog_debug("%s: LS ID: %pI4", __func__, &lsa->data->id);
|
||||||
&lsa->data->id);
|
|
||||||
metric = GET_METRIC(sl->metric);
|
metric = GET_METRIC(sl->metric);
|
||||||
|
|
||||||
if (metric == OSPF_LS_INFINITY) {
|
if (metric == OSPF_LS_INFINITY) {
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug("%s: metric is infinity, skip", __func__);
|
||||||
"process_transit_summaries(): metric is infinity, skip");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_LSA_MAXAGE(lsa)) {
|
if (IS_LSA_MAXAGE(lsa)) {
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug("%s: This LSA is too old", __func__);
|
||||||
"process_transit_summaries(): This LSA is too old");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ospf_lsa_is_self_originated(area->ospf, lsa)) {
|
if (ospf_lsa_is_self_originated(area->ospf, lsa)) {
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug("%s: This LSA is mine, skip", __func__);
|
||||||
"process_transit_summaries(): This LSA is mine, skip");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,20 +580,19 @@ void ospf_ia_routing(struct ospf *ospf, struct route_table *rt,
|
|||||||
struct ospf_area *area;
|
struct ospf_area *area;
|
||||||
|
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug("ospf_ia_routing():start");
|
zlog_debug("%s:start", __func__);
|
||||||
|
|
||||||
if (IS_OSPF_ABR(ospf)) {
|
if (IS_OSPF_ABR(ospf)) {
|
||||||
switch (ospf->abr_type) {
|
switch (ospf->abr_type) {
|
||||||
case OSPF_ABR_STAND:
|
case OSPF_ABR_STAND:
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug("ospf_ia_routing():Standard ABR");
|
zlog_debug("%s:Standard ABR", __func__);
|
||||||
|
|
||||||
if ((area = ospf->backbone)) {
|
if ((area = ospf->backbone)) {
|
||||||
if (IS_DEBUG_OSPF_EVENT) {
|
if (IS_DEBUG_OSPF_EVENT) {
|
||||||
zlog_debug(
|
zlog_debug(
|
||||||
"ospf_ia_routing():backbone area found");
|
"%s:backbone area found, examining summaries",
|
||||||
zlog_debug(
|
__func__);
|
||||||
"ospf_ia_routing():examining summaries");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OSPF_EXAMINE_SUMMARIES_ALL(area, rt, rtrs);
|
OSPF_EXAMINE_SUMMARIES_ALL(area, rt, rtrs);
|
||||||
@ -611,23 +604,22 @@ void ospf_ia_routing(struct ospf *ospf, struct route_table *rt,
|
|||||||
OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL(
|
OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL(
|
||||||
area, rt, rtrs);
|
area, rt, rtrs);
|
||||||
} else if (IS_DEBUG_OSPF_EVENT)
|
} else if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug("%s:backbone area NOT found",
|
||||||
"ospf_ia_routing():backbone area NOT found");
|
__func__);
|
||||||
break;
|
break;
|
||||||
case OSPF_ABR_IBM:
|
case OSPF_ABR_IBM:
|
||||||
case OSPF_ABR_CISCO:
|
case OSPF_ABR_CISCO:
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug("%s:Alternative Cisco/IBM ABR",
|
||||||
"ospf_ia_routing():Alternative Cisco/IBM ABR");
|
__func__);
|
||||||
area = ospf->backbone; /* Find the BB */
|
area = ospf->backbone; /* Find the BB */
|
||||||
|
|
||||||
/* If we have an active BB connection */
|
/* If we have an active BB connection */
|
||||||
if (area && ospf_act_bb_connection(ospf)) {
|
if (area && ospf_act_bb_connection(ospf)) {
|
||||||
if (IS_DEBUG_OSPF_EVENT) {
|
if (IS_DEBUG_OSPF_EVENT) {
|
||||||
zlog_debug(
|
zlog_debug(
|
||||||
"ospf_ia_routing(): backbone area found");
|
"%s: backbone area found, examining BB summaries",
|
||||||
zlog_debug(
|
__func__);
|
||||||
"ospf_ia_routing(): examining BB summaries");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OSPF_EXAMINE_SUMMARIES_ALL(area, rt, rtrs);
|
OSPF_EXAMINE_SUMMARIES_ALL(area, rt, rtrs);
|
||||||
@ -642,7 +634,8 @@ void ospf_ia_routing(struct ospf *ospf, struct route_table *rt,
|
|||||||
*/
|
*/
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug(
|
||||||
"ospf_ia_routing(): Active BB connection not found");
|
"%s: Active BB connection not found",
|
||||||
|
__func__);
|
||||||
for (ALL_LIST_ELEMENTS_RO(ospf->areas, node,
|
for (ALL_LIST_ELEMENTS_RO(ospf->areas, node,
|
||||||
area))
|
area))
|
||||||
OSPF_EXAMINE_SUMMARIES_ALL(area, rt,
|
OSPF_EXAMINE_SUMMARIES_ALL(area, rt,
|
||||||
@ -651,17 +644,15 @@ void ospf_ia_routing(struct ospf *ospf, struct route_table *rt,
|
|||||||
break;
|
break;
|
||||||
case OSPF_ABR_SHORTCUT:
|
case OSPF_ABR_SHORTCUT:
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug("%s:Alternative Shortcut", __func__);
|
||||||
"ospf_ia_routing():Alternative Shortcut");
|
|
||||||
area = ospf->backbone; /* Find the BB */
|
area = ospf->backbone; /* Find the BB */
|
||||||
|
|
||||||
/* If we have an active BB connection */
|
/* If we have an active BB connection */
|
||||||
if (area && ospf_act_bb_connection(ospf)) {
|
if (area && ospf_act_bb_connection(ospf)) {
|
||||||
if (IS_DEBUG_OSPF_EVENT) {
|
if (IS_DEBUG_OSPF_EVENT) {
|
||||||
zlog_debug(
|
zlog_debug(
|
||||||
"ospf_ia_routing(): backbone area found");
|
"%s: backbone area found, examining BB summaries",
|
||||||
zlog_debug(
|
__func__);
|
||||||
"ospf_ia_routing(): examining BB summaries");
|
|
||||||
}
|
}
|
||||||
OSPF_EXAMINE_SUMMARIES_ALL(area, rt, rtrs);
|
OSPF_EXAMINE_SUMMARIES_ALL(area, rt, rtrs);
|
||||||
}
|
}
|
||||||
@ -683,8 +674,8 @@ void ospf_ia_routing(struct ospf *ospf, struct route_table *rt,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug(
|
zlog_debug("%s:not ABR, considering all areas",
|
||||||
"ospf_ia_routing():not ABR, considering all areas");
|
__func__);
|
||||||
|
|
||||||
for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area))
|
for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area))
|
||||||
OSPF_EXAMINE_SUMMARIES_ALL(area, rt, rtrs);
|
OSPF_EXAMINE_SUMMARIES_ALL(area, rt, rtrs);
|
||||||
|
Loading…
Reference in New Issue
Block a user