diff options
44 files changed, 182 insertions, 157 deletions
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 47da8fcb88..c0d88fc521 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -1932,7 +1932,7 @@ int bgp_mp_reach_parse(struct bgp_attr_parser_args *args,  	case BGP_ATTR_NHLEN_IPV4:  		stream_get(&attr->mp_nexthop_global_in, s, IPV4_MAX_BYTELEN);  		/* Probably needed for RFC 2283 */ -		if (attr->nexthop.s_addr == 0) +		if (attr->nexthop.s_addr == INADDR_ANY)  			memcpy(&attr->nexthop.s_addr,  			       &attr->mp_nexthop_global_in, IPV4_MAX_BYTELEN);  		break; diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index 44a884830a..c5f7927c4d 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -771,7 +771,7 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int type,  		for (; pi; pi = pi->next) {  			json_object *json_path = NULL; -			if (vtep_ip.s_addr +			if (vtep_ip.s_addr != INADDR_ANY  			    && !IPV4_ADDR_SAME(&(vtep_ip),  					       &(pi->attr->nexthop)))  				continue; diff --git a/bgpd/bgp_flowspec_util.c b/bgpd/bgp_flowspec_util.c index b9a0d81cc5..002aae561a 100644 --- a/bgpd/bgp_flowspec_util.c +++ b/bgpd/bgp_flowspec_util.c @@ -455,7 +455,7 @@ int bgp_flowspec_match_rules_fill(uint8_t *nlri_content, int len,  				 * ignore that rule  				 */  				if (prefix->family == AF_INET -				    && prefix->u.prefix4.s_addr == 0) +				    && prefix->u.prefix4.s_addr == INADDR_ANY)  					bpem->match_bitmask_iprule |= bitmask;  				else  					bpem->match_bitmask |= bitmask; diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index 3c5903c194..ac8fe5e914 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -1527,7 +1527,7 @@ int bgp_start(struct peer *peer)  	}  	/* Clear remote router-id. */ -	peer->remote_id.s_addr = 0; +	peer->remote_id.s_addr = INADDR_ANY;  	/* Clear peer capability flag. */  	peer->cap = 0; diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c index cc7bd6e7c7..6bc8134f36 100644 --- a/bgpd/bgp_mpath.c +++ b/bgpd/bgp_mpath.c @@ -797,7 +797,7 @@ void bgp_path_info_mpath_aggregate_update(struct bgp_path_info *new_best,  		}  		/* Zap multipath attr nexthop so we set nexthop to self */ -		attr.nexthop.s_addr = 0; +		attr.nexthop.s_addr = INADDR_ANY;  		memset(&attr.mp_nexthop_global, 0, sizeof(struct in6_addr));  		/* TODO: should we set ATOMIC_AGGREGATE and AGGREGATOR? */ diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 20fbc89396..afb3a09b6b 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -1186,7 +1186,8 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size)  	}  	/* remote router-id check. */ -	if (remote_id.s_addr == 0 || IPV4_CLASS_DE(ntohl(remote_id.s_addr)) +	if (remote_id.s_addr == INADDR_ANY +	    || IPV4_CLASS_DE(ntohl(remote_id.s_addr))  	    || ntohl(peer->local_id.s_addr) == ntohl(remote_id.s_addr)) {  		if (bgp_debug_neighbor_events(peer))  			zlog_debug("%s bad OPEN, wrong router identifier %s", @@ -1354,7 +1355,7 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size)  	    || peer->afc_nego[AFI_IP][SAFI_MULTICAST]  	    || peer->afc_nego[AFI_IP][SAFI_MPLS_VPN]  	    || peer->afc_nego[AFI_IP][SAFI_ENCAP]) { -		if (!peer->nexthop.v4.s_addr) { +		if (peer->nexthop.v4.s_addr == INADDR_ANY) {  #if defined(HAVE_CUMULUS)  			flog_err(  				EC_BGP_SND_FAIL, diff --git a/bgpd/bgp_pbr.c b/bgpd/bgp_pbr.c index 9ced99616b..eea20d7210 100644 --- a/bgpd/bgp_pbr.c +++ b/bgpd/bgp_pbr.c @@ -754,13 +754,15 @@ int bgp_pbr_build_and_validate_entry(struct prefix *p,  				 * draft-ietf-idr-flowspec-redirect  				 */  				if (api_action_redirect_ip) { -					if (api_action_redirect_ip->u -					    .zr.redirect_ip_v4.s_addr) +					if (api_action_redirect_ip->u.zr +						    .redirect_ip_v4.s_addr +					    != INADDR_ANY)  						continue; -					if (!path->attr->nexthop.s_addr) +					if (path->attr->nexthop.s_addr +					    == INADDR_ANY)  						continue; -					api_action_redirect_ip->u -						.zr.redirect_ip_v4.s_addr = +					api_action_redirect_ip->u.zr +						.redirect_ip_v4.s_addr =  						path->attr->nexthop.s_addr;  					api_action_redirect_ip->u.zr.duplicate  						= ecom_eval->val[7]; diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index c14450414a..5e41f82d4a 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -1535,8 +1535,8 @@ void bgp_attr_add_gshut_community(struct attr *attr)  static void subgroup_announce_reset_nhop(uint8_t family, struct attr *attr)  {  	if (family == AF_INET) { -		attr->nexthop.s_addr = 0; -		attr->mp_nexthop_global_in.s_addr = 0; +		attr->nexthop.s_addr = INADDR_ANY; +		attr->mp_nexthop_global_in.s_addr = INADDR_ANY;  	}  	if (family == AF_INET6)  		memset(&attr->mp_nexthop_global, 0, IPV6_MAX_BYTELEN); @@ -3200,10 +3200,9 @@ static int bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,  	/* If NEXT_HOP is present, validate it. */  	if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) { -		if (attr->nexthop.s_addr == 0 +		if (attr->nexthop.s_addr == INADDR_ANY  		    || IPV4_CLASS_DE(ntohl(attr->nexthop.s_addr)) -		    || bgp_nexthop_self(bgp, afi, type, stype, -			attr, rn)) +		    || bgp_nexthop_self(bgp, afi, type, stype, attr, rn))  			return 1;  	} @@ -3216,11 +3215,11 @@ static int bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,  		switch (attr->mp_nexthop_len) {  		case BGP_ATTR_NHLEN_IPV4:  		case BGP_ATTR_NHLEN_VPNV4: -			ret = (attr->mp_nexthop_global_in.s_addr == 0 -			       || IPV4_CLASS_DE(ntohl( -					  attr->mp_nexthop_global_in.s_addr)) -			       || bgp_nexthop_self(bgp, afi, type, stype, -						   attr, rn)); +			ret = (attr->mp_nexthop_global_in.s_addr == INADDR_ANY +			       || IPV4_CLASS_DE( +				       ntohl(attr->mp_nexthop_global_in.s_addr)) +			       || bgp_nexthop_self(bgp, afi, type, stype, attr, +						   rn));  			break;  		case BGP_ATTR_NHLEN_IPV6_GLOBAL: @@ -5475,7 +5474,7 @@ static int bgp_static_set(struct vty *vty, const char *negate,  			bgp_static->backdoor = backdoor;  			bgp_static->valid = 0;  			bgp_static->igpmetric = 0; -			bgp_static->igpnexthop.s_addr = 0; +			bgp_static->igpnexthop.s_addr = INADDR_ANY;  			bgp_static->label_index = label_index;  			if (rmap) { @@ -5766,7 +5765,7 @@ int bgp_static_set_safi(afi_t afi, safi_t safi, struct vty *vty,  		bgp_static->backdoor = 0;  		bgp_static->valid = 0;  		bgp_static->igpmetric = 0; -		bgp_static->igpnexthop.s_addr = 0; +		bgp_static->igpnexthop.s_addr = INADDR_ANY;  		bgp_static->label = label;  		bgp_static->prd = prd; @@ -7540,7 +7539,7 @@ void route_vty_out(struct vty *vty, struct prefix *p,  						 : inet_ntoa(attr->nexthop),  				vrf_id_str);  	} else if (safi == SAFI_FLOWSPEC) { -		if (attr->nexthop.s_addr != 0) { +		if (attr->nexthop.s_addr != INADDR_ANY) {  			if (json_paths) {  				json_nexthop_global = json_object_new_object(); diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index ecd770a1d1..f5de9ac8c6 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -1705,7 +1705,7 @@ route_set_ip_nexthop(void *rule, const struct prefix *prefix,  			 */  			SET_FLAG(path->attr->rmap_change_flags,  				 BATTR_RMAP_NEXTHOP_PEER_ADDRESS); -			path->attr->nexthop.s_addr = 0; +			path->attr->nexthop.s_addr = INADDR_ANY;  		}  	} else {  		/* Set next hop value. */ diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c index f31f8cd31b..77b547c0aa 100644 --- a/bgpd/bgp_snmp.c +++ b/bgpd/bgp_snmp.c @@ -755,7 +755,7 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],  			oid2in_addr(offset, len, &paddr);  		} else -			paddr.s_addr = 0; +			paddr.s_addr = INADDR_ANY;  		if (!rn)  			return NULL; @@ -804,7 +804,7 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],  				return min;  			} -			paddr.s_addr = 0; +			paddr.s_addr = INADDR_ANY;  		} while ((rn = bgp_route_next(rn)) != NULL);  	}  	return NULL; diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c index 39eb065288..86750c0fcc 100644 --- a/bgpd/bgp_updgrp_packet.c +++ b/bgpd/bgp_updgrp_packet.c @@ -467,16 +467,16 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,  					mod_v4nh = &peer->nexthop.v4;  					nh_modified = 1;  				} -			} else if (!v4nh.s_addr) { +			} else if (v4nh.s_addr == INADDR_ANY) {  				mod_v4nh = &peer->nexthop.v4;  				nh_modified = 1; -			} else if ( -				peer->sort == BGP_PEER_EBGP -				&& (bgp_multiaccess_check_v4(v4nh, peer) == 0) -				&& !CHECK_FLAG( +			} else if (peer->sort == BGP_PEER_EBGP +				   && (bgp_multiaccess_check_v4(v4nh, peer) +				       == 0) +				   && !CHECK_FLAG(  					   vec->flags,  					   BPKT_ATTRVEC_FLAGS_RMAP_NH_UNCHANGED) -				&& !peer_af_flag_check( +				   && !peer_af_flag_check(  					   peer, paf->afi, paf->safi,  					   PEER_FLAG_NEXTHOP_UNCHANGED)) {  				/* NOTE: not handling case where NH has new AFI @@ -628,7 +628,7 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,  			mod_v4nh = &v4nh;  			/* No route-map changes allowed for EVPN nexthops. */ -			if (!v4nh.s_addr) { +			if (v4nh.s_addr == INADDR_ANY) {  				mod_v4nh = &peer->nexthop.v4;  				nh_modified = 1;  			} diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 2c9529700f..076b6aabca 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -819,7 +819,7 @@ bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote,  		/* IPv4 nexthop. */  		ret = if_get_ipv4_address(ifp, &nexthop->v4); -		if (!ret && peer->local_id.s_addr) +		if (!ret && peer->local_id.s_addr != INADDR_ANY)  			nexthop->v4 = peer->local_id;  		/* Global address*/ @@ -2548,7 +2548,8 @@ static int bgp_zebra_process_local_vni(ZAPI_CALLBACK_ARGS)  	if (cmd == ZEBRA_VNI_ADD)  		return bgp_evpn_local_vni_add( -			bgp, vni, vtep_ip.s_addr ? vtep_ip : bgp->router_id, +			bgp, vni, +			vtep_ip.s_addr != INADDR_ANY ? vtep_ip : bgp->router_id,  			tenant_vrf_id, mcast_grp);  	else  		return bgp_evpn_local_vni_del(bgp, vni); @@ -2975,7 +2976,7 @@ void bgp_zebra_announce_default(struct bgp *bgp, struct nexthop *nh,  	SET_FLAG(api.message, ZAPI_MESSAGE_DISTANCE);  	/* redirect IP */ -	if (nh->gate.ipv4.s_addr) { +	if (nh->gate.ipv4.s_addr != INADDR_ANY) {  		char buff[PREFIX_STRLEN];  		api_nh->vrf_id = nh->vrf_id; diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 05a3f7ef2e..60bcc7b8e3 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -335,7 +335,8 @@ void bgp_router_id_zebra_bump(vrf_id_t vrf_id, const struct prefix *router_id)  int bgp_router_id_static_set(struct bgp *bgp, struct in_addr id)  {  	bgp->router_id_static = id; -	bgp_router_id_set(bgp, id.s_addr ? &id : &bgp->router_id_zebra, +	bgp_router_id_set(bgp, +			  id.s_addr != INADDR_ANY ? &id : &bgp->router_id_zebra,  			  true /* is config */);  	return 0;  } diff --git a/eigrpd/eigrp_network.c b/eigrpd/eigrp_network.c index 324f309290..39008a01c4 100644 --- a/eigrpd/eigrp_network.c +++ b/eigrpd/eigrp_network.c @@ -230,7 +230,7 @@ int eigrp_network_set(struct eigrp *eigrp, struct prefix *p)  	rn->info = (void *)pref;  	/* Schedule Router ID Update. */ -	if (eigrp->router_id.s_addr == 0) +	if (eigrp->router_id.s_addr == INADDR_ANY)  		eigrp_router_id_update(eigrp);  	/* Run network config now. */  	/* Get target interface. */ diff --git a/eigrpd/eigrp_northbound.c b/eigrpd/eigrp_northbound.c index 4ccce2ebb8..e03ebb4fcb 100644 --- a/eigrpd/eigrp_northbound.c +++ b/eigrpd/eigrp_northbound.c @@ -161,7 +161,7 @@ static int eigrpd_instance_router_id_destroy(enum nb_event event,  		break;  	case NB_EV_APPLY:  		eigrp = nb_running_get_entry(dnode, NULL, true); -		eigrp->router_id_static.s_addr = 0; +		eigrp->router_id_static.s_addr = INADDR_ANY;  		break;  	} diff --git a/eigrpd/eigrpd.c b/eigrpd/eigrpd.c index e93dc0cbfa..820f015b57 100644 --- a/eigrpd/eigrpd.c +++ b/eigrpd/eigrpd.c @@ -99,10 +99,10 @@ void eigrp_router_id_update(struct eigrp *eigrp)  	router_id_old = eigrp->router_id; -	if (eigrp->router_id_static.s_addr != 0) +	if (eigrp->router_id_static.s_addr != INADDR_ANY)  		router_id = eigrp->router_id_static; -	else if (eigrp->router_id.s_addr != 0) +	else if (eigrp->router_id.s_addr != INADDR_ANY)  		router_id = eigrp->router_id;  	else @@ -142,8 +142,8 @@ static struct eigrp *eigrp_new(uint16_t as, vrf_id_t vrf_id)  	eigrp->vrf_id = vrf_id;  	eigrp->vrid = 0;  	eigrp->AS = as; -	eigrp->router_id.s_addr = 0; -	eigrp->router_id_static.s_addr = 0; +	eigrp->router_id.s_addr = INADDR_ANY; +	eigrp->router_id_static.s_addr = INADDR_ANY;  	eigrp->sequence_number = 1;  	/*Configure default K Values for EIGRP Process*/ diff --git a/ldpd/ldp_vty_conf.c b/ldpd/ldp_vty_conf.c index 4ef57f574a..816fcc64b8 100644 --- a/ldpd/ldp_vty_conf.c +++ b/ldpd/ldp_vty_conf.c @@ -250,9 +250,8 @@ ldp_config_write(struct vty *vty)  	vty_out (vty, "mpls ldp\n"); -	if (ldpd_conf->rtr_id.s_addr != 0) -		vty_out (vty, " router-id %s\n", -		    inet_ntoa(ldpd_conf->rtr_id)); +	if (ldpd_conf->rtr_id.s_addr != INADDR_ANY) +		vty_out(vty, " router-id %s\n", inet_ntoa(ldpd_conf->rtr_id));  	if (ldpd_conf->lhello_holdtime != LINK_DFLT_HOLDTIME &&  	    ldpd_conf->lhello_holdtime != 0) diff --git a/lib/filter.c b/lib/filter.c index 4521cf6469..911a8e53d1 100644 --- a/lib/filter.c +++ b/lib/filter.c @@ -2551,7 +2551,8 @@ static int filter_show(struct vty *vty, const char *name, afi_t afi)  				else {  					vty_out(vty, " %s",  						inet_ntoa(filter->addr)); -					if (filter->addr_mask.s_addr != 0) +					if (filter->addr_mask.s_addr +					    != INADDR_ANY)  						vty_out(vty,  							", wildcard bits %s",  							inet_ntoa( @@ -2599,7 +2600,8 @@ static int filter_show(struct vty *vty, const char *name, afi_t afi)  				else {  					vty_out(vty, " %s",  						inet_ntoa(filter->addr)); -					if (filter->addr_mask.s_addr != 0) +					if (filter->addr_mask.s_addr +					    != INADDR_ANY)  						vty_out(vty,  							", wildcard bits %s",  							inet_ntoa( @@ -2692,7 +2694,7 @@ static void config_write_access_cisco(struct vty *vty, struct filter *mfilter)  		vty_out(vty, " ip");  		if (filter->addr_mask.s_addr == 0xffffffff)  			vty_out(vty, " any"); -		else if (filter->addr_mask.s_addr == 0) +		else if (filter->addr_mask.s_addr == INADDR_ANY)  			vty_out(vty, " host %s", inet_ntoa(filter->addr));  		else {  			vty_out(vty, " %s", inet_ntoa(filter->addr)); @@ -2701,7 +2703,7 @@ static void config_write_access_cisco(struct vty *vty, struct filter *mfilter)  		if (filter->mask_mask.s_addr == 0xffffffff)  			vty_out(vty, " any"); -		else if (filter->mask_mask.s_addr == 0) +		else if (filter->mask_mask.s_addr == INADDR_ANY)  			vty_out(vty, " host %s", inet_ntoa(filter->mask));  		else {  			vty_out(vty, " %s", inet_ntoa(filter->mask)); @@ -2713,7 +2715,7 @@ static void config_write_access_cisco(struct vty *vty, struct filter *mfilter)  			vty_out(vty, " any\n");  		else {  			vty_out(vty, " %s", inet_ntoa(filter->addr)); -			if (filter->addr_mask.s_addr != 0) +			if (filter->addr_mask.s_addr != INADDR_ANY)  				vty_out(vty, " %s",  					inet_ntoa(filter->addr_mask));  			vty_out(vty, "\n"); diff --git a/lib/prefix.c b/lib/prefix.c index cb6e53b305..199ff3267b 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -659,7 +659,7 @@ void apply_mask_ipv4(struct prefix_ipv4 *p)  /* If prefix is 0.0.0.0/0 then return 1 else return 0. */  int prefix_ipv4_any(const struct prefix_ipv4 *p)  { -	return (p->prefix.s_addr == 0 && p->prefixlen == 0); +	return (p->prefix.s_addr == INADDR_ANY && p->prefixlen == 0);  }  /* Allocate a new ip version 6 route */ @@ -1144,7 +1144,7 @@ int netmask_str2prefix_str(const char *net_str, const char *mask_str,  	} else {  		destination = ntohl(network.s_addr); -		if (network.s_addr == 0) +		if (network.s_addr == INADDR_ANY)  			prefixlen = 0;  		else if (IN_CLASSC(destination))  			prefixlen = 24; diff --git a/lib/routemap_northbound.c b/lib/routemap_northbound.c index 78f2a5a018..68b112b09a 100644 --- a/lib/routemap_northbound.c +++ b/lib/routemap_northbound.c @@ -940,7 +940,7 @@ lib_route_map_entry_set_action_ipv4_address_modify(enum nb_event event,  		 * only implemented action.  		 */  		yang_dnode_get_ipv4(&ia, dnode, NULL); -		if (ia.s_addr == 0 || IPV4_CLASS_DE(ntohl(ia.s_addr))) +		if (ia.s_addr == INADDR_ANY || IPV4_CLASS_DE(ntohl(ia.s_addr)))  			return NB_ERR_VALIDATION;  		/* FALLTHROUGH */  	case NB_EV_PREPARE: diff --git a/nhrpd/nhrp_interface.c b/nhrpd/nhrp_interface.c index 9f828a1c7d..7cf8dfbde4 100644 --- a/nhrpd/nhrp_interface.c +++ b/nhrpd/nhrp_interface.c @@ -135,7 +135,7 @@ static void nhrp_interface_update_nbma(struct interface *ifp)  				     &nifp->linkidx, &saddr);  		debugf(NHRP_DEBUG_IF, "%s: GRE: %x %x %x", ifp->name,  		       nifp->grekey, nifp->linkidx, saddr.s_addr); -		if (saddr.s_addr) +		if (saddr.s_addr != INADDR_ANY)  			sockunion_set(&nbma, AF_INET, (uint8_t *)&saddr.s_addr,  				      sizeof(saddr.s_addr));  		else if (!nbmaifp && nifp->linkidx != IFINDEX_INTERNAL) diff --git a/ospfclient/ospf_apiclient.c b/ospfclient/ospf_apiclient.c index 50485cc7e2..da390e3c70 100644 --- a/ospfclient/ospf_apiclient.c +++ b/ospfclient/ospf_apiclient.c @@ -451,7 +451,7 @@ int ospf_apiclient_lsa_originate(struct ospf_apiclient *oclient,  	tmp = SET_OPAQUE_LSID(opaque_type, opaque_id);  	lsah->id.s_addr = htonl(tmp); -	lsah->adv_router.s_addr = 0; +	lsah->adv_router.s_addr = INADDR_ANY;  	lsah->ls_seqnum = 0;  	lsah->checksum = 0;  	lsah->length = htons(sizeof(struct lsa_header) + opaquelen); diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c index c8b8b611ef..b4690cfa42 100644 --- a/ospfd/ospf_abr.c +++ b/ospfd/ospf_abr.c @@ -310,7 +310,7 @@ int ospf_area_range_substitute_unset(struct ospf *ospf, struct in_addr area_id,  			ospf_schedule_abr_task(ospf);  	UNSET_FLAG(range->flags, OSPF_AREA_RANGE_SUBSTITUTE); -	range->subst_addr.s_addr = 0; +	range->subst_addr.s_addr = INADDR_ANY;  	range->subst_masklen = 0;  	return 1; diff --git a/ospfd/ospf_ase.c b/ospfd/ospf_ase.c index 44244f651e..2c80d485a3 100644 --- a/ospfd/ospf_ase.c +++ b/ospfd/ospf_ase.c @@ -370,7 +370,7 @@ int ospf_ase_calculate_route(struct ospf *ospf, struct ospf_lsa *lsa)  	       external-LSA.  This indicates the IP address to which  	       packets for the destination should be forwarded. */ -	if (al->e[0].fwd_addr.s_addr == 0) { +	if (al->e[0].fwd_addr.s_addr == INADDR_ANY) {  		/* If the forwarding address is set to 0.0.0.0, packets should  		   be sent to the ASBR itself. Among the multiple routing table  		   entries for the ASBR, select the preferred entry as follows. @@ -470,7 +470,7 @@ int ospf_ase_calculate_route(struct ospf *ospf, struct ospf_lsa *lsa)  		ospf_route_add(ospf->new_external_route, &p, new, asbr_route); -		if (al->e[0].fwd_addr.s_addr) +		if (al->e[0].fwd_addr.s_addr != INADDR_ANY)  			ospf_ase_complete_direct_routes(new, al->e[0].fwd_addr);  		return 0;  	} else { @@ -512,7 +512,7 @@ int ospf_ase_calculate_route(struct ospf *ospf, struct ospf_lsa *lsa)  				zlog_debug(  					"Route[External]: New route is better");  			ospf_route_subst(rn, new, asbr_route); -			if (al->e[0].fwd_addr.s_addr) +			if (al->e[0].fwd_addr.s_addr != INADDR_ANY)  				ospf_ase_complete_direct_routes(  					new, al->e[0].fwd_addr);  			or = new; @@ -530,7 +530,7 @@ int ospf_ase_calculate_route(struct ospf *ospf, struct ospf_lsa *lsa)  			if (IS_DEBUG_OSPF(lsa, LSA))  				zlog_debug("Route[External]: Routes are equal");  			ospf_route_copy_nexthops(or, asbr_route->paths); -			if (al->e[0].fwd_addr.s_addr) +			if (al->e[0].fwd_addr.s_addr != INADDR_ANY)  				ospf_ase_complete_direct_routes(  					or, al->e[0].fwd_addr);  		} diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index 3eb03f53c4..f2efaf322f 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -862,7 +862,7 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,  	p = prefix_ipv4_new();  	p->family = AF_INET; -	p->prefix.s_addr = 0; +	p->prefix.s_addr = INADDR_ANY;  	p->prefixlen = 0;  	co->address = (struct prefix *)p; @@ -885,7 +885,7 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,  	if (IS_DEBUG_OSPF_EVENT)  		zlog_debug("ospf_vl_new(): set if->name to %s", vi->name); -	area_id.s_addr = 0; +	area_id.s_addr = INADDR_ANY;  	area = ospf_area_get(ospf, area_id);  	voi->area = area; @@ -907,7 +907,7 @@ static void ospf_vl_if_delete(struct ospf_vl_data *vl_data)  {  	struct interface *ifp = vl_data->vl_oi->ifp; -	vl_data->vl_oi->address->u.prefix4.s_addr = 0; +	vl_data->vl_oi->address->u.prefix4.s_addr = INADDR_ANY;  	vl_data->vl_oi->address->prefixlen = 0;  	ospf_if_free(vl_data->vl_oi);  	if_delete(&ifp); @@ -971,7 +971,7 @@ static void ospf_vl_shutdown(struct ospf_vl_data *vl_data)  	if ((oi = vl_data->vl_oi) == NULL)  		return; -	oi->address->u.prefix4.s_addr = 0; +	oi->address->u.prefix4.s_addr = INADDR_ANY;  	oi->address->prefixlen = 0;  	UNSET_FLAG(oi->ifp->flags, IFF_UP); diff --git a/ospfd/ospf_ism.c b/ospfd/ospf_ism.c index e394b6f472..f4e89da45d 100644 --- a/ospfd/ospf_ism.c +++ b/ospfd/ospf_ism.c @@ -169,7 +169,7 @@ static void ospf_dr_eligible_routers(struct route_table *nbrs,  	for (rn = route_top(nbrs); rn; rn = route_next(rn))  		if ((nbr = rn->info) != NULL)  			/* Ignore 0.0.0.0 node*/ -			if (nbr->router_id.s_addr != 0) +			if (nbr->router_id.s_addr != INADDR_ANY)  				/* Is neighbor eligible? */  				if (nbr->priority > 0)  					/* Is neighbor upper 2-Way? */ @@ -186,7 +186,7 @@ static void ospf_dr_change(struct ospf *ospf, struct route_table *nbrs)  	for (rn = route_top(nbrs); rn; rn = route_next(rn))  		if ((nbr = rn->info) != NULL)  			/* Ignore 0.0.0.0 node*/ -			if (nbr->router_id.s_addr != 0) +			if (nbr->router_id.s_addr != INADDR_ANY)  				/* Is neighbor upper 2-Way? */  				if (nbr->state >= NSM_TwoWay)  					/* Ignore myself. */ diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index 6eec87c93e..35bbe06cd1 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -820,7 +820,7 @@ static struct ospf_lsa *ospf_router_lsa_originate(struct ospf_area *area)  	}  	/* Sanity check. */ -	if (new->data->adv_router.s_addr == 0) { +	if (new->data->adv_router.s_addr == INADDR_ANY) {  		if (IS_DEBUG_OSPF_EVENT)  			zlog_debug("LSA[Type1]: AdvRouter is 0, discard");  		ospf_lsa_discard(new); @@ -1459,7 +1459,7 @@ struct in_addr ospf_get_ip_from_ifp(struct ospf_interface *oi)  {  	struct in_addr fwd; -	fwd.s_addr = 0; +	fwd.s_addr = INADDR_ANY;  	if (if_is_operative(oi->ifp))  		return oi->address->u.prefix4; @@ -1931,7 +1931,7 @@ int is_prefix_default(struct prefix_ipv4 *p)  	struct prefix_ipv4 q;  	q.family = AF_INET; -	q.prefix.s_addr = 0; +	q.prefix.s_addr = INADDR_ANY;  	q.prefixlen = 0;  	return prefix_same((struct prefix *)p, (struct prefix *)&q); @@ -1979,10 +1979,11 @@ struct ospf_lsa *ospf_external_lsa_originate(struct ospf *ospf,  	   */ -	if (ospf->router_id.s_addr == 0) { +	if (ospf->router_id.s_addr == INADDR_ANY) {  		if (IS_DEBUG_OSPF_EVENT) -			zlog_debug("LSA[Type5:%pI4]: deferring AS-external-LSA origination, router ID is zero", -				   &ei->p.prefix); +			zlog_debug( +				"LSA[Type5:%pI4]: deferring AS-external-LSA origination, router ID is zero", +				&ei->p.prefix);  		return NULL;  	} @@ -2197,7 +2198,7 @@ void ospf_external_lsa_refresh_default(struct ospf *ospf)  	p.family = AF_INET;  	p.prefixlen = 0; -	p.prefix.s_addr = 0; +	p.prefix.s_addr = INADDR_ANY;  	ei = ospf_default_external_info(ospf);  	lsa = ospf_external_info_find_lsa(ospf, &p); diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 95fb694925..1b47fde215 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -1074,7 +1074,8 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh,  	/* If neighbor itself declares DR and no BDR exists,  	   cause event BackupSeen */  	if (IPV4_ADDR_SAME(&nbr->address.u.prefix4, &hello->d_router)) -		if (hello->bd_router.s_addr == 0 && oi->state == ISM_Waiting) +		if (hello->bd_router.s_addr == INADDR_ANY +		    && oi->state == ISM_Waiting)  			OSPF_ISM_EVENT_SCHEDULE(oi, ISM_BackupSeen);  	/* neighbor itself declares BDR. */ @@ -3352,7 +3353,7 @@ static int ospf_make_hello(struct ospf_interface *oi, struct stream *s)  	for (rn = route_top(oi->nbrs); rn; rn = route_next(rn))  		if ((nbr = rn->info))  			if (nbr->router_id.s_addr -			    != 0) /* Ignore 0.0.0.0 node. */ +			    != INADDR_ANY) /* Ignore 0.0.0.0 node. */  				if (nbr->state  				    != NSM_Attempt) /* Ignore Down neighbor. */  					if (nbr->state @@ -3364,17 +3365,17 @@ static int ospf_make_hello(struct ospf_interface *oi, struct stream *s)  							/* Check neighbor is  							 * sane? */  							if (nbr->d_router.s_addr -								    != 0 +								    != INADDR_ANY  							    && IPV4_ADDR_SAME( -								       &nbr->d_router, -								       &oi->address -										->u -										.prefix4) +								    &nbr->d_router, +								    &oi->address +									     ->u +									     .prefix4)  							    && IPV4_ADDR_SAME( -								       &nbr->bd_router, -								       &oi->address -										->u -										.prefix4)) +								    &nbr->bd_router, +								    &oi->address +									     ->u +									     .prefix4))  								flag = 1;  							/* Hello packet overflows interface MTU. */ diff --git a/ospfd/ospf_route.c b/ospfd/ospf_route.c index 6cabc0c985..b6e8338ee7 100644 --- a/ospfd/ospf_route.c +++ b/ospfd/ospf_route.c @@ -603,7 +603,7 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link,  					IF_NAME(oi));  			path = ospf_path_new(); -			path->nexthop.s_addr = 0; +			path->nexthop.s_addr = INADDR_ANY;  			path->ifindex = oi->ifp->ifindex;  			if (CHECK_FLAG(oi->connected->flags,  				       ZEBRA_IFA_UNNUMBERED)) @@ -962,7 +962,7 @@ int ospf_add_discard_route(struct ospf *ospf, struct route_table *rt,  	new_or = ospf_route_new();  	new_or->type = OSPF_DESTINATION_DISCARD; -	new_or->id.s_addr = 0; +	new_or->id.s_addr = INADDR_ANY;  	new_or->cost = 0;  	new_or->u.std.area_id = area->area_id;  	new_or->u.std.external_routing = area->external_routing; diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 1542ef88fb..fb4082e509 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -3551,7 +3551,7 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,  		}  		/* Show DR information. */ -		if (DR(oi).s_addr == 0) { +		if (DR(oi).s_addr == INADDR_ANY) {  			if (!use_json)  				vty_out(vty,  					"  No backup designated router on this network\n"); @@ -4199,7 +4199,7 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty,  				}  				if (nbr->state == NSM_Attempt -				    && nbr->router_id.s_addr == 0) +				    && nbr->router_id.s_addr == INADDR_ANY)  					strlcpy(neigh_str, "neighbor",  						sizeof(neigh_str));  				else @@ -4258,7 +4258,7 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty,  				ospf_nbr_state_message(nbr, msgbuf, 16);  				if (nbr->state == NSM_Attempt -				    && nbr->router_id.s_addr == 0) +				    && nbr->router_id.s_addr == INADDR_ANY)  					vty_out(vty, "%-15s %3d %-15s ", "-",  						nbr->priority, msgbuf);  				else @@ -4908,7 +4908,8 @@ static void show_ip_ospf_neighbor_detail_sub(struct vty *vty,  			json_neigh_array = NULL;  		} -		if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) +		if (nbr->state == NSM_Attempt +		    && nbr->router_id.s_addr == INADDR_ANY)  			strlcpy(neigh_str, "noNbrId", sizeof(neigh_str));  		else  			strlcpy(neigh_str, inet_ntoa(nbr->router_id), @@ -4926,7 +4927,8 @@ static void show_ip_ospf_neighbor_detail_sub(struct vty *vty,  	} else {  		/* Show neighbor ID. */ -		if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) +		if (nbr->state == NSM_Attempt +		    && nbr->router_id.s_addr == INADDR_ANY)  			vty_out(vty, " Neighbor %s,", "-");  		else  			vty_out(vty, " Neighbor %s,", diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index 68d9d3bf83..64013435f6 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -585,9 +585,9 @@ int ospf_redistribute_default_set(struct ospf *ospf, int originate, int mtype,  	int cur_originate = ospf->default_originate;  	const char *type_str = NULL; -	nexthop.s_addr = 0; +	nexthop.s_addr = INADDR_ANY;  	p.family = AF_INET; -	p.prefix.s_addr = 0; +	p.prefix.s_addr = INADDR_ANY;  	p.prefixlen = 0;  	ospf->default_originate = originate; @@ -854,7 +854,7 @@ static int ospf_zebra_read_route(ZAPI_CALLBACK_ARGS)  			/* Nothing has changed, so nothing to do; return */  			return 0;  		} -		if (ospf->router_id.s_addr != 0) { +		if (ospf->router_id.s_addr != INADDR_ANY) {  			if (ei) {  				if (is_prefix_default(&p))  					ospf_external_lsa_refresh_default(ospf); diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index 6a4e63372a..2a3f1329a0 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -329,7 +329,7 @@ struct ospf *ospf_lookup_instance(unsigned short instance)  static int ospf_is_ready(struct ospf *ospf)  {  	/* OSPF must be on and Router-ID must be configured. */ -	if (!ospf || ospf->router_id.s_addr == 0) +	if (!ospf || ospf->router_id.s_addr == INADDR_ANY)  		return 0;  	return 1; @@ -379,7 +379,7 @@ struct ospf *ospf_get(unsigned short instance, const char *name, bool *created)  		ospf = ospf_new(instance, name);  		ospf_add(ospf); -		if (ospf->router_id_static.s_addr == 0) +		if (ospf->router_id_static.s_addr == INADDR_ANY)  			ospf_router_id_update(ospf);  		ospf_opaque_type11_lsa_init(ospf); @@ -398,7 +398,7 @@ struct ospf *ospf_get_instance(unsigned short instance, bool *created)  		ospf = ospf_new(instance, NULL /* VRF_DEFAULT*/);  		ospf_add(ospf); -		if (ospf->router_id_static.s_addr == 0) +		if (ospf->router_id_static.s_addr == INADDR_ANY)  			ospf_router_id_update(ospf);  		ospf_opaque_type11_lsa_init(ospf); @@ -938,7 +938,8 @@ static void add_ospf_interface(struct connected *co, struct ospf_area *area)  	 * ospf_router_id_update() will call ospf_if_update  	 * whenever r-id is configured instead.  	 */ -	if ((area->ospf->router_id.s_addr != 0) && if_is_operative(co->ifp)) +	if ((area->ospf->router_id.s_addr != INADDR_ANY) +	    && if_is_operative(co->ifp))  		ospf_if_up(oi);  } @@ -1267,7 +1268,7 @@ static void ospf_network_run(struct prefix *p, struct ospf_area *area)  	struct interface *ifp;  	/* Schedule Router ID Update. */ -	if (area->ospf->router_id.s_addr == 0) +	if (area->ospf->router_id.s_addr == INADDR_ANY)  		ospf_router_id_update(area->ospf);  	/* Get target interface. */ diff --git a/pimd/mtracebis.c b/pimd/mtracebis.c index dd95762754..2f10abccee 100644 --- a/pimd/mtracebis.c +++ b/pimd/mtracebis.c @@ -448,7 +448,7 @@ int main(int argc, char *const argv[])  		exit(EXIT_FAILURE);  	} -	mc_group.s_addr = 0; +	mc_group.s_addr = INADDR_ANY;  	not_group = false;  	if (argc == 3) { diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 01bebebd29..6508fb4453 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -1741,12 +1741,12 @@ static void pim_show_join(struct pim_instance *pim, struct vty *vty,  			continue;  		RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) { -			if (sg->grp.s_addr != 0 +			if (sg->grp.s_addr != INADDR_ANY  			    && sg->grp.s_addr != ch->sg.grp.s_addr)  				continue; -			if (sg->src.s_addr != 0 +			if (sg->src.s_addr != INADDR_ANY  			    && sg->src.s_addr != ch->sg.src.s_addr) -			continue; +				continue;  			pim_show_join_helper(vty, pim_ifp, ch, json, now, uj);  		} /* scan interface channels */  	} @@ -2448,9 +2448,11 @@ static void pim_show_upstream(struct pim_instance *pim, struct vty *vty,  		char msdp_reg_timer[10];  		char state_str[PIM_REG_STATE_STR_LEN]; -		if (sg->grp.s_addr != 0 && sg->grp.s_addr != up->sg.grp.s_addr) +		if (sg->grp.s_addr != INADDR_ANY +		    && sg->grp.s_addr != up->sg.grp.s_addr)  			continue; -		if (sg->src.s_addr != 0 && sg->src.s_addr != up->sg.src.s_addr) +		if (sg->src.s_addr != INADDR_ANY +		    && sg->src.s_addr != up->sg.src.s_addr)  			continue;  		pim_inet4_dump("<src?>", up->sg.src, src_str, sizeof(src_str)); diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c index 3a7eb45f27..d9c9bb37dd 100644 --- a/pimd/pim_ifchannel.c +++ b/pimd/pim_ifchannel.c @@ -580,7 +580,7 @@ struct pim_ifchannel *pim_ifchannel_add(struct interface *ifp,  	ch->ifassert_my_metric = pim_macro_ch_my_assert_metric_eval(ch);  	ch->ifassert_winner_metric = pim_macro_ch_my_assert_metric_eval(ch); -	ch->ifassert_winner.s_addr = 0; +	ch->ifassert_winner.s_addr = INADDR_ANY;  	/* Assert state */  	ch->t_ifassert_timer = NULL; diff --git a/pimd/pim_igmp_mtrace.c b/pimd/pim_igmp_mtrace.c index 695d04c7c2..309b8c1495 100644 --- a/pimd/pim_igmp_mtrace.c +++ b/pimd/pim_igmp_mtrace.c @@ -68,7 +68,7 @@ static bool mtrace_fwd_info_weak(struct pim_instance *pim,  	struct in_addr nh_addr;  	char nexthop_str[INET_ADDRSTRLEN]; -	nh_addr.s_addr = 0; +	nh_addr.s_addr = INADDR_ANY;  	memset(&nexthop, 0, sizeof(nexthop)); @@ -123,7 +123,7 @@ static bool mtrace_fwd_info(struct pim_instance *pim,  	up = pim_upstream_find(pim, &sg);  	if (!up) { -		sg.src.s_addr = 0; +		sg.src.s_addr = INADDR_ANY;  		up = pim_upstream_find(pim, &sg);  	} @@ -160,7 +160,7 @@ static bool mtrace_fwd_info(struct pim_instance *pim,  	rspp->rtg_proto = MTRACE_RTG_PROTO_PIM;  	/* 6.2.2. 4. Fill in ... S, and Src Mask */ -	if (sg.src.s_addr) { +	if (sg.src.s_addr != INADDR_ANY) {  		rspp->s = 1;  		rspp->src_mask = MTRACE_SRC_MASK_SOURCE;  	} else { @@ -181,9 +181,9 @@ static void mtrace_rsp_set_fwd_code(struct igmp_mtrace_rsp *mtrace_rspp,  static void mtrace_rsp_init(struct igmp_mtrace_rsp *mtrace_rspp)  {  	mtrace_rspp->arrival = 0; -	mtrace_rspp->incoming.s_addr = 0; -	mtrace_rspp->outgoing.s_addr = 0; -	mtrace_rspp->prev_hop.s_addr = 0; +	mtrace_rspp->incoming.s_addr = INADDR_ANY; +	mtrace_rspp->outgoing.s_addr = INADDR_ANY; +	mtrace_rspp->prev_hop.s_addr = INADDR_ANY;  	mtrace_rspp->in_count = htonl(MTRACE_UNKNOWN_COUNT);  	mtrace_rspp->out_count = htonl(MTRACE_UNKNOWN_COUNT);  	mtrace_rspp->total = htonl(MTRACE_UNKNOWN_COUNT); @@ -779,7 +779,7 @@ int igmp_mtrace_recv_qry_req(struct igmp_sock *igmp, struct ip *ip_hdr,  	/* 6.2.2. 2. Attempt to determine the forwarding information... */ -	if (mtracep->grp_addr.s_addr) +	if (mtracep->grp_addr.s_addr != INADDR_ANY)  		fwd_info = mtrace_fwd_info(pim, mtracep, rspp, &out_ifp);  	else  		fwd_info = mtrace_fwd_info_weak(pim, mtracep, rspp, &out_ifp); @@ -797,7 +797,7 @@ int igmp_mtrace_recv_qry_req(struct igmp_sock *igmp, struct ip *ip_hdr,  	reached_source = false; -	if (nh_addr.s_addr == 0) { +	if (nh_addr.s_addr == INADDR_ANY) {  		/* no pim? i.e. 7.5.3. No Previous Hop */  		if (!out_ifp->info) {  			if (PIM_DEBUG_MTRACE) diff --git a/pimd/pim_msdp.c b/pimd/pim_msdp.c index bb02a36e1d..27af9473bb 100644 --- a/pimd/pim_msdp.c +++ b/pimd/pim_msdp.c @@ -473,7 +473,7 @@ static void pim_msdp_sa_local_add(struct pim_instance *pim,  				  struct prefix_sg *sg)  {  	struct in_addr rp; -	rp.s_addr = 0; +	rp.s_addr = INADDR_ANY;  	pim_msdp_sa_ref(pim, NULL /* mp */, sg, rp);  } diff --git a/ripd/rip_routemap.c b/ripd/rip_routemap.c index 4e848766d6..102b64df6b 100644 --- a/ripd/rip_routemap.c +++ b/ripd/rip_routemap.c @@ -158,8 +158,9 @@ route_match_ip_next_hop(void *rule, const struct prefix *prefix,  	if (type == RMAP_RIP) {  		rinfo = object;  		p.family = AF_INET; -		p.prefix = (rinfo->nh.gate.ipv4.s_addr) ? rinfo->nh.gate.ipv4 -							: rinfo->from; +		p.prefix = (rinfo->nh.gate.ipv4.s_addr != INADDR_ANY) +				   ? rinfo->nh.gate.ipv4 +				   : rinfo->from;  		p.prefixlen = IPV4_MAX_BITLEN;  		alist = access_list_lookup(AFI_IP, (char *)rule); @@ -207,8 +208,9 @@ route_match_ip_next_hop_prefix_list(void *rule, const struct prefix *prefix,  	if (type == RMAP_RIP) {  		rinfo = object;  		p.family = AF_INET; -		p.prefix = (rinfo->nh.gate.ipv4.s_addr) ? rinfo->nh.gate.ipv4 -							: rinfo->from; +		p.prefix = (rinfo->nh.gate.ipv4.s_addr != INADDR_ANY) +				   ? rinfo->nh.gate.ipv4 +				   : rinfo->from;  		p.prefixlen = IPV4_MAX_BITLEN;  		plist = prefix_list_lookup(AFI_IP, (char *)rule); diff --git a/ripd/ripd.c b/ripd/ripd.c index 99f48dffdd..5ccefac178 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -1223,7 +1223,8 @@ static void rip_response_process(struct rip_packet *packet, int size,  		}  		/* RIPv1 does not have nexthop value. */ -		if (packet->version == RIPv1 && rte->nexthop.s_addr != 0) { +		if (packet->version == RIPv1 +		    && rte->nexthop.s_addr != INADDR_ANY) {  			zlog_info("RIPv1 packet with nexthop value %s",  				  inet_ntoa(rte->nexthop));  			rip_peer_bad_route(rip, from); @@ -1234,7 +1235,8 @@ static void rip_response_process(struct rip_packet *packet, int size,  		   sub-optimal, but absolutely valid, route may be taken.  If  		   the received Next Hop is not directly reachable, it should be  		   treated as 0.0.0.0. */ -		if (packet->version == RIPv2 && rte->nexthop.s_addr != 0) { +		if (packet->version == RIPv2 +		    && rte->nexthop.s_addr != INADDR_ANY) {  			uint32_t addrval;  			/* Multicast address check. */ @@ -1272,7 +1274,8 @@ static void rip_response_process(struct rip_packet *packet, int size,  								"Next hop %s is not directly reachable. Treat it as 0.0.0.0",  								inet_ntoa(  									rte->nexthop)); -						rte->nexthop.s_addr = 0; +						rte->nexthop.s_addr = +							INADDR_ANY;  					}  					route_unlock_node(rn); @@ -1282,7 +1285,7 @@ static void rip_response_process(struct rip_packet *packet, int size,  							"Next hop %s is not directly reachable. Treat it as 0.0.0.0",  							inet_ntoa(  								rte->nexthop)); -					rte->nexthop.s_addr = 0; +					rte->nexthop.s_addr = INADDR_ANY;  				}  			}  		} @@ -1297,10 +1300,11 @@ static void rip_response_process(struct rip_packet *packet, int size,  		   (/16 for class B's) except when the RIP packet does to inside  		   the classful network in question.  */ -		if ((packet->version == RIPv1 && rte->prefix.s_addr != 0) +		if ((packet->version == RIPv1 +		     && rte->prefix.s_addr != INADDR_ANY)  		    || (packet->version == RIPv2 -			&& (rte->prefix.s_addr != 0 -			    && rte->mask.s_addr == 0))) { +			&& (rte->prefix.s_addr != INADDR_ANY +			    && rte->mask.s_addr == INADDR_ANY))) {  			uint32_t destination;  			if (subnetted == -1) { @@ -1352,7 +1356,8 @@ static void rip_response_process(struct rip_packet *packet, int size,  		/* In case of RIPv2, if prefix in RTE is not netmask applied one  		   ignore the entry.  */ -		if ((packet->version == RIPv2) && (rte->mask.s_addr != 0) +		if ((packet->version == RIPv2) +		    && (rte->mask.s_addr != INADDR_ANY)  		    && ((rte->prefix.s_addr & rte->mask.s_addr)  			!= rte->prefix.s_addr)) {  			zlog_warn( @@ -1363,12 +1368,13 @@ static void rip_response_process(struct rip_packet *packet, int size,  		}  		/* Default route's netmask is ignored. */ -		if (packet->version == RIPv2 && (rte->prefix.s_addr == 0) -		    && (rte->mask.s_addr != 0)) { +		if (packet->version == RIPv2 +		    && (rte->prefix.s_addr == INADDR_ANY) +		    && (rte->mask.s_addr != INADDR_ANY)) {  			if (IS_RIP_DEBUG_EVENT)  				zlog_debug(  					"Default route with non-zero netmask.  Set zero to netmask"); -			rte->mask.s_addr = 0; +			rte->mask.s_addr = INADDR_ANY;  		}  		/* Routing table updates. */ diff --git a/zebra/router-id.c b/zebra/router-id.c index b37d4aea70..710f2f6c27 100644 --- a/zebra/router-id.c +++ b/zebra/router-id.c @@ -75,11 +75,11 @@ void router_id_get(struct prefix *p, vrf_id_t vrf_id)  	struct connected *c;  	struct zebra_vrf *zvrf = vrf_info_get(vrf_id); -	p->u.prefix4.s_addr = 0; +	p->u.prefix4.s_addr = INADDR_ANY;  	p->family = AF_INET;  	p->prefixlen = 32; -	if (zvrf->rid_user_assigned.u.prefix4.s_addr) +	if (zvrf->rid_user_assigned.u.prefix4.s_addr != INADDR_ANY)  		p->u.prefix4.s_addr = zvrf->rid_user_assigned.u.prefix4.s_addr;  	else if (!list_isempty(zvrf->rid_lo_sorted_list)) {  		node = listtail(zvrf->rid_lo_sorted_list); @@ -185,7 +185,8 @@ void router_id_write(struct vty *vty)  	RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)  		if ((zvrf = vrf->info) != NULL) -			if (zvrf->rid_user_assigned.u.prefix4.s_addr) { +			if (zvrf->rid_user_assigned.u.prefix4.s_addr +			    != INADDR_ANY) {  				if (zvrf_id(zvrf) == VRF_DEFAULT)  					vty_out(vty, "router-id %s\n",  						inet_ntoa( diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index b1c679e066..1d63db32e8 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -1162,10 +1162,12 @@ static void _netlink_route_build_singlepath(const char *routedesc, int bytelen,  		addattr_l(nlmsg, req_size, RTA_GATEWAY, &ipv4_ll, 4);  		addattr32(nlmsg, req_size, RTA_OIF, nexthop->ifindex); -		if (nexthop->rmap_src.ipv4.s_addr && (cmd == RTM_NEWROUTE)) +		if (nexthop->rmap_src.ipv4.s_addr != INADDR_ANY +		    && (cmd == RTM_NEWROUTE))  			addattr_l(nlmsg, req_size, RTA_PREFSRC,  				  &nexthop->rmap_src.ipv4, bytelen); -		else if (nexthop->src.ipv4.s_addr && (cmd == RTM_NEWROUTE)) +		else if (nexthop->src.ipv4.s_addr != INADDR_ANY +			 && (cmd == RTM_NEWROUTE))  			addattr_l(nlmsg, req_size, RTA_PREFSRC,  				  &nexthop->src.ipv4, bytelen); @@ -1187,10 +1189,10 @@ static void _netlink_route_build_singlepath(const char *routedesc, int bytelen,  				bytelen, nexthop);  		if (cmd == RTM_NEWROUTE) { -			if (nexthop->rmap_src.ipv4.s_addr) +			if (nexthop->rmap_src.ipv4.s_addr != INADDR_ANY)  				addattr_l(nlmsg, req_size, RTA_PREFSRC,  					  &nexthop->rmap_src.ipv4, bytelen); -			else if (nexthop->src.ipv4.s_addr) +			else if (nexthop->src.ipv4.s_addr != INADDR_ANY)  				addattr_l(nlmsg, req_size, RTA_PREFSRC,  					  &nexthop->src.ipv4, bytelen);  		} @@ -1236,10 +1238,10 @@ static void _netlink_route_build_singlepath(const char *routedesc, int bytelen,  	if (nexthop->type == NEXTHOP_TYPE_IFINDEX) {  		if (cmd == RTM_NEWROUTE) { -			if (nexthop->rmap_src.ipv4.s_addr) +			if (nexthop->rmap_src.ipv4.s_addr != INADDR_ANY)  				addattr_l(nlmsg, req_size, RTA_PREFSRC,  					  &nexthop->rmap_src.ipv4, bytelen); -			else if (nexthop->src.ipv4.s_addr) +			else if (nexthop->src.ipv4.s_addr != INADDR_ANY)  				addattr_l(nlmsg, req_size, RTA_PREFSRC,  					  &nexthop->src.ipv4, bytelen);  		} @@ -1336,9 +1338,9 @@ static void _netlink_route_build_multipath(const char *routedesc, int bytelen,  		rtnh->rtnh_len += sizeof(struct rtattr) + bytelen;  		rtnh->rtnh_ifindex = nexthop->ifindex; -		if (nexthop->rmap_src.ipv4.s_addr) +		if (nexthop->rmap_src.ipv4.s_addr != INADDR_ANY)  			*src = &nexthop->rmap_src; -		else if (nexthop->src.ipv4.s_addr) +		else if (nexthop->src.ipv4.s_addr != INADDR_ANY)  			*src = &nexthop->src;  		if (IS_ZEBRA_DEBUG_KERNEL) @@ -1355,9 +1357,9 @@ static void _netlink_route_build_multipath(const char *routedesc, int bytelen,  		_netlink_route_rta_add_gateway_info(rtmsg->rtm_family, AF_INET,  						    rta, rtnh, NL_PKT_BUF_SIZE,  						    bytelen, nexthop); -		if (nexthop->rmap_src.ipv4.s_addr) +		if (nexthop->rmap_src.ipv4.s_addr != INADDR_ANY)  			*src = &nexthop->rmap_src; -		else if (nexthop->src.ipv4.s_addr) +		else if (nexthop->src.ipv4.s_addr != INADDR_ANY)  			*src = &nexthop->src;  		if (IS_ZEBRA_DEBUG_KERNEL) @@ -1396,9 +1398,9 @@ static void _netlink_route_build_multipath(const char *routedesc, int bytelen,  	/* ifindex */  	if (nexthop->type == NEXTHOP_TYPE_IFINDEX) { -		if (nexthop->rmap_src.ipv4.s_addr) +		if (nexthop->rmap_src.ipv4.s_addr != INADDR_ANY)  			*src = &nexthop->rmap_src; -		else if (nexthop->src.ipv4.s_addr) +		else if (nexthop->src.ipv4.s_addr != INADDR_ANY)  			*src = &nexthop->src;  		if (IS_ZEBRA_DEBUG_KERNEL) diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c index 7786dc246c..d6f55fdeb4 100644 --- a/zebra/zebra_fpm_netlink.c +++ b/zebra/zebra_fpm_netlink.c @@ -218,7 +218,7 @@ static int netlink_route_info_add_nh(netlink_route_info_t *ri,  	if (nexthop->type == NEXTHOP_TYPE_IPV4  	    || nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX) {  		nhi.gateway = &nexthop->gate; -		if (nexthop->src.ipv4.s_addr) +		if (nexthop->src.ipv4.s_addr != INADDR_ANY)  			src = &nexthop->src;  	} @@ -228,7 +228,7 @@ static int netlink_route_info_add_nh(netlink_route_info_t *ri,  	}  	if (nexthop->type == NEXTHOP_TYPE_IFINDEX) { -		if (nexthop->src.ipv4.s_addr) +		if (nexthop->src.ipv4.s_addr != INADDR_ANY)  			src = &nexthop->src;  	} diff --git a/zebra/zebra_fpm_protobuf.c b/zebra/zebra_fpm_protobuf.c index c09fa1c65d..d50981debf 100644 --- a/zebra/zebra_fpm_protobuf.c +++ b/zebra/zebra_fpm_protobuf.c @@ -86,7 +86,7 @@ static inline int add_nexthop(qpb_allocator_t *allocator, Fpm__AddRoute *msg,  	if (nexthop->type == NEXTHOP_TYPE_IPV4  	    || nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX) {  		gateway = &nexthop->gate; -		if (nexthop->src.ipv4.s_addr) +		if (nexthop->src.ipv4.s_addr != INADDR_ANY)  			src = &nexthop->src;  	} @@ -96,7 +96,7 @@ static inline int add_nexthop(qpb_allocator_t *allocator, Fpm__AddRoute *msg,  	}  	if (nexthop->type == NEXTHOP_TYPE_IFINDEX) { -		if (nexthop->src.ipv4.s_addr) +		if (nexthop->src.ipv4.s_addr != INADDR_ANY)  			src = &nexthop->src;  	} diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index ffb2528a24..4b56581ca9 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -3212,7 +3212,7 @@ static int zvni_local_neigh_update(zebra_vni_t *zvni,  			vtep_ip = n->r_vtep_ip;  			/* Mark appropriately */  			UNSET_FLAG(n->flags, ZEBRA_NEIGH_REMOTE); -			n->r_vtep_ip.s_addr = 0; +			n->r_vtep_ip.s_addr = INADDR_ANY;  			SET_FLAG(n->flags, ZEBRA_NEIGH_LOCAL);  			n->ifindex = ifp->ifindex;  		} @@ -9985,7 +9985,7 @@ static zebra_vxlan_sg_t *zebra_vxlan_sg_add(struct zebra_vrf *zvrf,  	 * 2. the XG entry is used by pimd to setup the  	 * vxlan-termination-mroute  	 */ -	if (sg->src.s_addr) { +	if (sg->src.s_addr != INADDR_ANY) {  		memset(&sip, 0, sizeof(sip));  		parent = zebra_vxlan_sg_do_ref(zvrf, sip, sg->grp);  		if (!parent) @@ -10017,7 +10017,7 @@ static void zebra_vxlan_sg_del(zebra_vxlan_sg_t *vxlan_sg)  	/* On SG entry deletion remove the reference to its parent XG  	 * entry  	 */ -	if (vxlan_sg->sg.src.s_addr) { +	if (vxlan_sg->sg.src.s_addr != INADDR_ANY) {  		memset(&sip, 0, sizeof(sip));  		zebra_vxlan_sg_do_deref(zvrf, sip, vxlan_sg->sg.grp);  	} @@ -10076,7 +10076,8 @@ static void zebra_vxlan_sg_deref(struct in_addr local_vtep_ip,  {  	struct zebra_vrf *zvrf; -	if (!local_vtep_ip.s_addr || !mcast_grp.s_addr) +	if (local_vtep_ip.s_addr == INADDR_ANY +	    || mcast_grp.s_addr == INADDR_ANY)  		return;  	zvrf = vrf_info_lookup(VRF_DEFAULT); @@ -10091,7 +10092,8 @@ static void zebra_vxlan_sg_ref(struct in_addr local_vtep_ip,  {  	struct zebra_vrf *zvrf; -	if (!local_vtep_ip.s_addr || !mcast_grp.s_addr) +	if (local_vtep_ip.s_addr == INADDR_ANY +	    || mcast_grp.s_addr == INADDR_ANY)  		return;  	zvrf = vrf_info_lookup(VRF_DEFAULT);  | 
