Merge pull request #5767 from ton31337/fix/replace_s_addr_0_to_INADDR_ANY

MOAR CODE NAZI: replace s_addr 0 => INADDR_ANY
This commit is contained in:
Donald Sharp 2020-02-06 07:30:21 -05:00 committed by GitHub
commit 36955f90e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 196 additions and 157 deletions

View File

@ -1932,7 +1932,7 @@ int bgp_mp_reach_parse(struct bgp_attr_parser_args *args,
case BGP_ATTR_NHLEN_IPV4: case BGP_ATTR_NHLEN_IPV4:
stream_get(&attr->mp_nexthop_global_in, s, IPV4_MAX_BYTELEN); stream_get(&attr->mp_nexthop_global_in, s, IPV4_MAX_BYTELEN);
/* Probably needed for RFC 2283 */ /* Probably needed for RFC 2283 */
if (attr->nexthop.s_addr == 0) if (attr->nexthop.s_addr == INADDR_ANY)
memcpy(&attr->nexthop.s_addr, memcpy(&attr->nexthop.s_addr,
&attr->mp_nexthop_global_in, IPV4_MAX_BYTELEN); &attr->mp_nexthop_global_in, IPV4_MAX_BYTELEN);
break; break;

View File

@ -771,7 +771,7 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int type,
for (; pi; pi = pi->next) { for (; pi; pi = pi->next) {
json_object *json_path = NULL; json_object *json_path = NULL;
if (vtep_ip.s_addr if (vtep_ip.s_addr != INADDR_ANY
&& !IPV4_ADDR_SAME(&(vtep_ip), && !IPV4_ADDR_SAME(&(vtep_ip),
&(pi->attr->nexthop))) &(pi->attr->nexthop)))
continue; continue;

View File

@ -455,7 +455,7 @@ int bgp_flowspec_match_rules_fill(uint8_t *nlri_content, int len,
* ignore that rule * ignore that rule
*/ */
if (prefix->family == AF_INET if (prefix->family == AF_INET
&& prefix->u.prefix4.s_addr == 0) && prefix->u.prefix4.s_addr == INADDR_ANY)
bpem->match_bitmask_iprule |= bitmask; bpem->match_bitmask_iprule |= bitmask;
else else
bpem->match_bitmask |= bitmask; bpem->match_bitmask |= bitmask;

View File

@ -1527,7 +1527,7 @@ int bgp_start(struct peer *peer)
} }
/* Clear remote router-id. */ /* Clear remote router-id. */
peer->remote_id.s_addr = 0; peer->remote_id.s_addr = INADDR_ANY;
/* Clear peer capability flag. */ /* Clear peer capability flag. */
peer->cap = 0; peer->cap = 0;

View File

@ -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 */ /* 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)); memset(&attr.mp_nexthop_global, 0, sizeof(struct in6_addr));
/* TODO: should we set ATOMIC_AGGREGATE and AGGREGATOR? */ /* TODO: should we set ATOMIC_AGGREGATE and AGGREGATOR? */

View File

@ -1186,7 +1186,8 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size)
} }
/* remote router-id check. */ /* 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)) { || ntohl(peer->local_id.s_addr) == ntohl(remote_id.s_addr)) {
if (bgp_debug_neighbor_events(peer)) if (bgp_debug_neighbor_events(peer))
zlog_debug("%s bad OPEN, wrong router identifier %s", 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_MULTICAST]
|| peer->afc_nego[AFI_IP][SAFI_MPLS_VPN] || peer->afc_nego[AFI_IP][SAFI_MPLS_VPN]
|| peer->afc_nego[AFI_IP][SAFI_ENCAP]) { || 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) #if defined(HAVE_CUMULUS)
flog_err( flog_err(
EC_BGP_SND_FAIL, EC_BGP_SND_FAIL,

View File

@ -754,13 +754,15 @@ int bgp_pbr_build_and_validate_entry(struct prefix *p,
* draft-ietf-idr-flowspec-redirect * draft-ietf-idr-flowspec-redirect
*/ */
if (api_action_redirect_ip) { if (api_action_redirect_ip) {
if (api_action_redirect_ip->u if (api_action_redirect_ip->u.zr
.zr.redirect_ip_v4.s_addr) .redirect_ip_v4.s_addr
!= INADDR_ANY)
continue; continue;
if (!path->attr->nexthop.s_addr) if (path->attr->nexthop.s_addr
== INADDR_ANY)
continue; continue;
api_action_redirect_ip->u api_action_redirect_ip->u.zr
.zr.redirect_ip_v4.s_addr = .redirect_ip_v4.s_addr =
path->attr->nexthop.s_addr; path->attr->nexthop.s_addr;
api_action_redirect_ip->u.zr.duplicate api_action_redirect_ip->u.zr.duplicate
= ecom_eval->val[7]; = ecom_eval->val[7];

View File

@ -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) static void subgroup_announce_reset_nhop(uint8_t family, struct attr *attr)
{ {
if (family == AF_INET) { if (family == AF_INET) {
attr->nexthop.s_addr = 0; attr->nexthop.s_addr = INADDR_ANY;
attr->mp_nexthop_global_in.s_addr = 0; attr->mp_nexthop_global_in.s_addr = INADDR_ANY;
} }
if (family == AF_INET6) if (family == AF_INET6)
memset(&attr->mp_nexthop_global, 0, IPV6_MAX_BYTELEN); 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 NEXT_HOP is present, validate it. */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) { 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)) || IPV4_CLASS_DE(ntohl(attr->nexthop.s_addr))
|| bgp_nexthop_self(bgp, afi, type, stype, || bgp_nexthop_self(bgp, afi, type, stype, attr, rn))
attr, rn))
return 1; 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) { switch (attr->mp_nexthop_len) {
case BGP_ATTR_NHLEN_IPV4: case BGP_ATTR_NHLEN_IPV4:
case BGP_ATTR_NHLEN_VPNV4: case BGP_ATTR_NHLEN_VPNV4:
ret = (attr->mp_nexthop_global_in.s_addr == 0 ret = (attr->mp_nexthop_global_in.s_addr == INADDR_ANY
|| IPV4_CLASS_DE(ntohl( || IPV4_CLASS_DE(
attr->mp_nexthop_global_in.s_addr)) ntohl(attr->mp_nexthop_global_in.s_addr))
|| bgp_nexthop_self(bgp, afi, type, stype, || bgp_nexthop_self(bgp, afi, type, stype, attr,
attr, rn)); rn));
break; break;
case BGP_ATTR_NHLEN_IPV6_GLOBAL: 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->backdoor = backdoor;
bgp_static->valid = 0; bgp_static->valid = 0;
bgp_static->igpmetric = 0; bgp_static->igpmetric = 0;
bgp_static->igpnexthop.s_addr = 0; bgp_static->igpnexthop.s_addr = INADDR_ANY;
bgp_static->label_index = label_index; bgp_static->label_index = label_index;
if (rmap) { 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->backdoor = 0;
bgp_static->valid = 0; bgp_static->valid = 0;
bgp_static->igpmetric = 0; bgp_static->igpmetric = 0;
bgp_static->igpnexthop.s_addr = 0; bgp_static->igpnexthop.s_addr = INADDR_ANY;
bgp_static->label = label; bgp_static->label = label;
bgp_static->prd = prd; bgp_static->prd = prd;
@ -7540,7 +7539,7 @@ void route_vty_out(struct vty *vty, struct prefix *p,
: inet_ntoa(attr->nexthop), : inet_ntoa(attr->nexthop),
vrf_id_str); vrf_id_str);
} else if (safi == SAFI_FLOWSPEC) { } else if (safi == SAFI_FLOWSPEC) {
if (attr->nexthop.s_addr != 0) { if (attr->nexthop.s_addr != INADDR_ANY) {
if (json_paths) { if (json_paths) {
json_nexthop_global = json_object_new_object(); json_nexthop_global = json_object_new_object();

View File

@ -1705,7 +1705,7 @@ route_set_ip_nexthop(void *rule, const struct prefix *prefix,
*/ */
SET_FLAG(path->attr->rmap_change_flags, SET_FLAG(path->attr->rmap_change_flags,
BATTR_RMAP_NEXTHOP_PEER_ADDRESS); BATTR_RMAP_NEXTHOP_PEER_ADDRESS);
path->attr->nexthop.s_addr = 0; path->attr->nexthop.s_addr = INADDR_ANY;
} }
} else { } else {
/* Set next hop value. */ /* Set next hop value. */

View File

@ -755,7 +755,7 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
oid2in_addr(offset, len, &paddr); oid2in_addr(offset, len, &paddr);
} else } else
paddr.s_addr = 0; paddr.s_addr = INADDR_ANY;
if (!rn) if (!rn)
return NULL; return NULL;
@ -804,7 +804,7 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
return min; return min;
} }
paddr.s_addr = 0; paddr.s_addr = INADDR_ANY;
} while ((rn = bgp_route_next(rn)) != NULL); } while ((rn = bgp_route_next(rn)) != NULL);
} }
return NULL; return NULL;

