]> git.proxmox.com Git - mirror_frr.git/commitdiff
*: Replace s_addr check agains 0 with INADDR_ANY
authorDonatas Abraitis <donatas.abraitis@gmail.com>
Mon, 14 Dec 2020 19:01:31 +0000 (21:01 +0200)
committerDonatas Abraitis <donatas.abraitis@gmail.com>
Mon, 14 Dec 2020 19:03:38 +0000 (21:03 +0200)
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
24 files changed:
bgpd/bgp_evpn.c
bgpd/bgp_evpn_mh.c
bgpd/bgp_evpn_private.h
bgpd/bgp_flowspec_vty.c
bgpd/bgp_nb_config.c
bgpd/bgp_updgrp_packet.c
bgpd/bgp_vty.c
bgpd/rfapi/rfapi_private.h
eigrpd/eigrp_network.c
isisd/isis_lsp.c
ospfd/ospf_ase.c
ospfd/ospf_lsa.c
ospfd/ospf_route.c
ospfd/ospf_snmp.c
ospfd/ospf_spf.c
ospfd/ospf_vty.c
ospfd/ospfd.c
pimd/pim_cmd.c
pimd/pim_rp.c
pimd/pim_static.c
pimd/pim_vxlan.h
ripd/ripd.c
sharpd/sharp_vty.c
zebra/router-id.c

index b85a5c36369c53f35380449be85cb2d2c1d739a5..96f4b0aa780e86342bb6cd33a8754d9ccdd61dbb 100644 (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];
index 4bc53b10e81d727f8aa9ae10f5d5749ce1d8a245..b3e66d607fe4bf8ac2fa9e73872f08c7fdb2153c 100644 (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) {
index cd4920e3d087b6e52003a8266316d6b6978c0844..6a7d12493827839a29fefcb80c1aa7971a67388d 100644 (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
index 57f212b05dbd4aa15e08241b5e80fd0af1031a45..11487ed8471d4b0f03ca153d9121bdd4785e3a68 100644 (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,
index 6e7a1b650ccb0de163da3a240cfd57a29d339dbc..6ee8b25b823aad7be31eb2e14b717d13a9547365 100644 (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;
index ec80aa42260a50f695973150b2698a7cf7c23320..866bf8178a6c791613b78aa6daee1695236769ac 100644 (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);
                        }
index e840f8bceb510ca2e6137eb32e4820a3a05a99e5..1fefa10620c8a26fd5d68f3c7861cb3f8ec3bbdf 100644 (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);
 
index 68caba600a009a3c5b2c2e577d86c3613ad5984b..e24d62def4446a405aec28896e30a2811b2271ba 100644 (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)))
index bd8ec2f879251fefd064806682a0e141b93ea68a..51b499895946a504f2ae76f8f3ef319ebbeea10c 100644 (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. */
index d8ad4cd510ab2434c8713b5930a416fcd4fb30c0..47225ea2c3553f1425a36532ad137d0bfdad863e 100644 (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.",
index 3606efc76f1090916497b571448e9165b33385b8..e99653f91879d91f3f4b7808568db231097446bb 100644 (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.");
index 42fc3288cde21167a18495ab71c300ab723bd701..3680229e5d3d5a82787a0f71bb66190bc6f5b74d 100644 (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");
index bcf563a5ba3fff6ba7ddaf699f52b215aae1bf5f..590122e223a4634cd847c24ad0f974a9eee59ce9 100644 (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
index 033046da0a3b6e7f28c0f3d39fde431e3ddca690..66dd9c7ca4ac9dbbf4d650a1aa7f7c0b70efa3ae 100644 (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;
index ad9e6f547406664daf6e1848fc4dac457b83762f..4665f53edbdaf648a062676fc5827109289c9038 100644 (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",
index 91a29f7d653a7f39712eb0703eaa9b5b5a8f3331..aaa64e80c501345dbe392840ed9ea0bb1ed9289f 100644 (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);
 
index 6fe94f3a4129200f60a0055d41dcb7cb14b50251..0adf8a7b41d8df8f7b085298abd40b9f90b4beed 100644 (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;
index 6d01cc73d72a6af150e2602ff7776635232a9ae4..02a4c9c1fc01a2d763fee34b9d090112f38fb136 100644 (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
index 727daa42c1e4c02221b46207536f2a2e614cadbc..fa5d6f37bf8979a491dbcd514c90d7060ce69c8b 100644 (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(
index 91c9b5b9337ec48a35d6ce97a6d8bae41919e745..63a9a0065941a582d4d72754e5035aebd491e890 100644 (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);
index 18f1b74175977191d843da273ff733e659b59352..ce9054cd267089d203790c6b50957d486433a8f0 100644 (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)
index 0cec847f057c643fee83700a3f38b7367fa5b027..82dd401f96031f7203e63f87536a98b4b1a9172a 100644 (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;
index a1215835c03c164eaf1a20826fcfb0b4d8d278a0..940415b067bb5263619713653415ded7602e3b0a 100644 (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;
index 7af60a389bd47f234b2a2f802889bf4bb86882d8..ac21978ee826f96a5c398f68b8966a35ca23a133 100644 (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));