ospfd: Cleanup indentation surrounding oi->nbr

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2022-08-10 18:14:23 -04:00
parent 812e6c78c1
commit fe61ceaee7
5 changed files with 211 additions and 194 deletions

View file

@ -638,13 +638,15 @@ int ospf_flood_through_interface(struct ospf_interface *oi,
if (oi->type == OSPF_IFTYPE_NBMA) {
struct ospf_neighbor *nbr;
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn))
if ((nbr = rn->info) != NULL)
if (nbr != oi->nbr_self
&& nbr->state >= NSM_Exchange)
ospf_ls_upd_send_lsa(
nbr, lsa,
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) {
nbr = rn->info;
if (!nbr)
continue;
if (nbr != oi->nbr_self && nbr->state >= NSM_Exchange)
ospf_ls_upd_send_lsa(nbr, lsa,
OSPF_SEND_PACKET_DIRECT);
}
} else
ospf_ls_upd_send_lsa(oi->nbr_self, lsa,
OSPF_SEND_PACKET_INDIRECT);
@ -991,16 +993,18 @@ static void ospf_ls_retransmit_delete_nbr_if(struct ospf_interface *oi,
struct ospf_lsa *lsr;
if (ospf_if_is_enable(oi))
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn))
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) {
/* If LSA find in LS-retransmit list, then remove it. */
if ((nbr = rn->info) != NULL) {
nbr = rn->info;
if (!nbr)
continue;
lsr = ospf_ls_retransmit_lookup(nbr, lsa);
/* If LSA find in ls-retransmit list, remove it.
*/
if (lsr != NULL
&& lsr->data->ls_seqnum
== lsa->data->ls_seqnum)
/* If LSA find in ls-retransmit list, remove it. */
if (lsr != NULL &&
lsr->data->ls_seqnum == lsa->data->ls_seqnum)
ospf_ls_retransmit_delete(nbr, lsr);
}
}

View file

@ -66,7 +66,9 @@ int ospf_interface_neighbor_count(struct ospf_interface *oi)
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) {
nbr = rn->info;
if (nbr) {
if (!nbr)
continue;
/* Do not show myself. */
if (nbr == oi->nbr_self)
continue;
@ -75,7 +77,6 @@ int ospf_interface_neighbor_count(struct ospf_interface *oi)
continue;
count++;
}
}
return count;
}
@ -315,10 +316,11 @@ void ospf_if_cleanup(struct ospf_interface *oi)
}
/* send Neighbor event KillNbr to all associated neighbors. */
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn))
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) {
if ((nbr = rn->info) != NULL)
if (nbr != oi->nbr_self)
OSPF_NSM_EVENT_EXECUTE(nbr, NSM_KillNbr);
}
/* Cleanup Link State Acknowlegdment list. */
for (ALL_LIST_ELEMENTS(oi->ls_ack, node, nnode, lsa))

View file