View File

@ -467,12 +467,12 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
mod_v4nh = &peer->nexthop.v4; mod_v4nh = &peer->nexthop.v4;
nh_modified = 1; nh_modified = 1;
} }
} else if (!v4nh.s_addr) { } else if (v4nh.s_addr == INADDR_ANY) {
mod_v4nh = &peer->nexthop.v4; mod_v4nh = &peer->nexthop.v4;
nh_modified = 1; nh_modified = 1;
} else if ( } else if (peer->sort == BGP_PEER_EBGP
peer->sort == BGP_PEER_EBGP && (bgp_multiaccess_check_v4(v4nh, peer)
&& (bgp_multiaccess_check_v4(v4nh, peer) == 0) == 0)
&& !CHECK_FLAG( && !CHECK_FLAG(
vec->flags, vec->flags,
BPKT_ATTRVEC_FLAGS_RMAP_NH_UNCHANGED) BPKT_ATTRVEC_FLAGS_RMAP_NH_UNCHANGED)
@ -628,7 +628,7 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
mod_v4nh = &v4nh; mod_v4nh = &v4nh;
/* No route-map changes allowed for EVPN nexthops. */ /* No route-map changes allowed for EVPN nexthops. */
if (!v4nh.s_addr) { if (v4nh.s_addr == INADDR_ANY) {
mod_v4nh = &peer->nexthop.v4; mod_v4nh = &peer->nexthop.v4;
nh_modified = 1; nh_modified = 1;
} }

View File

@ -819,7 +819,7 @@ bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote,
/* IPv4 nexthop. */ /* IPv4 nexthop. */
ret = if_get_ipv4_address(ifp, &nexthop->v4); 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; nexthop->v4 = peer->local_id;
/* Global address*/ /* Global address*/
@ -2548,7 +2548,8 @@ static int bgp_zebra_process_local_vni(ZAPI_CALLBACK_ARGS)
if (cmd == ZEBRA_VNI_ADD) if (cmd == ZEBRA_VNI_ADD)
return bgp_evpn_local_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); tenant_vrf_id, mcast_grp);
else else
return bgp_evpn_local_vni_del(bgp, vni); 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); SET_FLAG(api.message, ZAPI_MESSAGE_DISTANCE);
/* redirect IP */ /* redirect IP */
if (nh->gate.ipv4.s_addr) { if (nh->gate.ipv4.s_addr != INADDR_ANY) {
char buff[PREFIX_STRLEN]; char buff[PREFIX_STRLEN];
api_nh->vrf_id = nh->vrf_id; api_nh->vrf_id = nh->vrf_id;

View File

@ -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) int bgp_router_id_static_set(struct bgp *bgp, struct in_addr id)
{ {
bgp->router_id_static = 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 */); true /* is config */);
return 0; return 0;
} }

View File

