]> git.proxmox.com Git - mirror_frr.git/commitdiff
*: Replace s_addr 0 => INADDR_ANY
authorDonatas Abraitis <donatas.abraitis@gmail.com>
Thu, 6 Feb 2020 06:49:02 +0000 (08:49 +0200)
committerDonatas Abraitis <donatas.abraitis@gmail.com>
Thu, 6 Feb 2020 07:00:12 +0000 (09:00 +0200)
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
44 files changed:
bgpd/bgp_attr.c
bgpd/bgp_evpn_vty.c
bgpd/bgp_flowspec_util.c
bgpd/bgp_fsm.c
bgpd/bgp_mpath.c
bgpd/bgp_packet.c
bgpd/bgp_pbr.c
bgpd/bgp_route.c
bgpd/bgp_routemap.c
bgpd/bgp_snmp.c
bgpd/bgp_updgrp_packet.c
bgpd/bgp_zebra.c
bgpd/bgpd.c
eigrpd/eigrp_network.c
eigrpd/eigrp_northbound.c
eigrpd/eigrpd.c
ldpd/ldp_vty_conf.c
lib/filter.c
lib/prefix.c
lib/routemap_northbound.c
nhrpd/nhrp_interface.c
ospfclient/ospf_apiclient.c
ospfd/ospf_abr.c
ospfd/ospf_ase.c
ospfd/ospf_interface.c
ospfd/ospf_ism.c
ospfd/ospf_lsa.c
ospfd/ospf_packet.c
ospfd/ospf_route.c
ospfd/ospf_vty.c
ospfd/ospf_zebra.c
ospfd/ospfd.c
pimd/mtracebis.c
pimd/pim_cmd.c
pimd/pim_ifchannel.c
pimd/pim_igmp_mtrace.c
pimd/pim_msdp.c
ripd/rip_routemap.c
ripd/ripd.c
zebra/router-id.c
zebra/rt_netlink.c
zebra/zebra_fpm_netlink.c
zebra/zebra_fpm_protobuf.c
zebra/zebra_vxlan.c

