*: Replace s_addr check agains 0 with INADDR_ANY

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
This commit is contained in:
Donatas Abraitis 2020-12-14 21:01:31 +02:00
parent c2dba6e5b8
commit 3a6290bdd1
24 changed files with 56 additions and 50 deletions

View File

@ -2898,7 +2898,7 @@ bgp_evpn_skip_vrf_import_of_local_es(const struct prefix_evpn *evp,
if (pi->attr)
nh = pi->attr->nexthop;
else
nh.s_addr = 0;
nh.s_addr = INADDR_ANY;
if (install && !bgp_evpn_es_is_vtep_active(esi, nh)) {
if (BGP_DEBUG(evpn_mh, EVPN_MH_RT)) {
char esi_buf[ESI_STR_LEN];

View File

@ -1078,7 +1078,7 @@ int bgp_evpn_type1_route_process(struct peer *peer, afi_t afi, safi_t safi,
/* EAD route prefix doesn't include the nexthop in the global
* table
*/
vtep_ip.s_addr = 0;
vtep_ip.s_addr = INADDR_ANY;
build_evpn_type1_prefix(&p, eth_tag, &esi, vtep_ip);
/* Process the route. */
if (attr) {

View File

@ -515,7 +515,7 @@ static inline void evpn_type1_prefix_global_copy(struct prefix_evpn *global_p,
{
memcpy(global_p, vni_p, sizeof(*global_p));
global_p->prefix.ead_addr.ip.ipa_type = 0;
global_p->prefix.ead_addr.ip.ipaddr_v4.s_addr = 0;
global_p->prefix.ead_addr.ip.ipaddr_v4.s_addr = INADDR_ANY;
}
/* EAD prefix in the global table doesn't include the VTEP-IP so

View File

@ -335,8 +335,8 @@ void route_vty_out_flowspec(struct vty *vty, const struct prefix *p,
char local_buff[INET6_ADDRSTRLEN];
local_buff[0] = '\0';
if (p->u.prefix_flowspec.family == AF_INET &&
attr->nexthop.s_addr != 0)
if (p->u.prefix_flowspec.family == AF_INET
&& attr->nexthop.s_addr != INADDR_ANY)
inet_ntop(AF_INET,
&attr->nexthop.s_addr,
local_buff,

View File

@ -279,7 +279,7 @@ int bgp_global_router_id_destroy(struct nb_cb_destroy_args *args)
bgp = nb_running_get_entry(args->dnode, NULL, true);
router_id.s_addr = 0;
router_id.s_addr = INADDR_ANY;
bgp_router_id_static_set(bgp, router_id);
return NB_OK;

View File

@ -575,7 +575,7 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
}
if (IN6_IS_ADDR_UNSPECIFIED(mod_v6nhg)) {
if (peer->nexthop.v4.s_addr) {
if (peer->nexthop.v4.s_addr != INADDR_ANY) {
ipv4_to_ipv4_mapped_ipv6(mod_v6nhg,
peer->nexthop.v4);
}

View File

@ -16982,7 +16982,7 @@ int bgp_config_write(struct vty *vty)
vty_out(vty, " no bgp fast-external-failover\n");
/* BGP router ID. */
if (bgp->router_id_static.s_addr != 0)
if (bgp->router_id_static.s_addr != INADDR_ANY)
vty_out(vty, " bgp router-id %pI4\n",
&bgp->router_id_static);

View File

@ -255,7 +255,7 @@ struct rfapi {
#define RFAPI_0_PREFIX(prefix) \
((((prefix)->family == AF_INET) \
? (prefix)->u.prefix4.s_addr == 0 \
? (prefix)->u.prefix4.s_addr == INADDR_ANY \
: (((prefix)->family == AF_INET6) \
? (IN6_IS_ADDR_UNSPECIFIED(&(prefix)->u.prefix6)) \
: 0)))

View File

@ -292,7 +292,7 @@ void eigrp_if_update(struct interface *ifp)
continue;
/* EIGRP must be on and Router-ID must be configured. */
if (eigrp->router_id.s_addr == 0)
if (eigrp->router_id.s_addr == INADDR_ANY)
continue;
/* Run each network for this interface. */

View File

@ -973,7 +973,7 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)
*/
if (area->newmetric) {
if (IS_MPLS_TE(area->mta)
&& area->mta->router_id.s_addr != 0)
&& area->mta->router_id.s_addr != INADDR_ANY)
id.s_addr = area->mta->router_id.s_addr;
lsp_debug(
"ISIS (%s): Adding router ID also as TE router ID tlv.",

View File

@ -136,7 +136,7 @@ static void ospf_ase_complete_direct_routes(struct ospf_route *ro,
struct ospf_path *op;
for (ALL_LIST_ELEMENTS_RO(ro->paths, node, op))
if (op->nexthop.s_addr == 0)
if (op->nexthop.s_addr == INADDR_ANY)
op->nexthop.s_addr = nexthop.s_addr;
}
@ -191,7 +191,7 @@ ospf_ase_calculate_asbr_route (struct ospf *ospf,
return NULL;
}
if (al->e[0].fwd_addr.s_addr != 0)
if (al->e[0].fwd_addr.s_addr != INADDR_ANY)
{
if (IS_DEBUG_OSPF (lsa, LSA))
zlog_debug ("ospf_ase_calculate(): Forwarding address is not 0.0.0.0.");

View File

@ -1480,17 +1480,17 @@ struct in_addr ospf_get_nssa_ip(struct ospf_area *area)
if (oi->area->external_routing == OSPF_AREA_NSSA)
if (oi->address
&& oi->address->family == AF_INET) {
if (best_default.s_addr == 0)
if (best_default.s_addr == INADDR_ANY)
best_default =
oi->address->u.prefix4;
if (oi->area == area)
return oi->address->u.prefix4;
}
}
if (best_default.s_addr != 0)
if (best_default.s_addr != INADDR_ANY)
return best_default;
if (best_default.s_addr != 0)
if (best_default.s_addr != INADDR_ANY)
return best_default;
return fwd;
@ -1708,11 +1708,11 @@ static void ospf_install_flood_nssa(struct ospf *ospf, struct ospf_lsa *lsa,
/* kevinm: not updating lsa anymore, just new */
extlsa = (struct as_external_lsa *)(new->data);
if (extlsa->e[0].fwd_addr.s_addr == 0)
if (extlsa->e[0].fwd_addr.s_addr == INADDR_ANY)
extlsa->e[0].fwd_addr = ospf_get_nssa_ip(
area); /* this NSSA area in ifp */
if (extlsa->e[0].fwd_addr.s_addr == 0) {
if (extlsa->e[0].fwd_addr.s_addr == INADDR_ANY) {
if (IS_DEBUG_OSPF_NSSA)
zlog_debug(
"LSA[Type-7]: Could not build FWD-ADDR");

View File

@ -681,7 +681,7 @@ void ospf_route_table_print(struct vty *vty, struct route_table *rt)
or->cost);
for (ALL_LIST_ELEMENTS_RO(or->paths, pnode,
path))
if (path->nexthop.s_addr != 0)
if (path->nexthop.s_addr != INADDR_ANY)
vty_out(vty, " -> %pI4\n",
&path->nexthop);
else

View File

@ -1405,7 +1405,8 @@ static int ospf_snmp_if_update(struct interface *ifp)
} else {
/* Unnumbered interfaces --> Sort them based on
* interface indexes */
if (osif->addr.s_addr != 0 || osif->ifindex > ifindex)
if (osif->addr.s_addr != INADDR_ANY
|| osif->ifindex > ifindex)
break;
}
pn = node;
@ -2003,11 +2004,12 @@ static struct ospf_neighbor *ospf_snmp_nbr_lookup(struct ospf *ospf,
for (ALL_LIST_ELEMENTS(ospf->oiflist, node, nnode, oi)) {
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn))
if ((nbr = rn->info) != NULL && nbr != oi->nbr_self
if ((nbr = rn->info) != NULL
&& nbr != oi->nbr_self
/* If EXACT match is needed, provide ALL entry found
&& nbr->state != NSM_Down
*/
&& nbr->src.s_addr != 0) {
&& nbr->src.s_addr != INADDR_ANY) {
if (IPV4_ADDR_SAME(&nbr->src, nbr_addr)) {
route_unlock_node(rn);
return nbr;
@ -2033,7 +2035,8 @@ static struct ospf_neighbor *ospf_snmp_nbr_lookup_next(struct in_addr *nbr_addr,
for (ALL_LIST_ELEMENTS_RO(ospf->oiflist, nn, oi)) {
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn))
if ((nbr = rn->info) != NULL && nbr != oi->nbr_self
&& nbr->state != NSM_Down && nbr->src.s_addr != 0) {
&& nbr->state != NSM_Down
&& nbr->src.s_addr != INADDR_ANY) {
if (first) {
if (!min)
min = nbr;

View File

@ -1238,7 +1238,7 @@ ospf_rtrs_print (struct route_table *rtrs)
for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
{
if (path->nexthop.s_addr == 0)
if (path->nexthop.s_addr == INADDR_ANY)
{
if (IS_DEBUG_OSPF_EVENT)
zlog_debug (" directly attached to %s\r",

View File

@ -10450,7 +10450,8 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf,
if (if_lookup_by_index(path->ifindex,
ospf->vrf_id)) {
if (path->nexthop.s_addr == 0) {
if (path->nexthop.s_addr
== INADDR_ANY) {
if (json) {
json_object_string_add(
json_nexthop,
@ -10595,7 +10596,8 @@ static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf,
}
if (if_lookup_by_index(path->ifindex,
ospf->vrf_id)) {
if (path->nexthop.s_addr == 0) {
if (path->nexthop.s_addr
== INADDR_ANY) {
if (json) {
json_object_string_add(
json_nexthop,
@ -10723,7 +10725,7 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf,
}
if (if_lookup_by_index(path->ifindex, ospf->vrf_id)) {
if (path->nexthop.s_addr == 0) {
if (path->nexthop.s_addr == INADDR_ANY) {
if (json) {
json_object_string_add(
json_nexthop, "ip",
@ -12092,7 +12094,7 @@ static int ospf_config_write_one(struct vty *vty, struct ospf *ospf)
}
/* Router ID print. */
if (ospf->router_id_static.s_addr != 0)
if (ospf->router_id_static.s_addr != INADDR_ANY)
vty_out(vty, " ospf router-id %pI4\n",
&ospf->router_id_static);

View File

@ -115,9 +115,9 @@ void ospf_router_id_update(struct ospf *ospf)
disruptive.
3. Last choice: just go with whatever the zebra daemon recommends.
*/
if (ospf->router_id_static.s_addr != 0)
if (ospf->router_id_static.s_addr != INADDR_ANY)
router_id = ospf->router_id_static;
else if (ospf->router_id.s_addr != 0)
else if (ospf->router_id.s_addr != INADDR_ANY)
router_id = ospf->router_id;
else
router_id = ospf->router_id_zebra;

View File

@ -4560,8 +4560,8 @@ DEFPY (show_ip_pim_join,
return CMD_WARNING;
}
if (s_or_g.s_addr != 0) {
if (g.s_addr != 0) {
if (s_or_g.s_addr != INADDR_ANY) {
if (g.s_addr != INADDR_ANY) {
sg.src = s_or_g;
sg.grp = g;
} else
@ -5180,8 +5180,8 @@ DEFPY (show_ip_pim_upstream,
return CMD_WARNING;
}
if (s_or_g.s_addr != 0) {
if (g.s_addr != 0) {
if (s_or_g.s_addr != INADDR_ANY) {
if (g.s_addr != INADDR_ANY) {
sg.src = s_or_g;
sg.grp = g;
} else
@ -5872,11 +5872,11 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty,
if (!c_oil->installed)
continue;
if (sg->grp.s_addr != 0 &&
sg->grp.s_addr != c_oil->oil.mfcc_mcastgrp.s_addr)
if (sg->grp.s_addr != INADDR_ANY
&& sg->grp.s_addr != c_oil->oil.mfcc_mcastgrp.s_addr)
continue;
if (sg->src.s_addr != 0 &&
sg->src.s_addr != c_oil->oil.mfcc_origin.s_addr)
if (sg->src.s_addr != INADDR_ANY
&& sg->src.s_addr != c_oil->oil.mfcc_origin.s_addr)
continue;
pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, grp_str,
@ -6232,8 +6232,8 @@ DEFPY (show_ip_mroute,
return CMD_WARNING;
}
if (s_or_g.s_addr != 0) {
if (g.s_addr != 0) {
if (s_or_g.s_addr != INADDR_ANY) {
if (g.s_addr != INADDR_ANY) {
sg.src = s_or_g;
sg.grp = g;
} else

View File

@ -1319,7 +1319,7 @@ void pim_resolve_rp_nh(struct pim_instance *pim, struct pim_neighbor *nbr)
continue;
for (nh_node = pnc.nexthop; nh_node; nh_node = nh_node->next) {
if (nh_node->gate.ipv4.s_addr != 0)
if (nh_node->gate.ipv4.s_addr != INADDR_ANY)
continue;
struct interface *ifp1 = if_lookup_by_index(

View File

@ -345,7 +345,7 @@ int pim_static_write_mroute(struct pim_instance *pim, struct vty *vty,
struct interface *oifp =
pim_if_find_by_vif_index(pim,
i);
if (sroute->source.s_addr == 0)
if (sroute->source.s_addr == INADDR_ANY)
vty_out(vty,
" ip mroute %s %s\n",
oifp->name, gbuf);

View File

@ -109,7 +109,7 @@ struct pim_vxlan {
*/
static inline bool pim_vxlan_is_orig_mroute(struct pim_vxlan_sg *vxlan_sg)
{
return (vxlan_sg->sg.src.s_addr != 0);
return (vxlan_sg->sg.src.s_addr != INADDR_ANY);
}
static inline bool pim_vxlan_is_local_sip(struct pim_upstream *up)

View File

@ -495,7 +495,7 @@ static void rip_rte_process(struct rte *rte, struct sockaddr_in *from,
rte->metric = RIP_METRIC_INFINITY;
/* Set nexthop pointer. */
if (rte->nexthop.s_addr == 0)
if (rte->nexthop.s_addr == INADDR_ANY)
nexthop = &from->sin_addr;
else
nexthop = &rte->nexthop;
@ -592,7 +592,7 @@ static void rip_rte_process(struct rte *rte, struct sockaddr_in *from,
/* Only routes directly connected to an interface
* (nexthop == 0)
* may have a valid NULL distance */
if (rinfo->nh.gate.ipv4.s_addr != 0)
if (rinfo->nh.gate.ipv4.s_addr != INADDR_ANY)
old_dist = old_dist
? old_dist
: ZEBRA_RIP_DISTANCE_DEFAULT;
@ -2156,7 +2156,7 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
memcpy(&classfull, &rp->p,
sizeof(struct prefix_ipv4));
apply_classful_mask_ipv4(&classfull);
if (rp->p.u.prefix4.s_addr != 0
if (rp->p.u.prefix4.s_addr != INADDR_ANY
&& classfull.prefixlen
!= rp->p.prefixlen)
continue;

View File

@ -207,7 +207,7 @@ DEFPY (install_routes,
memset(&sg.r.backup_nhop, 0, sizeof(sg.r.nhop));
memset(&sg.r.backup_nhop_group, 0, sizeof(sg.r.nhop_group));
if (start4.s_addr != 0) {
if (start4.s_addr != INADDR_ANY) {
prefix.family = AF_INET;
prefix.prefixlen = 32;
prefix.u.prefix4 = start4;
@ -362,7 +362,7 @@ DEFPY (remove_routes,
memset(&prefix, 0, sizeof(prefix));
if (start4.s_addr != 0) {
if (start4.s_addr != INADDR_ANY) {
prefix.family = AF_INET;
prefix.prefixlen = 32;
prefix.u.prefix4 = start4;
@ -672,7 +672,7 @@ DEFPY (neigh_discover,
memset(&prefix, 0, sizeof(prefix));
if (dst4.s_addr != 0) {
if (dst4.s_addr != INADDR_ANY) {
prefix.family = AF_INET;
prefix.prefixlen = 32;
prefix.u.prefix4 = dst4;

View File

@ -522,7 +522,8 @@ DEFUN (show_ip_router_id,
inet_ntop(AF_INET6, &zvrf->rid6_user_assigned.u.prefix6,
addr_name, sizeof(addr_name));
} else {
if (zvrf->rid_user_assigned.u.prefix4.s_addr == 0)
if (zvrf->rid_user_assigned.u.prefix4.s_addr
== INADDR_ANY)
return CMD_SUCCESS;
inet_ntop(AF_INET, &zvrf->rid_user_assigned.u.prefix4,
addr_name, sizeof(addr_name));