diff options
| author | Donald Sharp <sharpd@nvidia.com> | 2022-08-10 18:14:23 -0400 | 
|---|---|---|
| committer | Donald Sharp <sharpd@nvidia.com> | 2022-08-11 13:30:32 -0400 | 
| commit | fe61ceaee75dbba770f39af7670aa85b8d6ccacb (patch) | |
| tree | 184360281a451a372a547d04615cecf9881a229d /ospfd/ospf_packet.c | |
| parent | 812e6c78c10970d0c5e7e5f3d1ed54dc95736244 (diff) | |
ospfd: Cleanup indentation surrounding oi->nbr
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'ospfd/ospf_packet.c')
| -rw-r--r-- | ospfd/ospf_packet.c | 187 | 
1 files changed, 88 insertions, 99 deletions
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 907cb15ed5..c5e26fa371 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -3349,49 +3349,44 @@ 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)) -								flag = 1; - -							/* 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); -							length += 4; -						} +	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)) { +			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); +		length += 4; +	}  	/* Let neighbor generate BackupSeen. */  	if (flag == 1) @@ -3772,54 +3767,44 @@ 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)) -							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); -					} +		for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) { +			nbr = rn->info; +			if (!nbr) +				continue; + +			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); +		}  	} else {  		/* Decide destination address. */  		if (oi->type == OSPF_IFTYPE_VIRTUALLINK) @@ -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) -					while (listcount(oi->ls_ack)) -						ospf_ls_ack_send_list( -							oi, oi->ls_ack, -							nbr->address.u.prefix4); +		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)  | 