index 47da8fcb88a9add999158a30b8420846289abfac..c0d88fc521a7cb3ffd46dff333efe17d1366a167 100644 (file)
@@ -1932,7 +1932,7 @@ int bgp_mp_reach_parse(struct bgp_attr_parser_args *args,
        case BGP_ATTR_NHLEN_IPV4:
                stream_get(&attr->mp_nexthop_global_in, s, IPV4_MAX_BYTELEN);
                /* Probably needed for RFC 2283 */
-               if (attr->nexthop.s_addr == 0)
+               if (attr->nexthop.s_addr == INADDR_ANY)
                        memcpy(&attr->nexthop.s_addr,
                               &attr->mp_nexthop_global_in, IPV4_MAX_BYTELEN);
                break;
index 44a884830a7a07d2627d493463168636cabcbf01..c5f7927c4d5455c4b8cfa2a235dfc45d35d880de 100644 (file)
@@ -771,7 +771,7 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int type,
                for (; pi; pi = pi->next) {
                        json_object *json_path = NULL;
 
-                       if (vtep_ip.s_addr
+                       if (vtep_ip.s_addr != INADDR_ANY
                            && !IPV4_ADDR_SAME(&(vtep_ip),
                                               &(pi->attr->nexthop)))
                                continue;
index b9a0d81cc5a149207136bf8fbcbbaa031ec89400..002aae561a8bc72674494e8337618c4741e8baed 100644 (file)
@@ -455,7 +455,7 @@ int bgp_flowspec_match_rules_fill(uint8_t *nlri_content, int len,
                                 * ignore that rule
                                 */
                                if (prefix->family == AF_INET
-                                   && prefix->u.prefix4.s_addr == 0)
+                                   && prefix->u.prefix4.s_addr == INADDR_ANY)
                                        bpem->match_bitmask_iprule |= bitmask;
                                else
                                        bpem->match_bitmask |= bitmask;
index 3c5903c1945935c683f4e0efd6b08256dc9d2dae..ac8fe5e914774cafb40c497c323e14ae8fa7d1af 100644 (file)
@@ -1527,7 +1527,7 @@ int bgp_start(struct peer *peer)
        }
 
        /* Clear remote router-id. */
-       peer->remote_id.s_addr = 0;
+       peer->remote_id.s_addr = INADDR_ANY;
 
        /* Clear peer capability flag. */
        peer->cap = 0;
index cc7bd6e7c70938c6bcafa13d86bbb2ffbe92193c..6bc8134f3649d9d6bfa87f2fc5b5b056ec67171f 100644 (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 */
-               attr.nexthop.s_addr = 0;
+               attr.nexthop.s_addr = INADDR_ANY;
                memset(&attr.mp_nexthop_global, 0, sizeof(struct in6_addr));
 
                /* TODO: should we set ATOMIC_AGGREGATE and AGGREGATOR? */
index 20fbc89396722deb74464936dd5ce442a9745528..afb3a09b6b01eb85c6247cbad0338051d76d215d 100644 (file)
@@ -1186,7 +1186,8 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size)
        }
 
        /* 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)) {
                if (bgp_debug_neighbor_events(peer))
                        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_MPLS_VPN]
            || 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)
                        flog_err(
                                EC_BGP_SND_FAIL,
index 9ced99616b435059cc1290e390afb24f83ccbc20..eea20d721039cb01c46ce7aa77715a38dea2c667 100644 (file)
@@ -754,13 +754,15 @@ int bgp_pbr_build_and_validate_entry(struct prefix *p,
                                 * draft-ietf-idr-flowspec-redirect
                                 */
                                if (api_action_redirect_ip) {
-                                       if (api_action_redirect_ip->u
-                                           .zr.redirect_ip_v4.s_addr)
+                                       if (api_action_redirect_ip->u.zr
+                                                   .redirect_ip_v4.s_addr
+                                           != INADDR_ANY)
                                                continue;
-                                       if (!path->attr->nexthop.s_addr)
+                                       if (path->attr->nexthop.s_addr
+                                           == INADDR_ANY)
                                                continue;
-                                       api_action_redirect_ip->u
-                                               .zr.redirect_ip_v4.s_addr =
+                                       api_action_redirect_ip->u.zr
+                                               .redirect_ip_v4.s_addr =
                                                path->attr->nexthop.s_addr;
                                        api_action_redirect_ip->u.zr.duplicate
                                                = ecom_eval->val[7];
index c14450414a754e84bfce18bb5c397637e5703d49..5e41f82d4a864823300bda93f4cb833a75217910 100644 (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)
 {
        if (family == AF_INET) {
-               attr->nexthop.s_addr = 0;
-               attr->mp_nexthop_global_in.s_addr = 0;
+               attr->nexthop.s_addr = INADDR_ANY;
+               attr->mp_nexthop_global_in.s_addr = INADDR_ANY;
        }
        if (family == AF_INET6)
                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 (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))
-                   || bgp_nexthop_self(bgp, afi, type, stype,
-                       attr, rn))
+                   || bgp_nexthop_self(bgp, afi, type, stype, attr, rn))
                        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) {
                case BGP_ATTR_NHLEN_IPV4:
                case BGP_ATTR_NHLEN_VPNV4:
-                       ret = (attr->mp_nexthop_global_in.s_addr == 0
-                              || IPV4_CLASS_DE(ntohl(
-                                         attr->mp_nexthop_global_in.s_addr))
-                              || bgp_nexthop_self(bgp, afi, type, stype,
-                                                  attr, rn));
+                       ret = (attr->mp_nexthop_global_in.s_addr == INADDR_ANY
+                              || IPV4_CLASS_DE(
+                                      ntohl(attr->mp_nexthop_global_in.s_addr))
+                              || bgp_nexthop_self(bgp, afi, type, stype, attr,
+                                                  rn));
                        break;
 
                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->valid = 0;
                        bgp_static->igpmetric = 0;
-                       bgp_static->igpnexthop.s_addr = 0;
+                       bgp_static->igpnexthop.s_addr = INADDR_ANY;
                        bgp_static->label_index = label_index;
 
                        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->valid = 0;
                bgp_static->igpmetric = 0;
-               bgp_static->igpnexthop.s_addr = 0;
+               bgp_static->igpnexthop.s_addr = INADDR_ANY;
                bgp_static->label = label;
                bgp_static->prd = prd;
 
@@ -7540,7 +7539,7 @@ void route_vty_out(struct vty *vty, struct prefix *p,
                                                 : inet_ntoa(attr->nexthop),
                                vrf_id_str);
        } else if (safi == SAFI_FLOWSPEC) {
-               if (attr->nexthop.s_addr != 0) {
+               if (attr->nexthop.s_addr != INADDR_ANY) {
                        if (json_paths) {
                                json_nexthop_global = json_object_new_object();
 
index ecd770a1d1dc9c90cc40df08145b21ee7440b074..f5de9ac8c67b505b931878cc0b9bf4b3a30f5565 100644 (file)
@@ -1705,7 +1705,7 @@ route_set_ip_nexthop(void *rule, const struct prefix *prefix,
                         */
                        SET_FLAG(path->attr->rmap_change_flags,
                                 BATTR_RMAP_NEXTHOP_PEER_ADDRESS);
-                       path->attr->nexthop.s_addr = 0;
+                       path->attr->nexthop.s_addr = INADDR_ANY;
                }
        } else {
                /* Set next hop value. */
index f31f8cd31bdb5beeb8572c88087f17f1d56b8504..77b547c0aa5f49ad0e1e49f8961fc639fc6b2af5 100644 (file)
@@ -755,7 +755,7 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
 
                        oid2in_addr(offset, len, &paddr);
                } else
-                       paddr.s_addr = 0;
+                       paddr.s_addr = INADDR_ANY;
 
                if (!rn)
                        return NULL;
@@ -804,7 +804,7 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
                                return min;
                        }
 
-                       paddr.s_addr = 0;
+                       paddr.s_addr = INADDR_ANY;
                } while ((rn = bgp_route_next(rn)) != NULL);
        }
        return NULL;
index 39eb065288fc4a3f4a384014a458fb43acc6ae4c..86750c0fcc5673b1d23eaca72265cc167109d43d 100644 (file)
@@ -467,16 +467,16 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
                                        mod_v4nh = &peer->nexthop.v4;
                                        nh_modified = 1;
                                }
