pimd: remove PIM_INADDR_IS[NOT]_ANY macros

These really don't serve much of a purpose, especially with how
inconsistently they're used.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2022-01-13 14:37:42 +01:00
parent 6d7bf748b6
commit 3ca68c9cf3
7 changed files with 14 additions and 17 deletions

View file

@ -403,7 +403,7 @@ static int pim_sec_addr_update(struct interface *ifp)
for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc)) {
struct prefix *p = ifc->address;
if (PIM_INADDR_IS_ANY(p->u.prefix4)) {
if (p->u.prefix4.s_addr == INADDR_ANY) {
continue;
}
@ -598,7 +598,7 @@ void pim_if_addr_add(struct connected *ifc)
if (PIM_IF_TEST_PIM(pim_ifp->options)) {
if (PIM_INADDR_ISNOT_ANY(pim_ifp->primary_address)) {
if (!pim_addr_is_any(pim_ifp->primary_address)) {
/* Interface has a valid socket ? */
if (pim_ifp->pim_sock_fd < 0) {
@ -684,7 +684,7 @@ static void pim_if_addr_del_pim(struct connected *ifc)
return;
}
if (PIM_INADDR_ISNOT_ANY(pim_ifp->primary_address)) {
if (!pim_addr_is_any(pim_ifp->primary_address)) {
/* Interface keeps a valid primary address */
return;
}
@ -752,7 +752,7 @@ void pim_if_addr_add_all(struct interface *ifp)
if (PIM_IF_TEST_PIM(pim_ifp->options)) {
/* Interface has a valid primary address ? */
if (PIM_INADDR_ISNOT_ANY(pim_ifp->primary_address)) {
if (!pim_addr_is_any(pim_ifp->primary_address)) {
/* Interface has a valid socket ? */
if (pim_ifp->pim_sock_fd < 0) {
@ -836,7 +836,7 @@ struct in_addr pim_find_primary_addr(struct interface *ifp)
int v6_addrs = 0;
struct pim_interface *pim_ifp = ifp->info;
if (pim_ifp && PIM_INADDR_ISNOT_ANY(pim_ifp->update_source)) {
if (pim_ifp && !pim_addr_is_any(pim_ifp->update_source)) {
return pim_ifp->update_source;
}
@ -848,7 +848,7 @@ struct in_addr pim_find_primary_addr(struct interface *ifp)
continue;
}
if (PIM_INADDR_IS_ANY(p->u.prefix4)) {
if (p->u.prefix4.s_addr == INADDR_ANY) {
zlog_warn(
"%s: null IPv4 address connected to interface %s",
__func__, ifp->name);
@ -916,7 +916,7 @@ static int pim_iface_next_vif_index(struct interface *ifp)
int pim_if_add_vif(struct interface *ifp, bool ispimreg, bool is_vxlan_term)
{
struct pim_interface *pim_ifp = ifp->info;
struct in_addr ifaddr;
pim_addr ifaddr;
unsigned char flags = 0;
assert(pim_ifp);
@ -935,7 +935,7 @@ int pim_if_add_vif(struct interface *ifp, bool ispimreg, bool is_vxlan_term)
}
ifaddr = pim_ifp->primary_address;
if (!ispimreg && !is_vxlan_term && PIM_INADDR_IS_ANY(ifaddr)) {
if (!ispimreg && !is_vxlan_term && pim_addr_is_any(ifaddr)) {
zlog_warn(
"%s: could not get address for interface %s ifindex=%d",
__func__, ifp->name, ifp->ifindex);

View file

@ -1675,7 +1675,7 @@ void igmp_v3_send_query(struct gm_group *group, int fd, const char *ifname,
*/
if (!s_flag) {
/* general query? */
if (PIM_INADDR_IS_ANY(group_addr)) {
if (group_addr.s_addr == INADDR_ANY) {
char dst_str[INET_ADDRSTRLEN];
char group_str[INET_ADDRSTRLEN];
pim_inet4_dump("<dst?>", dst_addr, dst_str,
@ -1762,7 +1762,7 @@ void igmp_v3_recv_query(struct gm_sock *igmp, const char *from_str,
if (!s_flag) {
/* s_flag is clear */
if (PIM_INADDR_IS_ANY(group_addr)) {
if (group_addr.s_addr == INADDR_ANY) {
/* this is a general query */
/* log that general query should have the s_flag set */
zlog_warn(

View file

@ -477,7 +477,7 @@ int pim_joinprune_send(struct pim_rpf *rpf, struct list *groups)
return -1;
}
if (PIM_INADDR_IS_ANY(rpf->rpf_addr.u.prefix4)) {
if (rpf->rpf_addr.u.prefix4.s_addr == INADDR_ANY) {
if (PIM_DEBUG_PIM_J_P) {
char dst_str[INET_ADDRSTRLEN];
pim_inet4_dump("<dst?>", rpf->rpf_addr.u.prefix4,

View file

@ -128,7 +128,7 @@ int pim_macro_ch_lost_assert(const struct pim_ifchannel *ch)
return 0; /* false */
}
if (PIM_INADDR_IS_ANY(ch->ifassert_winner))
if (pim_addr_is_any(ch->ifassert_winner))
return 0; /* false */
/* AssertWinner(S,G,I) == me ? */

View file

@ -315,7 +315,7 @@ static void pim_msdp_sa_peer_ip_set(struct pim_msdp_sa *sa,
}
/* any time the peer ip changes also update the rp address */
if (PIM_INADDR_ISNOT_ANY(sa->peer)) {
if (sa->peer.s_addr != INADDR_ANY) {
old_mp = pim_msdp_peer_find(sa->pim, sa->peer);
if (old_mp && old_mp->sa_cnt) {
--old_mp->sa_cnt;

View file

@ -339,8 +339,7 @@ int pim_interface_config_write(struct vty *vty)
}
/* update source */
if (PIM_INADDR_ISNOT_ANY(
pim_ifp->update_source)) {
if (!pim_addr_is_any(pim_ifp->update_source)) {
char src_str[INET_ADDRSTRLEN];
pim_inet4_dump("<src?>",
pim_ifp->update_source,

View file

@ -83,8 +83,6 @@
#define PIM_FORCE_BOOLEAN(expr) ((expr) != 0)
#define PIM_NET_INADDR_ANY (htonl(INADDR_ANY))
#define PIM_INADDR_IS_ANY(addr) (addr).s_addr == PIM_NET_INADDR_ANY
#define PIM_INADDR_ISNOT_ANY(addr) ((addr).s_addr != PIM_NET_INADDR_ANY) /* struct in_addr addr */
#define PIM_MASK_PIM_EVENTS (1 << 0)
#define PIM_MASK_PIM_EVENTS_DETAIL (1 << 1)