From 3a6290bdd1003f53ad73aaaa2f6bc4b08e262352 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Mon, 14 Dec 2020 21:01:31 +0200 Subject: [PATCH] *: Replace s_addr check agains 0 with INADDR_ANY Signed-off-by: Donatas Abraitis --- bgpd/bgp_evpn.c | 2 +- bgpd/bgp_evpn_mh.c | 2 +- bgpd/bgp_evpn_private.h | 2 +- bgpd/bgp_flowspec_vty.c | 4 ++-- bgpd/bgp_nb_config.c | 2 +- bgpd/bgp_updgrp_packet.c | 2 +- bgpd/bgp_vty.c | 2 +- bgpd/rfapi/rfapi_private.h | 2 +- eigrpd/eigrp_network.c | 2 +- isisd/isis_lsp.c | 2 +- ospfd/ospf_ase.c | 4 ++-- ospfd/ospf_lsa.c | 10 +++++----- ospfd/ospf_route.c | 2 +- ospfd/ospf_snmp.c | 11 +++++++---- ospfd/ospf_spf.c | 2 +- ospfd/ospf_vty.c | 10 ++++++---- ospfd/ospfd.c | 4 ++-- pimd/pim_cmd.c | 20 ++++++++++---------- pimd/pim_rp.c | 2 +- pimd/pim_static.c | 2 +- pimd/pim_vxlan.h | 2 +- ripd/ripd.c | 6 +++--- sharpd/sharp_vty.c | 6 +++--- zebra/router-id.c | 3 ++- 24 files changed, 56 insertions(+), 50 deletions(-) diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index b85a5c3636..96f4b0aa78 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -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]; diff --git a/bgpd/bgp_evpn_mh.c b/bgpd/bgp_evpn_mh.c index 4bc53b10e8..b3e66d607f 100644 --- a/bgpd/bgp_evpn_mh.c +++ b/bgpd/bgp_evpn_mh.c @@ -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) { diff --git a/bgpd/bgp_evpn_private.h b/bgpd/bgp_evpn_private.h index cd4920e3d0..6a7d124938 100644 --- a/bgpd/bgp_evpn_private.h +++ b/bgpd/bgp_evpn_private.h @@ -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 diff --git a/bgpd/bgp_flowspec_vty.c b/bgpd/bgp_flowspec_vty.c index 57f212b05d..11487ed847 100644 --- a/bgpd/bgp_flowspec_vty.c +++ b/bgpd/bgp_flowspec_vty.c @@ -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, diff --git a/bgpd/bgp_nb_config.c b/bgpd/bgp_nb_config.c index 6e7a1b650c..6ee8b25b82 100644 --- a/bgpd/bgp_nb_config.c +++ b/bgpd/bgp_nb_config.c @@ -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; diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c index ec80aa4226..866bf8178a 100644 --- a/bgpd/bgp_updgrp_packet.c +++ b/bgpd/bgp_updgrp_packet.c @@ -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); } diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index e840f8bceb..1fefa10620 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -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); diff --git a/bgpd/rfapi/rfapi_private.h b/bgpd/rfapi/rfapi_private.h index 68caba600a..e24d62def4 100644 --- a/bgpd/rfapi/rfapi_private.h +++ b/bgpd/rfapi/rfapi_private.h @@ -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))) diff --git a/eigrpd/eigrp_network.c b/eigrpd/eigrp_network.c index bd8ec2f879..51b4998959 100644 --- a/eigrpd/eigrp_network.c +++ b/eigrpd/eigrp_network.c @@ -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. */ diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index d8ad4cd510..47225ea2c3 100644 --- a/isisd/isis_lsp.c +++ b/isisd/isis_lsp.c @@ -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.", diff --git a/ospfd/ospf_ase.c b/ospfd/ospf_ase.c index 3606efc76f..e99653f918 100644 --- a/ospfd/ospf_ase.c +++ b/ospfd/ospf_ase.c @@ -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."); diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index 42fc3288cd..3680229e5d 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -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"); diff --git a/ospfd/ospf_route.c b/ospfd/ospf_route.c index bcf563a5ba..590122e223 100644 --- a/ospfd/ospf_route.c +++ b/ospfd/ospf_route.c @@ -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 diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index 033046da0a..66dd9c7ca4 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -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; diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c index ad9e6f5474..4665f53edb 100644 --- a/ospfd/ospf_spf.c +++ b/ospfd/ospf_spf.c @@ -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", diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 91a29f7d65..aaa64e80c5 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -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); diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index 6fe94f3a41..0adf8a7b41 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -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; diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 6d01cc73d7..02a4c9c1fc 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -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("", 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 diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c index 727daa42c1..fa5d6f37bf 100644 --- a/pimd/pim_rp.c +++ b/pimd/pim_rp.c @@ -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( diff --git a/pimd/pim_static.c b/pimd/pim_static.c index 91c9b5b933..63a9a00659 100644 --- a/pimd/pim_static.c +++ b/pimd/pim_static.c @@ -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); diff --git a/pimd/pim_vxlan.h b/pimd/pim_vxlan.h index 18f1b74175..ce9054cd26 100644 --- a/pimd/pim_vxlan.h +++ b/pimd/pim_vxlan.h @@ -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) diff --git a/ripd/ripd.c b/ripd/ripd.c index 0cec847f05..82dd401f96 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -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; diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c index a1215835c0..940415b067 100644 --- a/sharpd/sharp_vty.c +++ b/sharpd/sharp_vty.c @@ -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; diff --git a/zebra/router-id.c b/zebra/router-id.c index 7af60a389b..ac21978ee8 100644 --- a/zebra/router-id.c +++ b/zebra/router-id.c @@ -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)); -- 2.39.5