-                       } else if (!v4nh.s_addr) {
+                       } else if (v4nh.s_addr == INADDR_ANY) {
                                mod_v4nh = &peer->nexthop.v4;
                                nh_modified = 1;
-                       } else if (
-                               peer->sort == BGP_PEER_EBGP
-                               && (bgp_multiaccess_check_v4(v4nh, peer) == 0)
-                               && !CHECK_FLAG(
+                       } else if (peer->sort == BGP_PEER_EBGP
+                                  && (bgp_multiaccess_check_v4(v4nh, peer)
+                                      == 0)
+                                  && !CHECK_FLAG(
                                           vec->flags,
                                           BPKT_ATTRVEC_FLAGS_RMAP_NH_UNCHANGED)
-                               && !peer_af_flag_check(
+                                  && !peer_af_flag_check(
                                           peer, paf->afi, paf->safi,
                                           PEER_FLAG_NEXTHOP_UNCHANGED)) {
                                /* NOTE: not handling case where NH has new AFI
@@ -628,7 +628,7 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
                        mod_v4nh = &v4nh;
 
                        /* No route-map changes allowed for EVPN nexthops. */
-                       if (!v4nh.s_addr) {
+                       if (v4nh.s_addr == INADDR_ANY) {
                                mod_v4nh = &peer->nexthop.v4;
                                nh_modified = 1;
                        }
index 2c9529700f290bb783ea593fa575da150d35d236..076b6aabca12b68282c4699cb0cf0cace2d7e32b 100644 (file)
@@ -819,7 +819,7 @@ bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote,
 
                /* IPv4 nexthop. */
                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;
 
                /* Global address*/
@@ -2548,7 +2548,8 @@ static int bgp_zebra_process_local_vni(ZAPI_CALLBACK_ARGS)
 
        if (cmd == ZEBRA_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);
        else
                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);
 
        /* redirect IP */
-       if (nh->gate.ipv4.s_addr) {
+       if (nh->gate.ipv4.s_addr != INADDR_ANY) {
                char buff[PREFIX_STRLEN];
 
                api_nh->vrf_id = nh->vrf_id;
index 05a3f7ef2e985fd8f51a5fe01095a64344b1ddc2..60bcc7b8e3482f4dd56cb4912573875edcc61cf9 100644 (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)
 {
        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 */);
        return 0;
 }
index 324f309290dbb0bb8d341ae6efab577f6051da2e..39008a01c4a427f6748909b0f869242d62ac3c35 100644 (file)
@@ -230,7 +230,7 @@ int eigrp_network_set(struct eigrp *eigrp, struct prefix *p)
        rn->info = (void *)pref;
 
        /* Schedule Router ID Update. */
-       if (eigrp->router_id.s_addr == 0)
+       if (eigrp->router_id.s_addr == INADDR_ANY)
                eigrp_router_id_update(eigrp);
        /* Run network config now. */
        /* Get target interface. */
index 4ccce2ebb8c3f0ab9ed4705a5ba745500314d166..e03ebb4fcb2814f39bb95be944b14c25f114acca 100644 (file)
@@ -161,7 +161,7 @@ static int eigrpd_instance_router_id_destroy(enum nb_event event,
                break;
        case NB_EV_APPLY:
                eigrp = nb_running_get_entry(dnode, NULL, true);
-               eigrp->router_id_static.s_addr = 0;
+               eigrp->router_id_static.s_addr = INADDR_ANY;
                break;
        }
 
index e93dc0cbfa29a265429de3cf285c98cea4983496..820f015b5711e6889913840a5410680e1d3a321b 100644 (file)
@@ -99,10 +99,10 @@ void eigrp_router_id_update(struct eigrp *eigrp)
 
        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;
 
-       else if (eigrp->router_id.s_addr != 0)
+       else if (eigrp->router_id.s_addr != INADDR_ANY)
                router_id = eigrp->router_id;
 
        else
@@ -142,8 +142,8 @@ static struct eigrp *eigrp_new(uint16_t as, vrf_id_t vrf_id)
        eigrp->vrf_id = vrf_id;
        eigrp->vrid = 0;
        eigrp->AS = as;
-       eigrp->router_id.s_addr = 0;
-       eigrp->router_id_static.s_addr = 0;
+       eigrp->router_id.s_addr = INADDR_ANY;
+       eigrp->router_id_static.s_addr = INADDR_ANY;
        eigrp->sequence_number = 1;
 
        /*Configure default K Values for EIGRP Process*/
index 4ef57f574a75c21b90f09202653a543041926703..816fcc64b85c8704d97490a5e6bd055a9950255b 100644 (file)
@@ -250,9 +250,8 @@ ldp_config_write(struct vty *vty)
 
        vty_out (vty, "mpls ldp\n");
 
-       if (ldpd_conf->rtr_id.s_addr != 0)
-               vty_out (vty, " router-id %s\n",
-                   inet_ntoa(ldpd_conf->rtr_id));
+       if (ldpd_conf->rtr_id.s_addr != INADDR_ANY)
+               vty_out(vty, " router-id %s\n", inet_ntoa(ldpd_conf->rtr_id));
 
        if (ldpd_conf->lhello_holdtime != LINK_DFLT_HOLDTIME &&
            ldpd_conf->lhello_holdtime != 0)
index 4521cf64696fd269eb3253cdbf995c1de6cd5764..911a8e53d16fc4f65512eee685e154a9969fc54f 100644 (file)
@@ -2551,7 +2551,8 @@ static int filter_show(struct vty *vty, const char *name, afi_t afi)
                                else {
                                        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,
                                                        ", wildcard bits %s",
                                                        inet_ntoa(
@@ -2599,7 +2600,8 @@ static int filter_show(struct vty *vty, const char *name, afi_t afi)
                                else {
                                        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,
                                                        ", wildcard bits %s",
                                                        inet_ntoa(
@@ -2692,7 +2694,7 @@ static void config_write_access_cisco(struct vty *vty, struct filter *mfilter)
                vty_out(vty, " ip");
                if (filter->addr_mask.s_addr == 0xffffffff)
                        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));
                else {
                        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)
                        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));
                else {
                        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");
                else {
                        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",
                                        inet_ntoa(filter->addr_mask));
                        vty_out(vty, "\n");
index cb6e53b30539f1cd7d6cdb8041f8fe0dcdfa561e..199ff3267bce011aa2cbb96876685846b9f8075a 100644 (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. */
 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 */
@@ -1144,7 +1144,7 @@ int netmask_str2prefix_str(const char *net_str, const char *mask_str,
        } else {
                destination = ntohl(network.s_addr);
 
-               if (network.s_addr == 0)
+               if (network.s_addr == INADDR_ANY)
                        prefixlen = 0;
                else if (IN_CLASSC(destination))
                        prefixlen = 24;
index 78f2a5a018fcec108b27edc8f071280ea45d9cc9..68b112b09a7e99b5f1f52efef726c43d3b2e669a 100644 (file)
@@ -940,7 +940,7 @@ lib_route_map_entry_set_action_ipv4_address_modify(enum nb_event event,
                 * only implemented action.
                 */
                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;
                /* FALLTHROUGH */
        case NB_EV_PREPARE:
index 9f828a1c7d832a3f58760fc154ee35f57324b3b7..7cf8dfbde42fde3f8b803f7e89f55e6fffc52025 100644 (file)
@@ -135,7 +135,7 @@ static void nhrp_interface_update_nbma(struct interface *ifp)
                                     &nifp->linkidx, &saddr);
                debugf(NHRP_DEBUG_IF, "%s: GRE: %x %x %x", ifp->name,
                       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,
                                      sizeof(saddr.s_addr));
                else if (!nbmaifp && nifp->linkidx != IFINDEX_INTERNAL)
index 50485cc7e25c334de1a40787e945d3809c8b13c0..da390e3c704ed806da56afaf989297530e5ade12 100644 (file)
@@ -451,7 +451,7 @@ int ospf_apiclient_lsa_originate(struct ospf_apiclient *oclient,
 
        tmp = SET_OPAQUE_LSID(opaque_type, opaque_id);
        lsah->id.s_addr = htonl(tmp);
-       lsah->adv_router.s_addr = 0;
+       lsah->adv_router.s_addr = INADDR_ANY;
        lsah->ls_seqnum = 0;
        lsah->checksum = 0;
        lsah->length = htons(sizeof(struct lsa_header) + opaquelen);
index c8b8b611efcbd9fdc06ac55af6223e2f50336920..b4690cfa424a39cec334789264922ec668df5691 100644 (file)
@@ -310,7 +310,7 @@ int ospf_area_range_substitute_unset(struct ospf *ospf, struct in_addr area_id,
                        ospf_schedule_abr_task(ospf);
 
        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;
 
        return 1;
index 44244f651edcb58dac796e7847c2cd77bfab73f3..2c80d485a3fe6f44881907b8822e497ea36f86b8 100644 (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
               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
                   be sent to the ASBR itself. Among the multiple routing table
                   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);
 
-               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);
                return 0;
        } else {
@@ -512,7 +512,7 @@ int ospf_ase_calculate_route(struct ospf *ospf, struct ospf_lsa *lsa)
                                zlog_debug(
                                        "Route[External]: New route is better");
                        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(
                                        new, al->e[0].fwd_addr);
                        or = new;
@@ -530,7 +530,7 @@ int ospf_ase_calculate_route(struct ospf *ospf, struct ospf_lsa *lsa)
                        if (IS_DEBUG_OSPF(lsa, LSA))
                                zlog_debug("Route[External]: Routes are equal");
                        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(
                                        or, al->e[0].fwd_addr);
                }
index 3eb03f53c4df28f8a2504f782979373092f43cfb..f2efaf322f6bf13770549fec5b895c3bb9fe34af 100644 (file)
@@ -862,7 +862,7 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
 
        p = prefix_ipv4_new();
        p->family = AF_INET;
-       p->prefix.s_addr = 0;
+       p->prefix.s_addr = INADDR_ANY;
        p->prefixlen = 0;
 
        co->address = (struct prefix *)p;
@@ -885,7 +885,7 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
        if (IS_DEBUG_OSPF_EVENT)
                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);
        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;
 
-       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;
        ospf_if_free(vl_data->vl_oi);
        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)
                return;
 
-       oi->address->u.prefix4.s_addr = 0;
+       oi->address->u.prefix4.s_addr = INADDR_ANY;
        oi->address->prefixlen = 0;
 
        UNSET_FLAG(oi->ifp->flags, IFF_UP);
index e394b6f472b4f58f2d4439a46c817a269b9245bb..f4e89da45dd5f167cf27067b7e66737768393e9b 100644 (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))
                if ((nbr = rn->info) != NULL)
                        /* Ignore 0.0.0.0 node*/
-                       if (nbr->router_id.s_addr != 0)
+                       if (nbr->router_id.s_addr != INADDR_ANY)
                                /* Is neighbor eligible? */
                                if (nbr->priority > 0)
                                        /* 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))
                if ((nbr = rn->info) != NULL)
                        /* 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? */
                                if (nbr->state >= NSM_TwoWay)
                                        /* Ignore myself. */
index 6eec87c93ea87931096cdc5560df1939cd2c2611..35bbe06cd15d8d9518b3485e7127559c67e87cf4 100644 (file)
@@ -820,7 +820,7 @@ static struct ospf_lsa *ospf_router_lsa_originate(struct ospf_area *area)
        }
 
        /* Sanity check. */
-       if (new->data->adv_router.s_addr == 0) {
+       if (new->data->adv_router.s_addr == INADDR_ANY) {
                if (IS_DEBUG_OSPF_EVENT)
                        zlog_debug("LSA[Type1]: AdvRouter is 0, discard");
                ospf_lsa_discard(new);
@@ -1459,7 +1459,7 @@ struct in_addr ospf_get_ip_from_ifp(struct ospf_interface *oi)
 {
        struct in_addr fwd;
 
-       fwd.s_addr = 0;
+       fwd.s_addr = INADDR_ANY;
 
        if (if_is_operative(oi->ifp))
                return oi->address->u.prefix4;
@@ -1931,7 +1931,7 @@ int is_prefix_default(struct prefix_ipv4 *p)
        struct prefix_ipv4 q;
 
        q.family = AF_INET;
-       q.prefix.s_addr = 0;
+       q.prefix.s_addr = INADDR_ANY;
        q.prefixlen = 0;
 
        return prefix_same((struct prefix *)p, (struct prefix *)&q);
@@ -1979,10 +1979,11 @@ 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)
-                       zlog_debug("LSA[Type5:%pI4]: deferring AS-external-LSA origination, router ID is zero",
-                                  &ei->p.prefix);
+                       zlog_debug(
+                               "LSA[Type5:%pI4]: deferring AS-external-LSA origination, router ID is zero",
+                               &ei->p.prefix);
                return NULL;
        }
 
@@ -2197,7 +2198,7 @@ void ospf_external_lsa_refresh_default(struct ospf *ospf)
 
        p.family = AF_INET;
        p.prefixlen = 0;
-       p.prefix.s_addr = 0;
+       p.prefix.s_addr = INADDR_ANY;
 
        ei = ospf_default_external_info(ospf);
        lsa = ospf_external_info_find_lsa(ospf, &p);
index 95fb694925a3d1eb090bafb274563541d241257d..1b47fde215894464b9a209bf9c6073b768f26d43 100644 (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,
           cause event BackupSeen */
        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);
 
        /* 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))
                if ((nbr = rn->info))
                        if (nbr->router_id.s_addr
-                           != 0) /* Ignore 0.0.0.0 node. */
+                           != INADDR_ANY) /* Ignore 0.0.0.0 node. */
                                if (nbr->state
                                    != NSM_Attempt) /* Ignore Down neighbor. */
                                        if (nbr->state
@@ -3364,17 +3365,17 @@ static int ospf_make_hello(struct ospf_interface *oi, struct stream *s)
                                                        /* Check neighbor is
                                                         * sane? */
                                                        if (nbr->d_router.s_addr
-                                                                   != 0
+                                                                   != INADDR_ANY
                                                            && IPV4_ADDR_SAME(
-                                                                      &nbr->d_router,
-                                                                      &oi->address
-                                                                               ->u
-                                                                               .prefix4)
+                                                                   &nbr->d_router,
+                                                                   &oi->address
+                                                                            ->u
+                                                                            .prefix4)
                                                            && IPV4_ADDR_SAME(
-                                                                      &nbr->bd_router,
-                                                                      &oi->address
-                                                                               ->u
-                                                                               .prefix4))
+                                                                   &nbr->bd_router,
+                                                                   &oi->address
+                                                                            ->u
+                                                                            .prefix4))
                                                                flag = 1;
 
                                                        /* Hello packet overflows interface MTU. */
index 6cabc0c985dcd6ce8907f4a00c41fce5030e1ebb..b6e8338ee704101002787c5c913f870076573cc6 100644 (file)
@@ -603,7 +603,7 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link,
                                        IF_NAME(oi));
 
                        path = ospf_path_new();