@ -230,7 +230,7 @@ int eigrp_network_set(struct eigrp *eigrp, struct prefix *p)
rn->info = (void *)pref; rn->info = (void *)pref;
/* Schedule Router ID Update. */ /* Schedule Router ID Update. */
if (eigrp->router_id.s_addr == 0) if (eigrp->router_id.s_addr == INADDR_ANY)
eigrp_router_id_update(eigrp); eigrp_router_id_update(eigrp);
/* Run network config now. */ /* Run network config now. */
/* Get target interface. */ /* Get target interface. */

View File

@ -161,7 +161,7 @@ static int eigrpd_instance_router_id_destroy(enum nb_event event,
break; break;
case NB_EV_APPLY: case NB_EV_APPLY:
eigrp = nb_running_get_entry(dnode, NULL, true); eigrp = nb_running_get_entry(dnode, NULL, true);
eigrp->router_id_static.s_addr = 0; eigrp->router_id_static.s_addr = INADDR_ANY;
break; break;
} }

View File

@ -99,10 +99,10 @@ void eigrp_router_id_update(struct eigrp *eigrp)
router_id_old = eigrp->router_id; 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; 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; router_id = eigrp->router_id;
else else
@ -142,8 +142,8 @@ static struct eigrp *eigrp_new(uint16_t as, vrf_id_t vrf_id)
eigrp->vrf_id = vrf_id; eigrp->vrf_id = vrf_id;
eigrp->vrid = 0; eigrp->vrid = 0;
eigrp->AS = as; eigrp->AS = as;
eigrp->router_id.s_addr = 0; eigrp->router_id.s_addr = INADDR_ANY;
eigrp->router_id_static.s_addr = 0; eigrp->router_id_static.s_addr = INADDR_ANY;
eigrp->sequence_number = 1; eigrp->sequence_number = 1;
/*Configure default K Values for EIGRP Process*/ /*Configure default K Values for EIGRP Process*/

View File

@ -250,9 +250,8 @@ ldp_config_write(struct vty *vty)
vty_out (vty, "mpls ldp\n"); vty_out (vty, "mpls ldp\n");
if (ldpd_conf->rtr_id.s_addr != 0) if (ldpd_conf->rtr_id.s_addr != INADDR_ANY)
vty_out (vty, " router-id %s\n", vty_out(vty, " router-id %s\n", inet_ntoa(ldpd_conf->rtr_id));
inet_ntoa(ldpd_conf->rtr_id));
if (ldpd_conf->lhello_holdtime != LINK_DFLT_HOLDTIME && if (ldpd_conf->lhello_holdtime != LINK_DFLT_HOLDTIME &&
ldpd_conf->lhello_holdtime != 0) ldpd_conf->lhello_holdtime != 0)

View File