@ -3349,47 +3349,42 @@ static int ospf_make_hello(struct ospf_interface *oi, struct stream *s)
stream_put_ipv4(s, BDR(oi).s_addr);
/* Add neighbor seen. */
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn))
if ((nbr = rn->info))
if (nbr->router_id.s_addr
!= INADDR_ANY) /* Ignore 0.0.0.0 node. */
if (nbr->state
!= NSM_Attempt) /* Ignore Down neighbor. */
if (nbr->state
!= NSM_Down) /* This is myself for
DR election. */
if (!IPV4_ADDR_SAME(
&nbr->router_id,
&oi->ospf->router_id)) {
/* Check neighbor is
* sane? */
if (nbr->d_router.s_addr
!= INADDR_ANY
&& IPV4_ADDR_SAME(
&nbr->d_router,
&oi->address
->u
.prefix4)
&& IPV4_ADDR_SAME(
&nbr->bd_router,
&oi->address
->u
.prefix4))
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) {
nbr = rn->info;
if (!nbr)
continue;
/* Ignore the 0.0.0.0 node */
if (nbr->router_id.s_addr == INADDR_ANY)
continue;
/* Ignore Down neighbor */
if (nbr->state == NSM_Attempt)
continue;
/* This is myself for DR election */
if (nbr->state == NSM_Down)
continue;
if (IPV4_ADDR_SAME(&nbr->router_id, &oi->ospf->router_id))
continue;
/* Check neighbor is sane? */
if (nbr->d_router.s_addr != INADDR_ANY &&
IPV4_ADDR_SAME(&nbr->d_router, &oi->address->u.prefix4) &&
IPV4_ADDR_SAME(&nbr->bd_router, &oi->address->u.prefix4))
flag = 1;
/* Hello packet overflows interface MTU. */
if (length + sizeof(uint32_t)
> ospf_packet_max(oi)) {
/* Hello packet overflows interface MTU.
*/
if (length + sizeof(uint32_t) > ospf_packet_max(oi)) {
flog_err(
EC_OSPF_LARGE_HELLO,
"Oversized Hello packet! Larger than MTU. Not sending it out");
return 0;
}
stream_put_ipv4(
s,
nbr->router_id
.s_addr);
stream_put_ipv4(s, nbr->router_id.s_addr);
length += 4;
}
@ -3772,53 +3767,43 @@ void ospf_hello_send(struct ospf_interface *oi)
struct ospf_neighbor *nbr;
struct route_node *rn;
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn))
if ((nbr = rn->info))
if (nbr != oi->nbr_self)
if (nbr->state != NSM_Down) {
/* RFC 2328 Section 9.5.1
If the router is not
eligible to become Designated
Router,
it must periodically send
Hello Packets to both the
Designated Router and the
Backup Designated Router (if
they
exist). */
if (PRIORITY(oi) == 0
&& IPV4_ADDR_CMP(
&DR(oi),
&nbr->address.u
.prefix4)
&& IPV4_ADDR_CMP(
&BDR(oi),
&nbr->address.u
.prefix4))
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) {
nbr = rn->info;
if (!nbr)
continue;
/* If the router is eligible to
become Designated Router, it
must periodically send Hello
Packets to all neighbors that
are also eligible. In
addition, if the router is
itself the
Designated Router or Backup
Designated Router, it must
also
send periodic Hello Packets
to all other neighbors. */
if (nbr->priority == 0
&& oi->state == ISM_DROther)
if (nbr == oi->nbr_self)
continue;
if (nbr->state == NSM_Down)
continue;
/*
* RFC 2328 Section 9.5.1
* If the router is not eligible to become Designated
* Router, it must periodically send Hello Packets to
* both the Designated Router and the Backup
* Designated Router (if they exist).
*/
if (PRIORITY(oi) == 0 &&
IPV4_ADDR_CMP(&DR(oi), &nbr->address.u.prefix4) &&
IPV4_ADDR_CMP(&BDR(oi), &nbr->address.u.prefix4))
continue;
/*
* If the router is eligible to become Designated
* Router, it must periodically send Hello Packets to
* all neighbors that are also eligible. In addition,
* if the router is itself the Designated Router or
* Backup Designated Router, it must also send periodic
* Hello Packets to all other neighbors.
*/
if (nbr->priority == 0 && oi->state == ISM_DROther)
continue;
/* if oi->state == Waiting, send
* hello to all neighbors */
ospf_hello_send_sub(
oi,
nbr->address.u.prefix4
.s_addr);
ospf_hello_send_sub(oi, nbr->address.u.prefix4.s_addr);
}
} else {
/* Decide destination address. */
@ -4291,14 +4276,18 @@ void ospf_ls_ack_send_delayed(struct ospf_interface *oi)
struct ospf_neighbor *nbr;
struct route_node *rn;
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn))
if ((nbr = rn->info) != NULL)
if (nbr != oi->nbr_self
&& nbr->state >= NSM_Exchange)
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) {
nbr = rn->info;
if (!nbr)
continue;
if (nbr != oi->nbr_self && nbr->state >= NSM_Exchange)
while (listcount(oi->ls_ack))
ospf_ls_ack_send_list(
oi, oi->ls_ack,
nbr->address.u.prefix4);
}
return;
}
if (oi->type == OSPF_IFTYPE_VIRTUALLINK)

View file