-                       path->nexthop.s_addr = 0;
+                       path->nexthop.s_addr = INADDR_ANY;
                        path->ifindex = oi->ifp->ifindex;
                        if (CHECK_FLAG(oi->connected->flags,
                                       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->type = OSPF_DESTINATION_DISCARD;
-       new_or->id.s_addr = 0;
+       new_or->id.s_addr = INADDR_ANY;
        new_or->cost = 0;
        new_or->u.std.area_id = area->area_id;
        new_or->u.std.external_routing = area->external_routing;
index 1542ef88fb9ad3eeedb8e7dadfc1d360af78151a..fb4082e50994f168ff1b98b72b8836479aa9fae6 100644 (file)
@@ -3551,7 +3551,7 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
                }
 
                /* Show DR information. */
-               if (DR(oi).s_addr == 0) {
+               if (DR(oi).s_addr == INADDR_ANY) {
                        if (!use_json)
                                vty_out(vty,
                                        "  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
-                                   && nbr->router_id.s_addr == 0)
+                                   && nbr->router_id.s_addr == INADDR_ANY)
                                        strlcpy(neigh_str, "neighbor",
                                                sizeof(neigh_str));
                                else
@@ -4258,7 +4258,7 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty,
                                ospf_nbr_state_message(nbr, msgbuf, 16);
 
                                if (nbr->state == NSM_Attempt
-                                   && nbr->router_id.s_addr == 0)
+                                   && nbr->router_id.s_addr == INADDR_ANY)
                                        vty_out(vty, "%-15s %3d %-15s ", "-",
                                                nbr->priority, msgbuf);
                                else
@@ -4908,7 +4908,8 @@ static void show_ip_ospf_neighbor_detail_sub(struct vty *vty,
                        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));
                else
                        strlcpy(neigh_str, inet_ntoa(nbr->router_id),
@@ -4926,7 +4927,8 @@ static void show_ip_ospf_neighbor_detail_sub(struct vty *vty,
 
        } else {
                /* 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,", "-");
                else
                        vty_out(vty, " Neighbor %s,",
index 68d9d3bf8319bd1553be65714d5a85f26706f1db..64013435f657ae12817b37065378fcce2fe628dd 100644 (file)
@@ -585,9 +585,9 @@ int ospf_redistribute_default_set(struct ospf *ospf, int originate, int mtype,
        int cur_originate = ospf->default_originate;
        const char *type_str = NULL;
 
-       nexthop.s_addr = 0;
+       nexthop.s_addr = INADDR_ANY;
        p.family = AF_INET;
-       p.prefix.s_addr = 0;
+       p.prefix.s_addr = INADDR_ANY;
        p.prefixlen = 0;
 
        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 */
                        return 0;
                }
-               if (ospf->router_id.s_addr != 0) {
+               if (ospf->router_id.s_addr != INADDR_ANY) {
                        if (ei) {
                                if (is_prefix_default(&p))
                                        ospf_external_lsa_refresh_default(ospf);
index 6a4e63372aedeab31919ccedc4981963b0ac9ab8..2a3f1329a0c158bf11ae9ac74ad0def5fc85776b 100644 (file)
@@ -329,7 +329,7 @@ struct ospf *ospf_lookup_instance(unsigned short instance)
 static int ospf_is_ready(struct ospf *ospf)
 {
        /* 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 1;
@@ -379,7 +379,7 @@ struct ospf *ospf_get(unsigned short instance, const char *name, bool *created)
                ospf = ospf_new(instance, name);
                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_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_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_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
         * 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);
 }
 
@@ -1267,7 +1268,7 @@ static void ospf_network_run(struct prefix *p, struct ospf_area *area)
        struct interface *ifp;
 
        /* 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);
 
        /* Get target interface. */
index dd9576275411c0a88d0dfe8e1210121427314665..2f10abccee5953ecfcd9ce445fa0f59c64f22d4a 100644 (file)
@@ -448,7 +448,7 @@ int main(int argc, char *const argv[])
                exit(EXIT_FAILURE);
        }
 
-       mc_group.s_addr = 0;
+       mc_group.s_addr = INADDR_ANY;
        not_group = false;
 
        if (argc == 3) {
index 01bebebd290215e991f06fe213073e9d55c75c67..6508fb4453f71f4abea06b5173f3aa70385c14ab 100644 (file)
@@ -1741,12 +1741,12 @@ static void pim_show_join(struct pim_instance *pim, struct vty *vty,
                        continue;
 
                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)
                                continue;
-                       if (sg->src.s_addr != 0
+                       if (sg->src.s_addr != INADDR_ANY
                            && sg->src.s_addr != ch->sg.src.s_addr)
-                       continue;
+                               continue;
                        pim_show_join_helper(vty, pim_ifp, ch, json, now, uj);
                } /* scan interface channels */
        }
@@ -2448,9 +2448,11 @@ static void pim_show_upstream(struct pim_instance *pim, struct vty *vty,
                char msdp_reg_timer[10];
                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;
-               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;
 
                pim_inet4_dump("<src?>", up->sg.src, src_str, sizeof(src_str));
index 3a7eb45f27fb3abdb44c794e913267cf127a5b60..d9c9bb37dd2048171c25b8ce883ca1a7cb6cec2b 100644 (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_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 */
        ch->t_ifassert_timer = NULL;
index 695d04c7c2ba4cdc0243446fdb21a0e47a57e4fa..309b8c1495b11658c6b4032e4296358959197d4b 100644 (file)
@@ -68,7 +68,7 @@ static bool mtrace_fwd_info_weak(struct pim_instance *pim,
        struct in_addr nh_addr;
        char nexthop_str[INET_ADDRSTRLEN];
 
-       nh_addr.s_addr = 0;
+       nh_addr.s_addr = INADDR_ANY;
 
        memset(&nexthop, 0, sizeof(nexthop));
 
@@ -123,7 +123,7 @@ static bool mtrace_fwd_info(struct pim_instance *pim,
        up = pim_upstream_find(pim, &sg);
 
        if (!up) {
-               sg.src.s_addr = 0;
+               sg.src.s_addr = INADDR_ANY;
                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;
 
        /* 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->src_mask = MTRACE_SRC_MASK_SOURCE;
        } 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)
 {
        mtrace_rspp->arrival = 0;
-       mtrace_rspp->incoming.s_addr = 0;
-       mtrace_rspp->outgoing.s_addr = 0;
-       mtrace_rspp->prev_hop.s_addr = 0;
+       mtrace_rspp->incoming.s_addr = INADDR_ANY;
+       mtrace_rspp->outgoing.s_addr = INADDR_ANY;
+       mtrace_rspp->prev_hop.s_addr = INADDR_ANY;
        mtrace_rspp->in_count = htonl(MTRACE_UNKNOWN_COUNT);
        mtrace_rspp->out_count = 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... */
 
-       if (mtracep->grp_addr.s_addr)
+       if (mtracep->grp_addr.s_addr != INADDR_ANY)
                fwd_info = mtrace_fwd_info(pim, mtracep, rspp, &out_ifp);
        else
                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;
 
-       if (nh_addr.s_addr == 0) {
+       if (nh_addr.s_addr == INADDR_ANY) {
                /* no pim? i.e. 7.5.3. No Previous Hop */
                if (!out_ifp->info) {
                        if (PIM_DEBUG_MTRACE)
index bb02a36e1db65caf63777d6287631b2cd844095f..27af9473bb65cce9f44218d4b08c77da092974f0 100644 (file)
@@ -473,7 +473,7 @@ static void pim_msdp_sa_local_add(struct pim_instance *pim,
                                  struct prefix_sg *sg)
 {
        struct in_addr rp;
-       rp.s_addr = 0;
+       rp.s_addr = INADDR_ANY;
        pim_msdp_sa_ref(pim, NULL /* mp */, sg, rp);
 }
 
index 4e848766d6fbfc00ebd5c7c50bce4147e9727a8d..102b64df6b9c326220148a128c73ac3ea02cc6f1 100644 (file)
@@ -158,8 +158,9 @@ route_match_ip_next_hop(void *rule, const struct prefix *prefix,
        if (type == RMAP_RIP) {
                rinfo = object;
                p.family = AF_INET;
-               p.prefix = (rinfo->nh.gate.ipv4.s_addr) ? rinfo->nh.gate.ipv4
-                                                       : rinfo->from;
+               p.prefix = (rinfo->nh.gate.ipv4.s_addr != INADDR_ANY)
+                                  ? rinfo->nh.gate.ipv4
+                                  : rinfo->from;
                p.prefixlen = IPV4_MAX_BITLEN;
 
                alist = access_list_lookup(AFI_IP, (char *)rule);
@@ -207,8 +208,9 @@ route_match_ip_next_hop_prefix_list(void *rule, const struct prefix *prefix,
        if (type == RMAP_RIP) {
                rinfo = object;
                p.family = AF_INET;
-               p.prefix = (rinfo->nh.gate.ipv4.s_addr) ? rinfo->nh.gate.ipv4
-                                                       : rinfo->from;
+               p.prefix = (rinfo->nh.gate.ipv4.s_addr != INADDR_ANY)
+                                  ? rinfo->nh.gate.ipv4
+                                  : rinfo->from;
                p.prefixlen = IPV4_MAX_BITLEN;
 
                plist = prefix_list_lookup(AFI_IP, (char *)rule);
index 99f48dffdd090237ba64b246956afa297b059498..5ccefac1788d1a2277a081b5c8a64f5cbf83adc8 100644 (file)
@@ -1223,7 +1223,8 @@ static void rip_response_process(struct rip_packet *packet, int size,
                }
 
                /* 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",
                                  inet_ntoa(rte->nexthop));
                        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
                   the received Next Hop is not directly reachable, it should be
                   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;
 
                        /* 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",
                                                                inet_ntoa(
                                                                        rte->nexthop));
-                                               rte->nexthop.s_addr = 0;
+                                               rte->nexthop.s_addr =
+                                                       INADDR_ANY;
                                        }
 
                                        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",
                                                        inet_ntoa(
                                                                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
                   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
-                       && (rte->prefix.s_addr != 0
-                           && rte->mask.s_addr == 0))) {
+                       && (rte->prefix.s_addr != INADDR_ANY
+                           && rte->mask.s_addr == INADDR_ANY))) {
                        uint32_t destination;
 
                        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
                   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)) {
                        zlog_warn(
@@ -1363,12 +1368,13 @@ static void rip_response_process(struct rip_packet *packet, int size,
                }
 
                /* Default route's netmask is ignored. */
-               if (packet->version == RIPv2 && (rte->prefix.s_addr == 0)
-                   && (rte->mask.s_addr != 0)) {
+               if (packet->version == RIPv2
+                   && (rte->prefix.s_addr == INADDR_ANY)
+                   && (rte->mask.s_addr != INADDR_ANY)) {
                        if (IS_RIP_DEBUG_EVENT)
                                zlog_debug(
                                        "Default route with non-zero netmask.  Set zero to netmask");
-                       rte->mask.s_addr = 0;
+                       rte->mask.s_addr = INADDR_ANY;
                }
 
                /* Routing table updates. */
index b37d4aea70277766a4b2a141136ecf7a2c19b715..710f2f6c2798c24b3b20a7d5f570d720712de85d 100644 (file)
@@ -75,11 +75,11 @@ void router_id_get(struct prefix *p, vrf_id_t vrf_id)
        struct connected *c;
        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->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;
        else if (!list_isempty(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)
                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)
                                        vty_out(vty, "router-id %s\n",
                                                inet_ntoa(
index b1c679e06607738aaa8b77e82f190a817544ae78..1d63db32e8a5e5f41a60564473cc6e12f56586d7 100644 (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);
                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,
                                  &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,
                                  &nexthop->src.ipv4, bytelen);
 
@@ -1187,10 +1189,10 @@ static void _netlink_route_build_singlepath(const char *routedesc, int bytelen,
                                bytelen, nexthop);
 
                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,
                                          &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,
                                          &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 (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,
                                          &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,
                                          &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_ifindex = nexthop->ifindex;
 
-               if (nexthop->rmap_src.ipv4.s_addr)
+               if (nexthop->rmap_src.ipv4.s_addr != INADDR_ANY)
                        *src = &nexthop->rmap_src;
-               else if (nexthop->src.ipv4.s_addr)
+               else if (nexthop->src.ipv4.s_addr != INADDR_ANY)
                        *src = &nexthop->src;
 
                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,
                                                    rta, rtnh, NL_PKT_BUF_SIZE,
                                                    bytelen, nexthop);
-               if (nexthop->rmap_src.ipv4.s_addr)
+               if (nexthop->rmap_src.ipv4.s_addr != INADDR_ANY)
                        *src = &nexthop->rmap_src;
-               else if (nexthop->src.ipv4.s_addr)
+               else if (nexthop->src.ipv4.s_addr != INADDR_ANY)
                        *src = &nexthop->src;
 
                if (IS_ZEBRA_DEBUG_KERNEL)
@@ -1396,9 +1398,9 @@ static void _netlink_route_build_multipath(const char *routedesc, int bytelen,
 
        /* 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;
-               else if (nexthop->src.ipv4.s_addr)
+               else if (nexthop->src.ipv4.s_addr != INADDR_ANY)
                        *src = &nexthop->src;
 
                if (IS_ZEBRA_DEBUG_KERNEL)
index 7786dc246c34eac08cef50020ec9b87f2a497d19..d6f55fdeb47c5e952aa6ddfdee19fd555222625a 100644 (file)
@@ -218,7 +218,7 @@ static int netlink_route_info_add_nh(netlink_route_info_t *ri,
        if (nexthop->type == NEXTHOP_TYPE_IPV4
            || nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX) {
                nhi.gateway = &nexthop->gate;
-               if (nexthop->src.ipv4.s_addr)
+               if (nexthop->src.ipv4.s_addr != INADDR_ANY)
                        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->src.ipv4.s_addr)
+               if (nexthop->src.ipv4.s_addr != INADDR_ANY)
                        src = &nexthop->src;
        }
 
index c09fa1c65d8a755fc620f97f95011de56c27e212..d50981debf58685b38dbfa19f484d973532b1dce 100644 (file)
@@ -86,7 +86,7 @@ static inline int add_nexthop(qpb_allocator_t *allocator, Fpm__AddRoute *msg,
        if (nexthop->type == NEXTHOP_TYPE_IPV4
            || nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX) {
                gateway = &nexthop->gate;
-               if (nexthop->src.ipv4.s_addr)
+               if (nexthop->src.ipv4.s_addr != INADDR_ANY)
                        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->src.ipv4.s_addr)
+               if (nexthop->src.ipv4.s_addr != INADDR_ANY)
                        src = &nexthop->src;
        }
 
index ffb2528a245716716984c08d78528142195c6ada..4b56581ca9ba7282f30c0a3893caf071847bccbb 100644 (file)
@@ -3212,7 +3212,7 @@ static int zvni_local_neigh_update(zebra_vni_t *zvni,
                        vtep_ip = n->r_vtep_ip;
                        /* Mark appropriately */
                        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);
                        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
         * vxlan-termination-mroute
         */
-       if (sg->src.s_addr) {
+       if (sg->src.s_addr != INADDR_ANY) {
                memset(&sip, 0, sizeof(sip));
                parent = zebra_vxlan_sg_do_ref(zvrf, sip, sg->grp);
                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
         * entry
         */
-       if (vxlan_sg->sg.src.s_addr) {
+       if (vxlan_sg->sg.src.s_addr != INADDR_ANY) {
                memset(&sip, 0, sizeof(sip));
                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;
 
-       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;
 
        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;
 
-       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;
 
        zvrf = vrf_info_lookup(VRF_DEFAULT);