@ -2551,7 +2551,8 @@ static int filter_show(struct vty *vty, const char *name, afi_t afi)
else { else {
vty_out(vty, " %s", vty_out(vty, " %s",
inet_ntoa(filter->addr)); inet_ntoa(filter->addr));
if (filter->addr_mask.s_addr != 0) if (filter->addr_mask.s_addr
!= INADDR_ANY)
vty_out(vty, vty_out(vty,
", wildcard bits %s", ", wildcard bits %s",
inet_ntoa( inet_ntoa(
@ -2599,7 +2600,8 @@ static int filter_show(struct vty *vty, const char *name, afi_t afi)
else { else {
vty_out(vty, " %s", vty_out(vty, " %s",
inet_ntoa(filter->addr)); inet_ntoa(filter->addr));
if (filter->addr_mask.s_addr != 0) if (filter->addr_mask.s_addr
!= INADDR_ANY)
vty_out(vty, vty_out(vty,
", wildcard bits %s", ", wildcard bits %s",
inet_ntoa( inet_ntoa(
@ -2692,7 +2694,7 @@ static void config_write_access_cisco(struct vty *vty, struct filter *mfilter)
vty_out(vty, " ip"); vty_out(vty, " ip");
if (filter->addr_mask.s_addr == 0xffffffff) if (filter->addr_mask.s_addr == 0xffffffff)
vty_out(vty, " any"); 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)); vty_out(vty, " host %s", inet_ntoa(filter->addr));
else { else {
vty_out(vty, " %s", inet_ntoa(filter->addr)); 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) if (filter->mask_mask.s_addr == 0xffffffff)
vty_out(vty, " any"); 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)); vty_out(vty, " host %s", inet_ntoa(filter->mask));
else { else {
vty_out(vty, " %s", inet_ntoa(filter->mask)); 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"); vty_out(vty, " any\n");
else { else {
vty_out(vty, " %s", inet_ntoa(filter->addr)); 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", vty_out(vty, " %s",
inet_ntoa(filter->addr_mask)); inet_ntoa(filter->addr_mask));
vty_out(vty, "\n"); vty_out(vty, "\n");

View File

@ -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. */ /* If prefix is 0.0.0.0/0 then return 1 else return 0. */
int prefix_ipv4_any(const struct prefix_ipv4 *p) 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 */ /* Allocate a new ip version 6 route */
@ -1144,7 +1144,7 @@ int netmask_str2prefix_str(const char *net_str, const char *mask_str,
} else { } else {
destination = ntohl(network.s_addr); destination = ntohl(network.s_addr);
if (network.s_addr == 0) if (network.s_addr == INADDR_ANY)
prefixlen = 0; prefixlen = 0;
else if (IN_CLASSC(destination)) else if (IN_CLASSC(destination))
prefixlen = 24; prefixlen = 24;

View File

@ -940,7 +940,7 @@ lib_route_map_entry_set_action_ipv4_address_modify(enum nb_event event,
* only implemented action. * only implemented action.
*/ */
yang_dnode_get_ipv4(&ia, dnode, NULL); 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; return NB_ERR_VALIDATION;
/* FALLTHROUGH */ /* FALLTHROUGH */
case NB_EV_PREPARE: case NB_EV_PREPARE:

View File

@ -135,7 +135,7 @@ static void nhrp_interface_update_nbma(struct interface *ifp)
&nifp->linkidx, &saddr); &nifp->linkidx, &saddr);
debugf(NHRP_DEBUG_IF, "%s: GRE: %x %x %x", ifp->name, debugf(NHRP_DEBUG_IF, "%s: GRE: %x %x %x", ifp->name,
nifp->grekey, nifp->linkidx, saddr.s_addr); 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, sockunion_set(&nbma, AF_INET, (uint8_t *)&saddr.s_addr,
sizeof(saddr.s_addr)); sizeof(saddr.s_addr));
else if (!nbmaifp && nifp->linkidx != IFINDEX_INTERNAL) else if (!nbmaifp && nifp->linkidx != IFINDEX_INTERNAL)

View File

@ -451,7 +451,7 @@ int ospf_apiclient_lsa_originate(struct ospf_apiclient *oclient,
tmp = SET_OPAQUE_LSID(opaque_type, opaque_id); tmp = SET_OPAQUE_LSID(opaque_type, opaque_id);
lsah->id.s_addr = htonl(tmp); lsah->id.s_addr = htonl(tmp);
lsah->adv_router.s_addr = 0; lsah->adv_router.s_addr = INADDR_ANY;
lsah->ls_seqnum = 0; lsah->ls_seqnum = 0;
lsah->checksum = 0; lsah->checksum = 0;
lsah->length = htons(sizeof(struct lsa_header) + opaquelen); lsah->length = htons(sizeof(struct lsa_header) + opaquelen);

View File

@ -310,7 +310,7 @@ int ospf_area_range_substitute_unset(struct ospf *ospf, struct in_addr area_id,
ospf_schedule_abr_task(ospf); ospf_schedule_abr_task(ospf);
UNSET_FLAG(range->flags, OSPF_AREA_RANGE_SUBSTITUTE); 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; range->subst_masklen = 0;
return 1; return 1;

View File

@ -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 external-LSA. This indicates the IP address to which
packets for the destination should be forwarded. */ 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 /* If the forwarding address is set to 0.0.0.0, packets should
be sent to the ASBR itself. Among the multiple routing table be sent to the ASBR itself. Among the multiple routing table
entries for the ASBR, select the preferred entry as follows. 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); 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); ospf_ase_complete_direct_routes(new, al->e[0].fwd_addr);
return 0; return 0;
} else { } else {
@ -512,7 +512,7 @@ int ospf_ase_calculate_route(struct ospf *ospf, struct ospf_lsa *lsa)
zlog_debug( zlog_debug(
"Route[External]: New route is better"); "Route[External]: New route is better");
ospf_route_subst(rn, new, asbr_route); 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( ospf_ase_complete_direct_routes(
new, al->e[0].fwd_addr); new, al->e[0].fwd_addr);
or = new; or = new;
@ -530,7 +530,7 @@ int ospf_ase_calculate_route(struct ospf *ospf, struct ospf_lsa *lsa)
if (IS_DEBUG_OSPF(lsa, LSA)) if (IS_DEBUG_OSPF(lsa, LSA))
zlog_debug("Route[External]: Routes are equal"); zlog_debug("Route[External]: Routes are equal");
ospf_route_copy_nexthops(or, asbr_route->paths); 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( ospf_ase_complete_direct_routes(
or, al->e[0].fwd_addr); or, al->e[0].fwd_addr);
} }

View File

@ -862,7 +862,7 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
p = prefix_ipv4_new(); p = prefix_ipv4_new();
p->family = AF_INET; p->family = AF_INET;
p->prefix.s_addr = 0; p->prefix.s_addr = INADDR_ANY;
p->prefixlen = 0; p->prefixlen = 0;
co->address = (struct prefix *)p; co->address = (struct prefix *)p;
@ -885,7 +885,7 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug("ospf_vl_new(): set if->name to %s", vi->name); 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); area = ospf_area_get(ospf, area_id);
voi->area = area; 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; 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; vl_data->vl_oi->address->prefixlen = 0;
ospf_if_free(vl_data->vl_oi); ospf_if_free(vl_data->vl_oi);
if_delete(&ifp); 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) if ((oi = vl_data->vl_oi) == NULL)
return; return;
oi->address->u.prefix4.s_addr = 0; oi->address->u.prefix4.s_addr = INADDR_ANY;
oi->address->prefixlen = 0; oi->address->prefixlen = 0;
UNSET_FLAG(oi->ifp->flags, IFF_UP); UNSET_FLAG(oi->ifp->flags, IFF_UP);

View File

@ -169,7 +169,7 @@ static void ospf_dr_eligible_routers(struct route_table *nbrs,
for (rn = route_top(nbrs); rn; rn = route_next(rn)) for (rn = route_top(nbrs); rn; rn = route_next(rn))
if ((nbr = rn->info) != NULL) if ((nbr = rn->info) != NULL)
/* Ignore 0.0.0.0 node*/ /* Ignore 0.0.0.0 node*/
if (nbr->router_id.s_addr != 0) if (nbr->router_id.s_addr != INADDR_ANY)
/* Is neighbor eligible? */ /* Is neighbor eligible? */
if (nbr->priority > 0) if (nbr->priority > 0)
/* Is neighbor upper 2-Way? */ /* 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)) for (rn = route_top(nbrs); rn; rn = route_next(rn))
if ((nbr = rn->info) != NULL) if ((nbr = rn->info) != NULL)
/* Ignore 0.0.0.0 node*/ /* 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? */ /* Is neighbor upper 2-Way? */
if (nbr->state >= NSM_TwoWay) if (nbr->state >= NSM_TwoWay)
/* Ignore myself. */ /* Ignore myself. */

View File

@ -820,7 +820,7 @@ static struct ospf_lsa *ospf_router_lsa_originate(struct ospf_area *area)
} }
/* Sanity check. */ /* Sanity check. */
if (new->data->adv_router.s_addr == 0) { if (new->data->adv_router.s_addr == INADDR_ANY) {
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug("LSA[Type1]: AdvRouter is 0, discard"); zlog_debug("LSA[Type1]: AdvRouter is 0, discard");
ospf_lsa_discard(new); ospf_lsa_discard(new);
@ -1459,7 +1459,7 @@ struct in_addr ospf_get_ip_from_ifp(struct ospf_interface *oi)
{ {
struct in_addr fwd; struct in_addr fwd;
fwd.s_addr = 0; fwd.s_addr = INADDR_ANY;
if (if_is_operative(oi->ifp)) if (if_is_operative(oi->ifp))
return oi->address->u.prefix4; return oi->address->u.prefix4;
@ -1931,7 +1931,7 @@ int is_prefix_default(struct prefix_ipv4 *p)
struct prefix_ipv4 q; struct prefix_ipv4 q;
q.family = AF_INET; q.family = AF_INET;
q.prefix.s_addr = 0; q.prefix.s_addr = INADDR_ANY;
q.prefixlen = 0; q.prefixlen = 0;
return prefix_same((struct prefix *)p, (struct prefix *)&q); return prefix_same((struct prefix *)p, (struct prefix *)&q);
@ -1979,9 +1979,10 @@ 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) if (IS_DEBUG_OSPF_EVENT)
zlog_debug("LSA[Type5:%pI4]: deferring AS-external-LSA origination, router ID is zero", zlog_debug(
"LSA[Type5:%pI4]: deferring AS-external-LSA origination, router ID is zero",
&ei->p.prefix); &ei->p.prefix);
return NULL; return NULL;
} }
@ -2197,7 +2198,7 @@ void ospf_external_lsa_refresh_default(struct ospf *ospf)
p.family = AF_INET; p.family = AF_INET;
p.prefixlen = 0; p.prefixlen = 0;
p.prefix.s_addr = 0; p.prefix.s_addr = INADDR_ANY;
ei = ospf_default_external_info(ospf); ei = ospf_default_external_info(ospf);
lsa = ospf_external_info_find_lsa(ospf, &p); lsa = ospf_external_info_find_lsa(ospf, &p);

View File

@ -1074,7 +1074,8 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh,
/* If neighbor itself declares DR and no BDR exists, /* If neighbor itself declares DR and no BDR exists,
cause event BackupSeen */ cause event BackupSeen */
if (IPV4_ADDR_SAME(&nbr->address.u.prefix4, &hello->d_router)) 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); OSPF_ISM_EVENT_SCHEDULE(oi, ISM_BackupSeen);
/* neighbor itself declares BDR. */ /* 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)) for (rn = route_top(oi->nbrs); rn; rn = route_next(rn))
if ((nbr = rn->info)) if ((nbr = rn->info))
if (nbr->router_id.s_addr if (nbr->router_id.s_addr
!= 0) /* Ignore 0.0.0.0 node. */ != INADDR_ANY) /* Ignore 0.0.0.0 node. */
if (nbr->state if (nbr->state
!= NSM_Attempt) /* Ignore Down neighbor. */ != NSM_Attempt) /* Ignore Down neighbor. */
if (nbr->state if (nbr->state
@ -3364,7 +3365,7 @@ static int ospf_make_hello(struct ospf_interface *oi, struct stream *s)
/* Check neighbor is /* Check neighbor is
* sane? */ * sane? */
if (nbr->d_router.s_addr if (nbr->d_router.s_addr
!= 0 != INADDR_ANY
&& IPV4_ADDR_SAME( && IPV4_ADDR_SAME(
&nbr->d_router, &nbr->d_router,
&oi->address &oi->address

View File

@ -603,7 +603,7 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link,
IF_NAME(oi)); IF_NAME(oi));
path = ospf_path_new(); path = ospf_path_new();
path->nexthop.s_addr = 0; path->nexthop.s_addr = INADDR_ANY;
path->ifindex = oi->ifp->ifindex; path->ifindex = oi->ifp->ifindex;
if (CHECK_FLAG(oi->connected->flags, if (CHECK_FLAG(oi->connected->flags,
ZEBRA_IFA_UNNUMBERED)) 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 = ospf_route_new();
new_or->type = OSPF_DESTINATION_DISCARD; 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->cost = 0;
new_or->u.std.area_id = area->area_id; new_or->u.std.area_id = area->area_id;
new_or->u.std.external_routing = area->external_routing; new_or->u.std.external_routing = area->external_routing;

View File

@ -3551,7 +3551,7 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
} }
/* Show DR information. */ /* Show DR information. */
if (DR(oi).s_addr == 0) { if (DR(oi).s_addr == INADDR_ANY) {
if (!use_json) if (!use_json)
vty_out(vty, vty_out(vty,
" No backup designated router on this network\n"); " 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 if (nbr->state == NSM_Attempt
&& nbr->router_id.s_addr == 0) && nbr->router_id.s_addr == INADDR_ANY)
strlcpy(neigh_str, "neighbor", strlcpy(neigh_str, "neighbor",
sizeof(neigh_str)); sizeof(neigh_str));
else else
@ -4258,7 +4258,7 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty,
ospf_nbr_state_message(nbr, msgbuf, 16); ospf_nbr_state_message(nbr, msgbuf, 16);
if (nbr->state == NSM_Attempt if (nbr->state == NSM_Attempt
&& nbr->router_id.s_addr == 0) && nbr->router_id.s_addr == INADDR_ANY)
vty_out(vty, "%-15s %3d %-15s ", "-", vty_out(vty, "%-15s %3d %-15s ", "-",
nbr->priority, msgbuf); nbr->priority, msgbuf);
else else
@ -4908,7 +4908,8 @@ static void show_ip_ospf_neighbor_detail_sub(struct vty *vty,
json_neigh_array = NULL; 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)); strlcpy(neigh_str, "noNbrId", sizeof(neigh_str));
else else
strlcpy(neigh_str, inet_ntoa(nbr->router_id), strlcpy(neigh_str, inet_ntoa(nbr->router_id),
@ -4926,7 +4927,8 @@ static void show_ip_ospf_neighbor_detail_sub(struct vty *vty,
} else { } else {
/* Show neighbor ID. */ /* 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,", "-"); vty_out(vty, " Neighbor %s,", "-");
else else
vty_out(vty, " Neighbor %s,", vty_out(vty, " Neighbor %s,",

View File

@ -585,9 +585,9 @@ int ospf_redistribute_default_set(struct ospf *ospf, int originate, int mtype,
int cur_originate = ospf->default_originate; int cur_originate = ospf->default_originate;
const char *type_str = NULL; const char *type_str = NULL;
nexthop.s_addr = 0; nexthop.s_addr = INADDR_ANY;
p.family = AF_INET; p.family = AF_INET;
p.prefix.s_addr = 0; p.prefix.s_addr = INADDR_ANY;
p.prefixlen = 0; p.prefixlen = 0;
ospf->default_originate = originate; 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 */ /* Nothing has changed, so nothing to do; return */
return 0; return 0;
} }
if (ospf->router_id.s_addr != 0) { if (ospf->router_id.s_addr != INADDR_ANY) {
if (ei) { if (ei) {
if (is_prefix_default(&p)) if (is_prefix_default(&p))
ospf_external_lsa_refresh_default(ospf); ospf_external_lsa_refresh_default(ospf);

View File

@ -329,7 +329,7 @@ struct ospf *ospf_lookup_instance(unsigned short instance)
static int ospf_is_ready(struct ospf *ospf) static int ospf_is_ready(struct ospf *ospf)
{ {
/* OSPF must be on and Router-ID must be configured. */ /* 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 0;
return 1; return 1;
@ -379,7 +379,7 @@ struct ospf *ospf_get(unsigned short instance, const char *name, bool *created)
ospf = ospf_new(instance, name); ospf = ospf_new(instance, name);
ospf_add(ospf); 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_router_id_update(ospf);
ospf_opaque_type11_lsa_init(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 = ospf_new(instance, NULL /* VRF_DEFAULT*/);
ospf_add(ospf); 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_router_id_update(ospf);
ospf_opaque_type11_lsa_init(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 * ospf_router_id_update() will call ospf_if_update
* whenever r-id is configured instead. * 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); ospf_if_up(oi);
} }
@ -1267,7 +1268,7 @@ static void ospf_network_run(struct prefix *p, struct ospf_area *area)
struct interface *ifp; struct interface *ifp;
/* Schedule Router ID Update. */ /* 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); ospf_router_id_update(area->ospf);
/* Get target interface. */ /* Get target interface. */

View File

@ -448,7 +448,7 @@ int main(int argc, char *const argv[])
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
mc_group.s_addr = 0; mc_group.s_addr = INADDR_ANY;
not_group = false; not_group = false;
if (argc == 3) { if (argc == 3) {

View File

@ -1741,10 +1741,10 @@ static void pim_show_join(struct pim_instance *pim, struct vty *vty,
continue; continue;
RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) { 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) && sg->grp.s_addr != ch->sg.grp.s_addr)
continue; continue;
if (sg->src.s_addr != 0 if (sg->src.s_addr != INADDR_ANY
&& sg->src.s_addr != ch->sg.src.s_addr) && sg->src.s_addr != ch->sg.src.s_addr)
continue; continue;
pim_show_join_helper(vty, pim_ifp, ch, json, now, uj); pim_show_join_helper(vty, pim_ifp, ch, json, now, uj);
@ -2448,9 +2448,11 @@ static void pim_show_upstream(struct pim_instance *pim, struct vty *vty,
char msdp_reg_timer[10]; char msdp_reg_timer[10];
char state_str[PIM_REG_STATE_STR_LEN]; 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; 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; continue;
pim_inet4_dump("<src?>", up->sg.src, src_str, sizeof(src_str)); pim_inet4_dump("<src?>", up->sg.src, src_str, sizeof(src_str));

View File

@ -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_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_metric = pim_macro_ch_my_assert_metric_eval(ch);
ch->ifassert_winner.s_addr = 0; ch->ifassert_winner.s_addr = INADDR_ANY;
/* Assert state */ /* Assert state */
ch->t_ifassert_timer = NULL; ch->t_ifassert_timer = NULL;

View File

@ -68,7 +68,7 @@ static bool mtrace_fwd_info_weak(struct pim_instance *pim,
struct in_addr nh_addr; struct in_addr nh_addr;
char nexthop_str[INET_ADDRSTRLEN]; char nexthop_str[INET_ADDRSTRLEN];
nh_addr.s_addr = 0; nh_addr.s_addr = INADDR_ANY;
memset(&nexthop, 0, sizeof(nexthop)); memset(&nexthop, 0, sizeof(nexthop));
@ -123,7 +123,7 @@ static bool mtrace_fwd_info(struct pim_instance *pim,
up = pim_upstream_find(pim, &sg); up = pim_upstream_find(pim, &sg);
if (!up) { if (!up) {
sg.src.s_addr = 0; sg.src.s_addr = INADDR_ANY;
up = pim_upstream_find(pim, &sg); 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; rspp->rtg_proto = MTRACE_RTG_PROTO_PIM;
/* 6.2.2. 4. Fill in ... S, and Src Mask */ /* 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->s = 1;
rspp->src_mask = MTRACE_SRC_MASK_SOURCE; rspp->src_mask = MTRACE_SRC_MASK_SOURCE;
} else { } 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) static void mtrace_rsp_init(struct igmp_mtrace_rsp *mtrace_rspp)
{ {
mtrace_rspp->arrival = 0; mtrace_rspp->arrival = 0;
mtrace_rspp->incoming.s_addr = 0; mtrace_rspp->incoming.s_addr = INADDR_ANY;
mtrace_rspp->outgoing.s_addr = 0; mtrace_rspp->outgoing.s_addr = INADDR_ANY;
mtrace_rspp->prev_hop.s_addr = 0; mtrace_rspp->prev_hop.s_addr = INADDR_ANY;
mtrace_rspp->in_count = htonl(MTRACE_UNKNOWN_COUNT); mtrace_rspp->in_count = htonl(MTRACE_UNKNOWN_COUNT);
mtrace_rspp->out_count = htonl(MTRACE_UNKNOWN_COUNT); mtrace_rspp->out_count = htonl(MTRACE_UNKNOWN_COUNT);
mtrace_rspp->total = 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... */ /* 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); fwd_info = mtrace_fwd_info(pim, mtracep, rspp, &out_ifp);
else else
fwd_info = mtrace_fwd_info_weak(pim, mtracep, rspp, &out_ifp); 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; 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 */ /* no pim? i.e. 7.5.3. No Previous Hop */
if (!out_ifp->info) { if (!out_ifp->info) {
if (PIM_DEBUG_MTRACE) if (PIM_DEBUG_MTRACE)

View File

@ -473,7 +473,7 @@ static void pim_msdp_sa_local_add(struct pim_instance *pim,
struct prefix_sg *sg) struct prefix_sg *sg)
{ {
struct in_addr rp; struct in_addr rp;
rp.s_addr = 0; rp.s_addr = INADDR_ANY;
pim_msdp_sa_ref(pim, NULL /* mp */, sg, rp); pim_msdp_sa_ref(pim, NULL /* mp */, sg, rp);
} }

View File

@ -158,7 +158,8 @@ route_match_ip_next_hop(void *rule, const struct prefix *prefix,
if (type == RMAP_RIP) { if (type == RMAP_RIP) {
rinfo = object; rinfo = object;
p.family = AF_INET; p.family = AF_INET;
p.prefix = (rinfo->nh.gate.ipv4.s_addr) ? rinfo->nh.gate.ipv4 p.prefix = (rinfo->nh.gate.ipv4.s_addr != INADDR_ANY)
? rinfo->nh.gate.ipv4
: rinfo->from; : rinfo->from;
p.prefixlen = IPV4_MAX_BITLEN; p.prefixlen = IPV4_MAX_BITLEN;
@ -207,7 +208,8 @@ route_match_ip_next_hop_prefix_list(void *rule, const struct prefix *prefix,
if (type == RMAP_RIP) { if (type == RMAP_RIP) {
rinfo = object; rinfo = object;
p.family = AF_INET; p.family = AF_INET;
p.prefix = (rinfo->nh.gate.ipv4.s_addr) ? rinfo->nh.gate.ipv4 p.prefix = (rinfo->nh.gate.ipv4.s_addr != INADDR_ANY)
? rinfo->nh.gate.ipv4
: rinfo->from; : rinfo->from;
p.prefixlen = IPV4_MAX_BITLEN; p.prefixlen = IPV4_MAX_BITLEN;

View File

@ -1223,7 +1223,8 @@ static void rip_response_process(struct rip_packet *packet, int size,
} }
/* RIPv1 does not have nexthop value. */ /* 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", zlog_info("RIPv1 packet with nexthop value %s",
inet_ntoa(rte->nexthop)); inet_ntoa(rte->nexthop));
rip_peer_bad_route(rip, from); 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 sub-optimal, but absolutely valid, route may be taken. If
the received Next Hop is not directly reachable, it should be the received Next Hop is not directly reachable, it should be
treated as 0.0.0.0. */ 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; uint32_t addrval;
/* Multicast address check. */ /* 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", "Next hop %s is not directly reachable. Treat it as 0.0.0.0",
inet_ntoa( inet_ntoa(
rte->nexthop)); rte->nexthop));
rte->nexthop.s_addr = 0; rte->nexthop.s_addr =
INADDR_ANY;
} }
route_unlock_node(rn); 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", "Next hop %s is not directly reachable. Treat it as 0.0.0.0",
inet_ntoa( inet_ntoa(
rte->nexthop)); 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 (/16 for class B's) except when the RIP packet does to inside
the classful network in question. */ 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 || (packet->version == RIPv2
&& (rte->prefix.s_addr != 0 && (rte->prefix.s_addr != INADDR_ANY
&& rte->mask.s_addr == 0))) { && rte->mask.s_addr == INADDR_ANY))) {
uint32_t destination; uint32_t destination;
if (subnetted == -1) { 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 /* In case of RIPv2, if prefix in RTE is not netmask applied one
ignore the entry. */ 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 & rte->mask.s_addr)
!= rte->prefix.s_addr)) { != rte->prefix.s_addr)) {
zlog_warn( zlog_warn(
@ -1363,12 +1368,13 @@ static void rip_response_process(struct rip_packet *packet, int size,
} }
/* Default route's netmask is ignored. */ /* Default route's netmask is ignored. */
if (packet->version == RIPv2 && (rte->prefix.s_addr == 0) if (packet->version == RIPv2
&& (rte->mask.s_addr != 0)) { && (rte->prefix.s_addr == INADDR_ANY)
&& (rte->mask.s_addr != INADDR_ANY)) {
if (IS_RIP_DEBUG_EVENT) if (IS_RIP_DEBUG_EVENT)
zlog_debug( zlog_debug(
"Default route with non-zero netmask. Set zero to netmask"); "Default route with non-zero netmask. Set zero to netmask");
rte->mask.s_addr = 0; rte->mask.s_addr = INADDR_ANY;
} }
/* Routing table updates. */ /* Routing table updates. */

View File

@ -0,0 +1,14 @@
@@
expression e;
@@
(
- e.s_addr == 0
+ e.s_addr == INADDR_ANY
|
- e.s_addr != 0
+ e.s_addr != INADDR_ANY
|
- e.s_addr = 0
+ e.s_addr = INADDR_ANY
)

View File

@ -75,11 +75,11 @@ void router_id_get(struct prefix *p, vrf_id_t vrf_id)
struct connected *c; struct connected *c;
struct zebra_vrf *zvrf = vrf_info_get(vrf_id); 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->family = AF_INET;
p->prefixlen = 32; 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; p->u.prefix4.s_addr = zvrf->rid_user_assigned.u.prefix4.s_addr;
else if (!list_isempty(zvrf->rid_lo_sorted_list)) { else if (!list_isempty(zvrf->rid_lo_sorted_list)) {
node = listtail(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) RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
if ((zvrf = vrf->info) != NULL) 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) if (zvrf_id(zvrf) == VRF_DEFAULT)
vty_out(vty, "router-id %s\n", vty_out(vty, "router-id %s\n",
inet_ntoa( inet_ntoa(

View File

@ -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); addattr_l(nlmsg, req_size, RTA_GATEWAY, &ipv4_ll, 4);
addattr32(nlmsg, req_size, RTA_OIF, nexthop->ifindex); 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, addattr_l(nlmsg, req_size, RTA_PREFSRC,
&nexthop->rmap_src.ipv4, bytelen); &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, addattr_l(nlmsg, req_size, RTA_PREFSRC,
&nexthop->src.ipv4, bytelen); &nexthop->src.ipv4, bytelen);
@ -1187,10 +1189,10 @@ static void _netlink_route_build_singlepath(const char *routedesc, int bytelen,
bytelen, nexthop); bytelen, nexthop);
if (cmd == RTM_NEWROUTE) { 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, addattr_l(nlmsg, req_size, RTA_PREFSRC,
&nexthop->rmap_src.ipv4, bytelen); &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, addattr_l(nlmsg, req_size, RTA_PREFSRC,
&nexthop->src.ipv4, bytelen); &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 (nexthop->type == NEXTHOP_TYPE_IFINDEX) {
if (cmd == RTM_NEWROUTE) { 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, addattr_l(nlmsg, req_size, RTA_PREFSRC,
&nexthop->rmap_src.ipv4, bytelen); &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, addattr_l(nlmsg, req_size, RTA_PREFSRC,
&nexthop->src.ipv4, bytelen); &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_len += sizeof(struct rtattr) + bytelen;
rtnh->rtnh_ifindex = nexthop->ifindex; 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; *src = &nexthop->rmap_src;
else if (nexthop->src.ipv4.s_addr) else if (nexthop->src.ipv4.s_addr != INADDR_ANY)
*src = &nexthop->src; *src = &nexthop->src;
if (IS_ZEBRA_DEBUG_KERNEL) 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, _netlink_route_rta_add_gateway_info(rtmsg->rtm_family, AF_INET,
rta, rtnh, NL_PKT_BUF_SIZE, rta, rtnh, NL_PKT_BUF_SIZE,
bytelen, nexthop); bytelen, nexthop);
if (nexthop->rmap_src.ipv4.s_addr) if (nexthop->rmap_src.ipv4.s_addr != INADDR_ANY)
*src = &nexthop->rmap_src; *src = &nexthop->rmap_src;
else if (nexthop->src.ipv4.s_addr) else if (nexthop->src.ipv4.s_addr != INADDR_ANY)
*src = &nexthop->src; *src = &nexthop->src;
if (IS_ZEBRA_DEBUG_KERNEL) if (IS_ZEBRA_DEBUG_KERNEL)
@ -1396,9 +1398,9 @@ static void _netlink_route_build_multipath(const char *routedesc, int bytelen,
/* ifindex */ /* ifindex */
if (nexthop->type == NEXTHOP_TYPE_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; *src = &nexthop->rmap_src;
else if (nexthop->src.ipv4.s_addr) else if (nexthop->src.ipv4.s_addr != INADDR_ANY)
*src = &nexthop->src; *src = &nexthop->src;
if (IS_ZEBRA_DEBUG_KERNEL) if (IS_ZEBRA_DEBUG_KERNEL)

View File

@ -218,7 +218,7 @@ static int netlink_route_info_add_nh(netlink_route_info_t *ri,
if (nexthop->type == NEXTHOP_TYPE_IPV4 if (nexthop->type == NEXTHOP_TYPE_IPV4
|| nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX) { || nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX) {
nhi.gateway = &nexthop->gate; nhi.gateway = &nexthop->gate;
if (nexthop->src.ipv4.s_addr) if (nexthop->src.ipv4.s_addr != INADDR_ANY)
src = &nexthop->src; 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->type == NEXTHOP_TYPE_IFINDEX) {
if (nexthop->src.ipv4.s_addr) if (nexthop->src.ipv4.s_addr != INADDR_ANY)
src = &nexthop->src; src = &nexthop->src;
} }

View File

@ -86,7 +86,7 @@ static inline int add_nexthop(qpb_allocator_t *allocator, Fpm__AddRoute *msg,
if (nexthop->type == NEXTHOP_TYPE_IPV4 if (nexthop->type == NEXTHOP_TYPE_IPV4
|| nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX) { || nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX) {
gateway = &nexthop->gate; gateway = &nexthop->gate;
if (nexthop->src.ipv4.s_addr) if (nexthop->src.ipv4.s_addr != INADDR_ANY)
src = &nexthop->src; 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->type == NEXTHOP_TYPE_IFINDEX) {
if (nexthop->src.ipv4.s_addr) if (nexthop->src.ipv4.s_addr != INADDR_ANY)
src = &nexthop->src; src = &nexthop->src;
} }

View File

@ -3212,7 +3212,7 @@ static int zvni_local_neigh_update(zebra_vni_t *zvni,
vtep_ip = n->r_vtep_ip; vtep_ip = n->r_vtep_ip;
/* Mark appropriately */ /* Mark appropriately */
UNSET_FLAG(n->flags, ZEBRA_NEIGH_REMOTE); 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); SET_FLAG(n->flags, ZEBRA_NEIGH_LOCAL);
n->ifindex = ifp->ifindex; 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 * 2. the XG entry is used by pimd to setup the
* vxlan-termination-mroute * vxlan-termination-mroute
*/ */
if (sg->src.s_addr) { if (sg->src.s_addr != INADDR_ANY) {
memset(&sip, 0, sizeof(sip)); memset(&sip, 0, sizeof(sip));
parent = zebra_vxlan_sg_do_ref(zvrf, sip, sg->grp); parent = zebra_vxlan_sg_do_ref(zvrf, sip, sg->grp);
if (!parent) 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 /* On SG entry deletion remove the reference to its parent XG
* entry * entry
*/ */
if (vxlan_sg->sg.src.s_addr) { if (vxlan_sg->sg.src.s_addr != INADDR_ANY) {
memset(&sip, 0, sizeof(sip)); memset(&sip, 0, sizeof(sip));
zebra_vxlan_sg_do_deref(zvrf, sip, vxlan_sg->sg.grp); 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; 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; return;
zvrf = vrf_info_lookup(VRF_DEFAULT); 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; 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; return;
zvrf = vrf_info_lookup(VRF_DEFAULT); zvrf = vrf_info_lookup(VRF_DEFAULT);