@ -756,10 +756,11 @@ static struct ospf_neighbor *get_neighbor_by_addr(struct ospf *top,
for (ALL_LIST_ELEMENTS_RO(top->oiflist, node, oi))
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) {
nbr = rn->info;
if (nbr)
if (IPV4_ADDR_SAME(&nbr->address.u.prefix4,
&addr)
|| IPV4_ADDR_SAME(&nbr->router_id, &addr)) {
if (!nbr)
continue;
if (IPV4_ADDR_SAME(&nbr->address.u.prefix4, &addr) ||
IPV4_ADDR_SAME(&nbr->router_id, &addr)) {
route_unlock_node(rn);
return nbr;
}

View file

@ -4476,7 +4476,11 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty,
struct ospf_neighbor *nbr, *prev_nbr = NULL;
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) {
if ((nbr = rn->info)) {
nbr = rn->info;
if (!nbr)
continue;
/* Do not show myself. */
if (nbr == oi->nbr_self)
continue;
@ -4490,7 +4494,6 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty,
use_json);
}
}
}
static int show_ip_ospf_neighbor_common(struct vty *vty, struct ospf *ospf,
json_object *json, bool use_json,
@ -5402,14 +5405,17 @@ static int show_ip_ospf_neighbor_id_common(struct vty *vty, struct ospf *ospf,
ospf_show_vrf_name(ospf, vty, json, use_vrf);
for (ALL_LIST_ELEMENTS_RO(ospf->oiflist, node, oi)) {
if ((nbr = ospf_nbr_lookup_by_routerid(oi->nbrs, router_id))) {
nbr = ospf_nbr_lookup_by_routerid(oi->nbrs, router_id);
if (!nbr)
continue;
if (is_detail)
show_ip_ospf_neighbor_detail_sub(
vty, oi, nbr, NULL, json, use_json);
else
show_ip_ospf_neighbour_brief(vty, nbr, NULL,
show_ip_ospf_neighbor_detail_sub(vty, oi, nbr, NULL,
json, use_json);
}
else
show_ip_ospf_neighbour_brief(vty, nbr, NULL, json,
use_json);
}
if (use_json)
@ -5498,7 +5504,11 @@ static int show_ip_ospf_neighbor_detail_common(struct vty *vty,
struct ospf_neighbor *nbr, *prev_nbr = NULL;
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) {
if ((nbr = rn->info)) {
nbr = rn->info;
if (!nbr)
continue;
if (nbr != oi->nbr_self) {
if (nbr->state != NSM_Down) {
show_ip_ospf_neighbor_detail_sub(
@ -5509,7 +5519,6 @@ static int show_ip_ospf_neighbor_detail_common(struct vty *vty,
prev_nbr = nbr;
}
}
}
if (use_json) {
json_object_object_add(json_vrf, "neighbors",
@ -5668,27 +5677,29 @@ static int show_ip_ospf_neighbor_detail_all_common(struct vty *vty,
struct ospf_nbr_nbma *nbr_nbma;
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) {
if ((nbr = rn->info)) {
nbr = rn->info;
if (!nbr)
continue;
if (nbr != oi->nbr_self)
if (nbr->state != NSM_Down)
show_ip_ospf_neighbor_detail_sub(
vty, oi, rn->info,
prev_nbr,
vty, oi, rn->info, prev_nbr,
json_vrf, use_json);
prev_nbr = nbr;
}
}
if (oi->type == OSPF_IFTYPE_NBMA) {
if (oi->type != OSPF_IFTYPE_NBMA)
continue;
struct listnode *nd;
for (ALL_LIST_ELEMENTS_RO(oi->nbr_nbma, nd, nbr_nbma)) {
if (nbr_nbma->nbr == NULL
|| nbr_nbma->nbr->state == NSM_Down)
if (nbr_nbma->nbr == NULL ||
nbr_nbma->nbr->state == NSM_Down)
show_ip_ospf_nbr_nbma_detail_sub(
vty, oi, nbr_nbma, use_json,
json_vrf);
}
vty, oi, nbr_nbma, use_json, json_vrf);
}
}
@ -5853,21 +5864,27 @@ static int show_ip_ospf_neighbor_int_detail_common(struct vty *vty,
}
for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) {
if ((oi = rn->info)) {
for (nrn = route_top(oi->nbrs); nrn;
nrn = route_next(nrn)) {
if ((nbr = nrn->info)) {
if (nbr != oi->nbr_self) {
if (nbr->state != NSM_Down)
show_ip_ospf_neighbor_detail_sub(
vty, oi, nbr,
NULL,
oi = rn->info;
if (!oi)
continue;
for (nrn = route_top(oi->nbrs); nrn; nrn = route_next(nrn)) {
nbr = nrn->info;
if (!nbr)
continue;
if (nbr == oi->nbr_self)
continue;
if (nbr->state == NSM_Down)
continue;
show_ip_ospf_neighbor_detail_sub(vty, oi, nbr, NULL,
json, use_json);
}
}
}
}
}
if (use_json)
vty_json(vty, json);
@ -8019,8 +8036,12 @@ static void ospf_nbr_timer_update(struct ospf_interface *oi)
struct route_node *rn;
struct ospf_neighbor *nbr;
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn))
if ((nbr = rn->info)) {
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) {
nbr = rn->info;
if (!nbr)
continue;
nbr->v_inactivity = OSPF_IF_PARAM(oi, v_wait);
nbr->v_db_desc = OSPF_IF_PARAM(oi, retransmit_interval);
nbr->v_ls_req = OSPF_IF_PARAM(oi, retransmit_interval);