]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd: remove useless PIM_IF_* macros 10960/head
authorDavid Lamparter <equinox@opensourcerouting.org>
Mon, 4 Apr 2022 12:00:59 +0000 (14:00 +0200)
committerDavid Lamparter <equinox@opensourcerouting.org>
Mon, 4 Apr 2022 12:11:29 +0000 (14:11 +0200)
The only function these macros have is to make the code confusing.
"PIM_IF_DO_PIM" sounds like it triggers some action, but it doesn't.

Replace with "bool" fields in struct pim_interface.

(Note: PIM_IF_*_IGMP_LISTEN_ALLROUTERS was always set, without any way
to unset it.  It is completely removed now and always enabled.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
pimd/pim_iface.c
pimd/pim_iface.h
pimd/pim_ifchannel.c
pimd/pim_igmp.c
pimd/pim_nb_config.c
pimd/pim_pim.c
pimd/pim_vty.c
pimd/pim_vxlan.c

index 4470d05663e02abb577936c64dcf8e60456742db..a644d9cfec9e5814de725e1fd841752543b49f65 100644 (file)
@@ -150,13 +150,9 @@ struct pim_interface *pim_if_new(struct interface *ifp, bool igmp, bool pim,
        assert(pim_ifp->gm_query_max_response_time_dsec <
               pim_ifp->gm_default_query_interval);
 
-       if (pim)
-               PIM_IF_DO_PIM(pim_ifp->options);
+       pim_ifp->pim_enable = pim;
 #if PIM_IPV == 4
-       if (igmp)
-               PIM_IF_DO_IGMP(pim_ifp->options);
-
-       PIM_IF_DO_IGMP_LISTEN_ALLROUTERS(pim_ifp->options);
+       pim_ifp->igmp_enable = igmp;
 #endif
 
        pim_ifp->gm_join_list = NULL;
@@ -317,7 +313,7 @@ static int detect_primary_address_change(struct interface *ifp,
 
        if (changed) {
                /* Before updating pim_ifp send Hello time with 0 hold time */
-               if (PIM_IF_TEST_PIM(pim_ifp->options)) {
+               if (pim_ifp->pim_enable) {
                        pim_hello_send(ifp, 0 /* zero-sec holdtime */);
                }
                pim_ifp->primary_address = new_prim_addr;
@@ -462,7 +458,7 @@ static void detect_address_change(struct interface *ifp, int force_prim_as_any,
 
 
        if (changed) {
-               if (!PIM_IF_TEST_PIM(pim_ifp->options)) {
+               if (!pim_ifp->pim_enable) {
                        return;
                }
 
@@ -543,7 +539,7 @@ void pim_if_addr_add(struct connected *ifc)
 #if PIM_IPV == 4
        struct in_addr ifaddr = ifc->address->u.prefix4;
 
-       if (PIM_IF_TEST_IGMP(pim_ifp->options)) {
+       if (pim_ifp->igmp_enable) {
                struct gm_sock *igmp;
 
                /* lookup IGMP socket */
@@ -610,7 +606,7 @@ void pim_if_addr_add(struct connected *ifc)
        } /* igmp mtrace only */
 #endif
 
-       if (PIM_IF_TEST_PIM(pim_ifp->options)) {
+       if (pim_ifp->pim_enable) {
 
                if (!pim_addr_is_any(pim_ifp->primary_address)) {
 
@@ -802,7 +798,7 @@ void pim_if_addr_add_all(struct interface *ifp)
        }
 
        if (!v4_addrs && v6_addrs && !if_is_loopback(ifp)) {
-               if (PIM_IF_TEST_PIM(pim_ifp->options)) {
+               if (pim_ifp->pim_enable) {
 
                        /* Interface has a valid primary address ? */
                        if (!pim_addr_is_any(pim_ifp->primary_address)) {
@@ -1211,7 +1207,7 @@ long pim_if_t_suppressed_msec(struct interface *ifp)
        assert(pim_ifp);
 
        /* join suppression disabled ? */
-       if (PIM_IF_TEST_PIM_CAN_DISABLE_JOIN_SUPPRESSION(pim_ifp->options))
+       if (pim_ifp->pim_can_disable_join_suppression)
                return 0;
 
        /* t_suppressed = t_periodic * rand(1.1, 1.4) */
index bab73eae86aa67018094e6031a12414317052afd..b0f7e52ac2da72ffeaccb0215eb18376ee4bebb7 100644 (file)
 #include "bfd.h"
 #include "pim_str.h"
 
-#define PIM_IF_MASK_PIM                             (1 << 0)
-#define PIM_IF_MASK_IGMP                            (1 << 1)
-#define PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS          (1 << 2)
-#define PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPPRESSION (1 << 3)
-
 #define PIM_IF_IS_DELETED(ifp) ((ifp)->ifindex == IFINDEX_INTERNAL)
 
-#define PIM_IF_TEST_PIM(options) (PIM_IF_MASK_PIM & (options))
-#define PIM_IF_TEST_IGMP(options) (PIM_IF_MASK_IGMP & (options))
-#define PIM_IF_TEST_IGMP_LISTEN_ALLROUTERS(options) (PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS & (options))
-#define PIM_IF_TEST_PIM_CAN_DISABLE_JOIN_SUPPRESSION(options)                  \
-       (PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPPRESSION & (options))
-
-#define PIM_IF_DO_PIM(options) ((options) |= PIM_IF_MASK_PIM)
-#define PIM_IF_DO_IGMP(options) ((options) |= PIM_IF_MASK_IGMP)
-#define PIM_IF_DO_IGMP_LISTEN_ALLROUTERS(options) ((options) |= PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS)
-#define PIM_IF_DO_PIM_CAN_DISABLE_JOIN_SUPPRESSION(options)                    \
-       ((options) |= PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPPRESSION)
-
-#define PIM_IF_DONT_PIM(options) ((options) &= ~PIM_IF_MASK_PIM)
-#define PIM_IF_DONT_IGMP(options) ((options) &= ~PIM_IF_MASK_IGMP)
-#define PIM_IF_DONT_IGMP_LISTEN_ALLROUTERS(options) ((options) &= ~PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS)
-#define PIM_IF_DONT_PIM_CAN_DISABLE_JOIN_SUPPRESSION(options)                  \
-       ((options) &= ~PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPPRESSION)
-
 #define PIM_I_am_DR(pim_ifp)                                                   \
        !pim_addr_cmp((pim_ifp)->pim_dr_addr, (pim_ifp)->primary_address)
 #define PIM_I_am_DualActive(pim_ifp) (pim_ifp)->activeactive == true
@@ -93,6 +70,11 @@ struct pim_secondary_addr {
 };
 
 struct pim_interface {
+       bool pim_enable : 1;
+       bool pim_can_disable_join_suppression : 1;
+
+       bool igmp_enable : 1;
+
        uint32_t options; /* bit vector */
        ifindex_t mroute_vif_index;
        struct pim_instance *pim;
index f9fb8cf094daca48da26de3c8ab3149e34c24499..54cd824f9e500b4193a9388e0146098dbdc14de8 100644 (file)
@@ -1155,7 +1155,7 @@ int pim_ifchannel_local_membership_add(struct interface *ifp, pim_sgaddr *sg,
                return 0;
        }
 
-       if (!PIM_IF_TEST_PIM(pim_ifp->options)) {
+       if (!pim_ifp->pim_enable) {
                if (PIM_DEBUG_EVENTS)
                        zlog_debug("%s:%pSG PIM is not configured on this interface %s",
                                   __func__, sg, ifp->name);
@@ -1249,7 +1249,7 @@ void pim_ifchannel_local_membership_del(struct interface *ifp, pim_sgaddr *sg)
        pim_ifp = ifp->info;
        if (!pim_ifp)
                return;
-       if (!PIM_IF_TEST_PIM(pim_ifp->options))
+       if (!pim_ifp->pim_enable)
                return;
 
        orig = ch = pim_ifchannel_find(ifp, sg);
index 13c51b9372b6bdf3261580a9c887e8776ecd60ac..6dea9f38f1fcea434e11d53b73bf30f9b5293e2a 100644 (file)
@@ -255,17 +255,14 @@ static int igmp_sock_open(struct in_addr ifaddr, struct interface *ifp,
        if (fd < 0)
                return -1;
 
-       if (PIM_IF_TEST_IGMP_LISTEN_ALLROUTERS(pim_options)) {
-               if (inet_aton(PIM_ALL_ROUTERS, &group)) {
-                       if (!pim_socket_join(fd, group, ifaddr, ifp->ifindex,
-                                            pim_ifp))
-                               ++join;
-               } else {
-                       zlog_warn(
-                               "%s %s: IGMP socket fd=%d interface %pI4: could not solve %s to group address: errno=%d: %s",
-                               __FILE__, __func__, fd, &ifaddr,
-                               PIM_ALL_ROUTERS, errno, safe_strerror(errno));
-               }
+       if (inet_aton(PIM_ALL_ROUTERS, &group)) {
+               if (!pim_socket_join(fd, group, ifaddr, ifp->ifindex, pim_ifp))
+                       ++join;
+       } else {
+               zlog_warn(
+                       "%s %s: IGMP socket fd=%d interface %pI4: could not solve %s to group address: errno=%d: %s",
+                       __FILE__, __func__, fd, &ifaddr, PIM_ALL_ROUTERS, errno,
+                       safe_strerror(errno));
        }
 
        /*
index 7fe7c0395f0b9ad7451428a2bd899ce4c5372987..0f59f1d61ba2a925ce6b67d4f454197ce1135a80 100644 (file)
@@ -63,8 +63,7 @@ static void pim_if_membership_clear(struct interface *ifp)
        pim_ifp = ifp->info;
        assert(pim_ifp);
 
-       if (PIM_IF_TEST_PIM(pim_ifp->options)
-           && PIM_IF_TEST_IGMP(pim_ifp->options)) {
+       if (pim_ifp->pim_enable && pim_ifp->igmp_enable) {
                return;
        }
 
@@ -90,9 +89,9 @@ static void pim_if_membership_refresh(struct interface *ifp)
        pim_ifp = ifp->info;
        assert(pim_ifp);
 
-       if (!PIM_IF_TEST_PIM(pim_ifp->options))
+       if (!pim_ifp->pim_enable)
                return;
-       if (!PIM_IF_TEST_IGMP(pim_ifp->options))
+       if (!pim_ifp->igmp_enable)
                return;
 
        /*
@@ -143,7 +142,7 @@ static int pim_cmd_interface_add(struct interface *ifp)
        if (!pim_ifp)
                pim_ifp = pim_if_new(ifp, false, true, false, false);
        else
-               PIM_IF_DO_PIM(pim_ifp->options);
+               pim_ifp->pim_enable = true;
 
        pim_if_addr_add_all(ifp);
        pim_if_membership_refresh(ifp);
@@ -159,7 +158,7 @@ static int pim_cmd_interface_delete(struct interface *ifp)
        if (!pim_ifp)
                return 1;
 
-       PIM_IF_DONT_PIM(pim_ifp->options);
+       pim_ifp->pim_enable = false;
 
        pim_if_membership_clear(ifp);
 
@@ -169,7 +168,7 @@ static int pim_cmd_interface_delete(struct interface *ifp)
         */
        pim_sock_delete(ifp, "pim unconfigured on interface");
 
-       if (!PIM_IF_TEST_IGMP(pim_ifp->options)) {
+       if (!pim_ifp->igmp_enable) {
                pim_if_addr_del_all(ifp);
                pim_if_delete(ifp);
        }
@@ -360,8 +359,8 @@ static int pim_cmd_igmp_start(struct interface *ifp)
                pim_ifp = pim_if_new(ifp, true, false, false, false);
                need_startup = 1;
        } else {
-               if (!PIM_IF_TEST_IGMP(pim_ifp->options)) {
-                       PIM_IF_DO_IGMP(pim_ifp->options);
+               if (!pim_ifp->igmp_enable) {
+                       pim_ifp->igmp_enable = true;
                        need_startup = 1;
                }
        }
@@ -2537,13 +2536,13 @@ int lib_interface_gmp_address_family_destroy(struct nb_cb_destroy_args *args)
                if (!pim_ifp)
                        return NB_OK;
 
-               PIM_IF_DONT_IGMP(pim_ifp->options);
+               pim_ifp->igmp_enable = false;
 
                pim_if_membership_clear(ifp);
 
                pim_if_addr_del_all_igmp(ifp);
 
-               if (!PIM_IF_TEST_PIM(pim_ifp->options))
+               if (!pim_ifp->pim_enable)
                        pim_if_delete(ifp);
        }
 
@@ -2594,13 +2593,13 @@ int lib_interface_gmp_address_family_enable_modify(
                        if (!pim_ifp)
                                return NB_ERR_INCONSISTENCY;
 
-                       PIM_IF_DONT_IGMP(pim_ifp->options);
+                       pim_ifp->igmp_enable = false;
 
                        pim_if_membership_clear(ifp);
 
                        pim_if_addr_del_all_igmp(ifp);
 
-                       if (!PIM_IF_TEST_PIM(pim_ifp->options))
+                       if (!pim_ifp->pim_enable)
                                pim_if_delete(ifp);
                }
        }
index 50bbc0fe18f05574835292771e4e2930136c4f9e..1baa5c38ca2027950c368bfcb3a3cf4f401843aa 100644 (file)
@@ -526,11 +526,8 @@ void pim_sock_reset(struct interface *ifp)
                PIM_DEFAULT_PROPAGATION_DELAY_MSEC;
        pim_ifp->pim_override_interval_msec =
                PIM_DEFAULT_OVERRIDE_INTERVAL_MSEC;
-       if (PIM_DEFAULT_CAN_DISABLE_JOIN_SUPPRESSION) {
-               PIM_IF_DO_PIM_CAN_DISABLE_JOIN_SUPPRESSION(pim_ifp->options);
-       } else {
-               PIM_IF_DONT_PIM_CAN_DISABLE_JOIN_SUPPRESSION(pim_ifp->options);
-       }
+       pim_ifp->pim_can_disable_join_suppression =
+               PIM_DEFAULT_CAN_DISABLE_JOIN_SUPPRESSION;
 
        /* neighbors without lan_delay */
        pim_ifp->pim_number_of_nonlandelay_neighbors = 0;
@@ -702,8 +699,7 @@ static int hello_send(struct interface *ifp, uint16_t holdtime)
                        __func__, &qpim_all_pim_routers_addr, ifp->name,
                        holdtime, pim_ifp->pim_propagation_delay_msec,
                        pim_ifp->pim_override_interval_msec,
-                       PIM_IF_TEST_PIM_CAN_DISABLE_JOIN_SUPPRESSION(
-                               pim_ifp->options),
+                       pim_ifp->pim_can_disable_join_suppression,
                        pim_ifp->pim_dr_priority, pim_ifp->pim_generation_id,
                        listcount(ifp->connected));
 
@@ -713,7 +709,7 @@ static int hello_send(struct interface *ifp, uint16_t holdtime)
                pim_ifp->pim_dr_priority, pim_ifp->pim_generation_id,
                pim_ifp->pim_propagation_delay_msec,
                pim_ifp->pim_override_interval_msec,
-               PIM_IF_TEST_PIM_CAN_DISABLE_JOIN_SUPPRESSION(pim_ifp->options));
+               pim_ifp->pim_can_disable_join_suppression);
        if (pim_tlv_size < 0) {
                return -1;
        }
index a0dea63b792ad3b8671e27542956511d7ef24c64..b360181f43a72cc74653b034668c30a9d787441f 100644 (file)
@@ -289,7 +289,7 @@ static int pim_igmp_config_write(struct vty *vty, int writes,
                                 struct pim_interface *pim_ifp)
 {
        /* IF ip igmp */
-       if (PIM_IF_TEST_IGMP(pim_ifp->options)) {
+       if (pim_ifp->igmp_enable) {
                vty_out(vty, " ip igmp\n");
                ++writes;
        }
@@ -361,7 +361,7 @@ int pim_config_write(struct vty *vty, int writes, struct interface *ifp,
 {
        struct pim_interface *pim_ifp = ifp->info;
 
-       if (PIM_IF_TEST_PIM(pim_ifp->options)) {
+       if (pim_ifp->pim_enable) {
                vty_out(vty, " " PIM_AF_NAME " pim\n");
                ++writes;
        }
index 5e55b9f9c8860784e38824007e13d8545270701f..93fdb13a38cc1475b0609c94fc7057d2d5ed5395 100644 (file)
@@ -1137,7 +1137,7 @@ void pim_vxlan_add_term_dev(struct pim_instance *pim,
        /* enable pim on the term ifp */
        pim_ifp = (struct pim_interface *)ifp->info;
        if (pim_ifp) {
-               PIM_IF_DO_PIM(pim_ifp->options);
+               pim_ifp->pim_enable = true;
                /* ifp is already oper up; activate it as a term dev */
                if (pim_ifp->mroute_vif_index >= 0)
                        pim_vxlan_term_oif_update(pim, ifp);
@@ -1165,8 +1165,8 @@ void pim_vxlan_del_term_dev(struct pim_instance *pim)
 
        pim_ifp = (struct pim_interface *)ifp->info;
        if (pim_ifp) {
-               PIM_IF_DONT_PIM(pim_ifp->options);
-               if (!PIM_IF_TEST_IGMP(pim_ifp->options))
+               pim_ifp->pim_enable = false;
+               if (!pim_ifp->igmp_enable)
                        pim_if_delete(ifp);
        }
 }