Merge pull request #7736 from ton31337/fix/s_addr_INADDR_ANY

*: Replace s_addr check agains 0 with INADDR_ANY
This commit is contained in:
Russ White 2020-12-15 07:12:49 -05:00 committed by GitHub
commit 930c9b7be8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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) if (pi->attr)
nh = pi->attr->nexthop; nh = pi->attr->nexthop;
else else
nh.s_addr = 0; nh.s_addr = INADDR_ANY;
if (install && !bgp_evpn_es_is_vtep_active(esi, nh)) { if (install && !bgp_evpn_es_is_vtep_active(esi, nh)) {
if (BGP_DEBUG(evpn_mh, EVPN_MH_RT)) { if (BGP_DEBUG(evpn_mh, EVPN_MH_RT)) {
char esi_buf[ESI_STR_LEN]; 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 /* EAD route prefix doesn't include the nexthop in the global
* table * table
*/ */
vtep_ip.s_addr = 0; vtep_ip.s_addr = INADDR_ANY;
build_evpn_type1_prefix(&p, eth_tag, &esi, vtep_ip); build_evpn_type1_prefix(&p, eth_tag, &esi, vtep_ip);
/* Process the route. */ /* Process the route. */
if (attr) { 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)); memcpy(global_p, vni_p, sizeof(*global_p));
global_p->prefix.ead_addr.ip.ipa_type = 0; 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 /* 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]; char local_buff[INET6_ADDRSTRLEN];
local_buff[0] = '\0'; local_buff[0] = '\0';
if (p->u.prefix_flowspec.family == AF_INET && if (p->u.prefix_flowspec.family == AF_INET
attr->nexthop.s_addr != 0) && attr->nexthop.s_addr != INADDR_ANY)
inet_ntop(AF_INET, inet_ntop(AF_INET,
&attr->nexthop.s_addr, &attr->nexthop.s_addr,
local_buff, 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); 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); bgp_router_id_static_set(bgp, router_id);
return NB_OK; 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 (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, ipv4_to_ipv4_mapped_ipv6(mod_v6nhg,
peer->nexthop.v4); 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"); vty_out(vty, " no bgp fast-external-failover\n");
/* BGP router ID. */ /* 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", vty_out(vty, " bgp router-id %pI4\n",
&bgp->router_id_static); &bgp->router_id_static);

View File

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

View File

@ -292,7 +292,7 @@ void eigrp_if_update(struct interface *ifp)
continue; continue;
/* EIGRP must be on and Router-ID must be configured. */ /* 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; continue;
/* Run each network for this interface. */ /* 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 (area->newmetric) {
if (IS_MPLS_TE(area->mta) 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; id.s_addr = area->mta->router_id.s_addr;
lsp_debug( lsp_debug(
"ISIS (%s): Adding router ID also as TE router ID tlv.", "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; struct ospf_path *op;
for (ALL_LIST_ELEMENTS_RO(ro->paths, node, 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; op->nexthop.s_addr = nexthop.s_addr;
} }
@ -191,7 +191,7 @@ ospf_ase_calculate_asbr_route (struct ospf *ospf,
return NULL; 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)) if (IS_DEBUG_OSPF (lsa, LSA))
zlog_debug ("ospf_ase_calculate(): Forwarding address is not 0.0.0.0."); 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->area->external_routing == OSPF_AREA_NSSA)
if (oi->address if (oi->address
&& oi->address->family == AF_INET) { && oi->address->family == AF_INET) {
if (best_default.s_addr == 0) if (best_default.s_addr == INADDR_ANY)
best_default = best_default =
oi->address->u.prefix4; oi->address->u.prefix4;
if (oi->area == area) if (oi->area == area)
return oi->address->u.prefix4; return oi->address->u.prefix4;
} }
} }
if (best_default.s_addr != 0) if (best_default.s_addr != INADDR_ANY)
return best_default; return best_default;
if (best_default.s_addr != 0) if (best_default.s_addr != INADDR_ANY)
return best_default; return best_default;
return fwd; 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 */ /* kevinm: not updating lsa anymore, just new */
extlsa = (struct as_external_lsa *)(new->data); 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( extlsa->e[0].fwd_addr = ospf_get_nssa_ip(
area); /* this NSSA area in ifp */ 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) if (IS_DEBUG_OSPF_NSSA)
zlog_debug( zlog_debug(
"LSA[Type-7]: Could not build FWD-ADDR"); "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); or->cost);
for (ALL_LIST_ELEMENTS_RO(or->paths, pnode, for (ALL_LIST_ELEMENTS_RO(or->paths, pnode,
path)) path))
if (path->nexthop.s_addr != 0) if (path->nexthop.s_addr != INADDR_ANY)
vty_out(vty, " -> %pI4\n", vty_out(vty, " -> %pI4\n",
&path->nexthop); &path->nexthop);
else else

View File

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

View File

@ -1238,7 +1238,7 @@ ospf_rtrs_print (struct route_table *rtrs)
for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path)) 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) if (IS_DEBUG_OSPF_EVENT)
zlog_debug (" directly attached to %s\r", zlog_debug (" directly attached to %s\r",

View File

@ -10496,7 +10496,8 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf,
if (if_lookup_by_index(path->ifindex, if (if_lookup_by_index(path->ifindex,
ospf->vrf_id)) { ospf->vrf_id)) {
if (path->nexthop.s_addr == 0) { if (path->nexthop.s_addr
== INADDR_ANY) {
if (json) { if (json) {
json_object_string_add( json_object_string_add(
json_nexthop, json_nexthop,
@ -10641,7 +10642,8 @@ static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf,
} }
if (if_lookup_by_index(path->ifindex, if (if_lookup_by_index(path->ifindex,
ospf->vrf_id)) { ospf->vrf_id)) {
if (path->nexthop.s_addr == 0) { if (path->nexthop.s_addr
== INADDR_ANY) {
if (json) { if (json) {
json_object_string_add( json_object_string_add(
json_nexthop, json_nexthop,
@ -10769,7 +10771,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 (if_lookup_by_index(path->ifindex, ospf->vrf_id)) {
if (path->nexthop.s_addr == 0) { if (path->nexthop.s_addr == INADDR_ANY) {
if (json) { if (json) {
json_object_string_add( json_object_string_add(
json_nexthop, "ip", json_nexthop, "ip",
@ -12138,7 +12140,7 @@ static int ospf_config_write_one(struct vty *vty, struct ospf *ospf)
} }
/* Router ID print. */ /* 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", vty_out(vty, " ospf router-id %pI4\n",
&ospf->router_id_static); &ospf->router_id_static);

View File

@ -115,9 +115,9 @@ void ospf_router_id_update(struct ospf *ospf)
disruptive. disruptive.
3. Last choice: just go with whatever the zebra daemon recommends. 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; 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; router_id = ospf->router_id;
else else
router_id = ospf->router_id_zebra; router_id = ospf->router_id_zebra;

View File

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

View File

@ -1319,7 +1319,7 @@ void pim_resolve_rp_nh(struct pim_instance *pim, struct pim_neighbor *nbr)
continue; continue;
for (nh_node = pnc.nexthop; nh_node; nh_node = nh_node->next) { 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; continue;
struct interface *ifp1 = if_lookup_by_index( 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 = struct interface *oifp =
pim_if_find_by_vif_index(pim, pim_if_find_by_vif_index(pim,
i); i);
if (sroute->source.s_addr == 0) if (sroute->source.s_addr == INADDR_ANY)
vty_out(vty, vty_out(vty,
" ip mroute %s %s\n", " ip mroute %s %s\n",
oifp->name, gbuf); 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) 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) 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; rte->metric = RIP_METRIC_INFINITY;
/* Set nexthop pointer. */ /* Set nexthop pointer. */
if (rte->nexthop.s_addr == 0) if (rte->nexthop.s_addr == INADDR_ANY)
nexthop = &from->sin_addr; nexthop = &from->sin_addr;
else else
nexthop = &rte->nexthop; 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 /* Only routes directly connected to an interface
* (nexthop == 0) * (nexthop == 0)
* may have a valid NULL distance */ * 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 = old_dist
? old_dist ? old_dist
: ZEBRA_RIP_DISTANCE_DEFAULT; : ZEBRA_RIP_DISTANCE_DEFAULT;
@ -2156,7 +2156,7 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
memcpy(&classfull, &rp->p, memcpy(&classfull, &rp->p,
sizeof(struct prefix_ipv4)); sizeof(struct prefix_ipv4));
apply_classful_mask_ipv4(&classfull); apply_classful_mask_ipv4(&classfull);
if (rp->p.u.prefix4.s_addr != 0 if (rp->p.u.prefix4.s_addr != INADDR_ANY
&& classfull.prefixlen && classfull.prefixlen
!= rp->p.prefixlen) != rp->p.prefixlen)
continue; 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, 0, sizeof(sg.r.nhop));
memset(&sg.r.backup_nhop_group, 0, sizeof(sg.r.nhop_group)); 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.family = AF_INET;
prefix.prefixlen = 32; prefix.prefixlen = 32;
prefix.u.prefix4 = start4; prefix.u.prefix4 = start4;
@ -362,7 +362,7 @@ DEFPY (remove_routes,
memset(&prefix, 0, sizeof(prefix)); memset(&prefix, 0, sizeof(prefix));
if (start4.s_addr != 0) { if (start4.s_addr != INADDR_ANY) {
prefix.family = AF_INET; prefix.family = AF_INET;
prefix.prefixlen = 32; prefix.prefixlen = 32;
prefix.u.prefix4 = start4; prefix.u.prefix4 = start4;
@ -672,7 +672,7 @@ DEFPY (neigh_discover,
memset(&prefix, 0, sizeof(prefix)); memset(&prefix, 0, sizeof(prefix));
if (dst4.s_addr != 0) { if (dst4.s_addr != INADDR_ANY) {
prefix.family = AF_INET; prefix.family = AF_INET;
prefix.prefixlen = 32; prefix.prefixlen = 32;
prefix.u.prefix4 = dst4; 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, inet_ntop(AF_INET6, &zvrf->rid6_user_assigned.u.prefix6,
addr_name, sizeof(addr_name)); addr_name, sizeof(addr_name));
} else { } 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; return CMD_SUCCESS;
inet_ntop(AF_INET, &zvrf->rid_user_assigned.u.prefix4, inet_ntop(AF_INET, &zvrf->rid_user_assigned.u.prefix4,
addr_name, sizeof(addr_name)); addr_name, sizeof(addr_name));