]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pim6d: get into a kinda-working state wrt. zebra
authorDavid Lamparter <equinox@opensourcerouting.org>
Fri, 21 Jan 2022 15:42:03 +0000 (16:42 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Wed, 16 Feb 2022 15:40:56 +0000 (16:40 +0100)
Fix up just enough to make us not operate in complete darkness.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
pimd/pim6_main.c
pimd/pim_iface.c
pimd/pim_mroute.c
pimd/pim_ssm.c
pimd/pim_zebra.c

index 3d8ebd0d8665ef74684dbf2ba2b4a5c488f4c0fc..a6cfe7682cdc4f49e35dd3fece3e046662b3f156 100644 (file)
@@ -183,8 +183,8 @@ int main(int argc, char **argv, char **envp)
        /* TODO PIM6: next line is temporary since pim_cmd_init is disabled */
        if_cmd_init(NULL);
 
-#if 0
        pim_zebra_init();
+#if 0
        pim_bfd_init();
        pim_mlag_init();
 
index cf503717120f3b9ef910afc6a5a4fbc530598502..3e24e696396e4047850abd9f197780ca50593178 100644 (file)
@@ -85,6 +85,7 @@ static void pim_sec_addr_free(struct pim_secondary_addr *sec_addr)
        XFREE(MTYPE_PIM_SEC_ADDR, sec_addr);
 }
 
+__attribute__((unused))
 static int pim_sec_addr_comp(const void *p1, const void *p2)
 {
        const struct pim_secondary_addr *sec1 = p1;
@@ -126,6 +127,7 @@ struct pim_interface *pim_if_new(struct interface *ifp, bool igmp, bool pim,
        pim_ifp->pim = ifp->vrf->info;
        pim_ifp->mroute_vif_index = -1;
 
+#if PIM_IPV == 4
        pim_ifp->igmp_version = IGMP_DEFAULT_VERSION;
        pim_ifp->gm_default_robustness_variable =
                IGMP_DEFAULT_ROBUSTNESS_VARIABLE;
@@ -187,6 +189,7 @@ struct pim_interface *pim_if_new(struct interface *ifp, bool igmp, bool pim,
        pim_sock_reset(ifp);
 
        pim_if_add_vif(ifp, ispimreg, is_vxlan_term);
+#endif
        pim_ifp->pim->mcast_if_count++;
 
        return pim_ifp;
@@ -195,12 +198,15 @@ struct pim_interface *pim_if_new(struct interface *ifp, bool igmp, bool pim,
 void pim_if_delete(struct interface *ifp)
 {
        struct pim_interface *pim_ifp;
-       struct pim_ifchannel *ch;
 
        assert(ifp);
        pim_ifp = ifp->info;
        assert(pim_ifp);
 
+       pim_ifp->pim->mcast_if_count--;
+#if PIM_IPV == 4
+       struct pim_ifchannel *ch;
+
        if (pim_ifp->gm_join_list) {
                pim_if_igmp_join_del_all(ifp);
        }
@@ -211,7 +217,6 @@ void pim_if_delete(struct interface *ifp)
        pim_neighbor_delete_all(ifp, "Interface removed from configuration");
 
        pim_if_del_vif(ifp);
-       pim_ifp->pim->mcast_if_count--;
 
        pim_igmp_if_fini(pim_ifp);
 
@@ -228,6 +233,7 @@ void pim_if_delete(struct interface *ifp)
        }
 
        XFREE(MTYPE_PIM_INTERFACE, pim_ifp);
+#endif
 
        ifp->info = NULL;
 }
@@ -496,7 +502,6 @@ void pim_if_addr_add(struct connected *ifc)
 {
        struct pim_interface *pim_ifp;
        struct interface *ifp;
-       struct in_addr ifaddr;
        bool vxlan_term;
 
        assert(ifc);
@@ -517,13 +522,14 @@ void pim_if_addr_add(struct connected *ifc)
                                   ? "secondary"
                                   : "primary");
 
-       ifaddr = ifc->address->u.prefix4;
-
        detect_address_change(ifp, 0, __func__);
 
        // if (ifc->address->family != AF_INET)
        //  return;
 
+#if PIM_IPV == 4
+       struct in_addr ifaddr = ifc->address->u.prefix4;
+
        if (PIM_IF_TEST_IGMP(pim_ifp->options)) {
                struct gm_sock *igmp;
 
@@ -589,6 +595,7 @@ void pim_if_addr_add(struct connected *ifc)
                                          true);
                }
        } /* igmp mtrace only */
+#endif
 
        if (PIM_IF_TEST_PIM(pim_ifp->options)) {
 
@@ -640,6 +647,7 @@ void pim_if_addr_add(struct connected *ifc)
 
 static void pim_if_addr_del_igmp(struct connected *ifc)
 {
+#if PIM_IPV == 4
        struct pim_interface *pim_ifp = ifc->ifp->info;
        struct gm_sock *igmp;
        struct in_addr ifaddr;
@@ -662,6 +670,7 @@ static void pim_if_addr_del_igmp(struct connected *ifc)
                /* if addr found, del IGMP socket */
                igmp_sock_delete(igmp);
        }
+#endif
 }
 
 static void pim_if_addr_del_pim(struct connected *ifc)
@@ -1341,6 +1350,7 @@ int pim_if_igmp_join_del(struct interface *ifp, struct in_addr group_addr,
        return 0;
 }
 
+__attribute__((unused))
 static void pim_if_igmp_join_del_all(struct interface *ifp)
 {
        struct pim_interface *pim_ifp;
@@ -1548,6 +1558,7 @@ static int pim_ifp_create(struct interface *ifp)
                 */
                if (pim_ifp)
                        pim_ifp->pim = pim;
+#if PIM_IPV == 4
                pim_if_addr_add_all(ifp);
 
                /*
@@ -1559,8 +1570,10 @@ static int pim_ifp_create(struct interface *ifp)
                 * this is a no-op if it's already been done.
                 */
                pim_if_create_pimreg(pim);
+#endif
        }
 
+#if PIM_IPV == 4
        /*
         * If we are a vrf device that is up, open up the pim_socket for
         * listening
@@ -1588,6 +1601,7 @@ static int pim_ifp_create(struct interface *ifp)
                                "%s: Cannot enable pim on %s. MAXVIFS(%d) reached. Deleting and readding the vxlan termimation device after unconfiguring pim from other interfaces may succeed.",
                                __func__, ifp->name, MAXVIFS);
        }
+#endif
 
        return 0;
 }
@@ -1596,7 +1610,6 @@ static int pim_ifp_up(struct interface *ifp)
 {
        struct pim_interface *pim_ifp;
        struct pim_instance *pim;
-       uint32_t table_id;
 
        if (PIM_DEBUG_ZEBRA) {
                zlog_debug(
@@ -1617,6 +1630,9 @@ static int pim_ifp_up(struct interface *ifp)
        if (pim_ifp)
                pim_ifp->pim = pim;
 
+#if PIM_IPV == 4
+       uint32_t table_id;
+
        /*
          pim_if_addr_add_all() suffices for bringing up both IGMP and
          PIM
@@ -1645,6 +1661,7 @@ static int pim_ifp_up(struct interface *ifp)
                        }
                }
        }
+#endif
        return 0;
 }
 
@@ -1658,6 +1675,7 @@ static int pim_ifp_down(struct interface *ifp)
                        ifp->mtu, if_is_operative(ifp));
        }
 
+#if PIM_IPV == 4
        if (!if_is_operative(ifp)) {
                pim_ifchannel_delete_all(ifp);
                /*
@@ -1680,14 +1698,13 @@ static int pim_ifp_down(struct interface *ifp)
                pim_if_del_vif(ifp);
                pim_ifstat_reset(ifp);
        }
+#endif
 
        return 0;
 }
 
 static int pim_ifp_destroy(struct interface *ifp)
 {
-       struct pim_instance *pim;
-
        if (PIM_DEBUG_ZEBRA) {
                zlog_debug(
                        "%s: %s index %d vrf %s(%u) flags %ld metric %d mtu %d operative %d",
@@ -1696,12 +1713,16 @@ static int pim_ifp_destroy(struct interface *ifp)
                        ifp->mtu, if_is_operative(ifp));
        }
 
+#if PIM_IPV == 4
+       struct pim_instance *pim;
+
        if (!if_is_operative(ifp))
                pim_if_addr_del_all(ifp);
 
        pim = ifp->vrf->info;
        if (pim && pim->vxlan.term_if == ifp)
                pim_vxlan_del_term_dev(pim);
+#endif
 
        return 0;
 }
index 2fabd3d1b1d0b4883d0e80f80c1e2636aac93e54..26ca0e2ceedf36011401c7ffffc31f7373e3f28d 100644 (file)
@@ -581,12 +581,8 @@ static int pim_mroute_msg(struct pim_instance *pim, const char *buf,
                          int buf_size, ifindex_t ifindex)
 {
        struct interface *ifp;
-       struct pim_interface *pim_ifp;
        const struct ip *ip_hdr;
        const struct igmpmsg *msg;
-       struct in_addr ifaddr;
-       struct gm_sock *igmp;
-       const struct prefix *connected_src;
 
        if (buf_size < (int)sizeof(struct ip))
                return 0;
@@ -594,6 +590,11 @@ static int pim_mroute_msg(struct pim_instance *pim, const char *buf,
        ip_hdr = (const struct ip *)buf;
 
        if (ip_hdr->ip_p == IPPROTO_IGMP) {
+#if PIM_IPV == 4
+               struct pim_interface *pim_ifp;
+               struct in_addr ifaddr;
+               struct gm_sock *igmp;
+               const struct prefix *connected_src;
 
                /* We have the IP packet but we do not know which interface this
                 * packet was
@@ -633,6 +634,7 @@ static int pim_mroute_msg(struct pim_instance *pim, const char *buf,
                        zlog_debug("No IGMP socket on interface: %s with connected source: %pFX",
                                   ifp->name, connected_src);
                }
+#endif
        } else if (ip_hdr->ip_p) {
                if (PIM_DEBUG_MROUTE_DETAIL) {
                        zlog_debug(
index 45aac7756a03ce3a50f83b6a33196629d578c186..688d38c84c833a4740997ca4b1c9f46ec8e992c1 100644 (file)
@@ -32,6 +32,7 @@
 
 static void pim_ssm_range_reevaluate(struct pim_instance *pim)
 {
+#if PIM_IPV == 4
        /* 1. Setup register state for (S,G) entries if G has changed from SSM
         * to
         *    ASM.
@@ -50,6 +51,7 @@ static void pim_ssm_range_reevaluate(struct pim_instance *pim)
         */
        pim_upstream_register_reevaluate(pim);
        igmp_source_forward_reevaluate_all(pim);
+#endif
 }
 
 void pim_ssm_prefix_list_update(struct pim_instance *pim,
index 422c612029c2a9ef450deafb1a18f2b34b566374..a0eb602f2e0c82a243b30e03d3da7590a7dd36bd 100644 (file)
@@ -55,6 +55,7 @@ struct zclient *zclient;
 
 
 /* Router-id update message from zebra. */
+__attribute__((unused))
 static int pim_router_id_update_zebra(ZAPI_CALLBACK_ARGS)
 {
        struct prefix router_id;
@@ -64,6 +65,7 @@ static int pim_router_id_update_zebra(ZAPI_CALLBACK_ARGS)
        return 0;
 }
 
+__attribute__((unused))
 static int pim_zebra_interface_vrf_update(ZAPI_CALLBACK_ARGS)
 {
        struct interface *ifp;
@@ -112,7 +114,6 @@ static int pim_zebra_if_address_add(ZAPI_CALLBACK_ARGS)
        struct connected *c;
        struct prefix *p;
        struct pim_interface *pim_ifp;
-       struct pim_instance *pim;
 
        /*
          zebra api notifies address adds/dels events by using the same call
@@ -141,6 +142,7 @@ static int pim_zebra_if_address_add(ZAPI_CALLBACK_ARGS)
 #endif
        }
 
+#if PIM_IPV == 4
        if (p->family != PIM_AF)
                SET_FLAG(c->flags, ZEBRA_IFA_SECONDARY);
        else if (!CHECK_FLAG(c->flags, ZEBRA_IFA_SECONDARY)) {
@@ -159,6 +161,8 @@ static int pim_zebra_if_address_add(ZAPI_CALLBACK_ARGS)
 
        pim_if_addr_add(c);
        if (pim_ifp) {
+               struct pim_instance *pim;
+
                pim = pim_get_pim_instance(vrf_id);
                pim_ifp->pim = pim;
 
@@ -174,7 +178,10 @@ static int pim_zebra_if_address_add(ZAPI_CALLBACK_ARGS)
                                pim_if_addr_add_all(ifp);
                }
        }
-
+#else /* PIM_IPV != 4 */
+       /* unused - for now */
+       (void)pim_ifp;
+#endif
        return 0;
 }
 
@@ -183,11 +190,9 @@ static int pim_zebra_if_address_del(ZAPI_CALLBACK_ARGS)
        struct connected *c;
        struct prefix *p;
        struct vrf *vrf = vrf_lookup_by_id(vrf_id);
-       struct pim_instance *pim;
 
        if (!vrf)
                return 0;
-       pim = vrf->info;
 
        /*
          zebra api notifies address adds/dels events by using the same call
@@ -202,24 +207,29 @@ static int pim_zebra_if_address_del(ZAPI_CALLBACK_ARGS)
                return 0;
 
        p = c->address;
-       if (p->family == AF_INET) {
-               if (PIM_DEBUG_ZEBRA) {
-                       zlog_debug(
-                               "%s: %s(%u) disconnected IP address %pFX flags %u %s",
-                               __func__, c->ifp->name, vrf_id, p, c->flags,
-                               CHECK_FLAG(c->flags, ZEBRA_IFA_SECONDARY)
-                                       ? "secondary"
-                                       : "primary");
 
+       if (PIM_DEBUG_ZEBRA) {
+               zlog_debug(
+                       "%s: %s(%u) disconnected IP address %pFX flags %u %s",
+                       __func__, c->ifp->name, vrf_id, p, c->flags,
+                       CHECK_FLAG(c->flags, ZEBRA_IFA_SECONDARY)
+                               ? "secondary"
+                               : "primary");
 #ifdef PIM_DEBUG_IFADDR_DUMP
-                       dump_if_address(c->ifp);
+               dump_if_address(c->ifp);
 #endif
-               }
+       }
 
+#if PIM_IPV == 4
+       if (p->family == AF_INET) {
+               struct pim_instance *pim;
+
+               pim = vrf->info;
                pim_if_addr_del(c, 0);
                pim_rp_setup(pim);
                pim_i_am_rp_re_evaluate(pim);
        }
+#endif
 
        connected_free(&c);
        return 0;
@@ -325,6 +335,7 @@ void pim_zebra_upstream_rpf_changed(struct pim_instance *pim,
        pim_upstream_update_join_desired(pim, up);
 }
 
+__attribute__((unused))
 static int pim_zebra_vxlan_sg_proc(ZAPI_CALLBACK_ARGS)
 {
        struct stream *s;
@@ -354,6 +365,7 @@ static int pim_zebra_vxlan_sg_proc(ZAPI_CALLBACK_ARGS)
        return 0;
 }
 
+__attribute__((unused))
 static void pim_zebra_vxlan_replay(void)
 {
        struct stream *s = NULL;
@@ -422,13 +434,17 @@ void sched_rpf_cache_refresh(struct pim_instance *pim)
 
 static void pim_zebra_connected(struct zclient *zclient)
 {
+#if PIM_IPV == 4
        /* Send the client registration */
        bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER, router->vrf_id);
+#endif
 
        zclient_send_reg_requests(zclient, router->vrf_id);
 
+#if PIM_IPV == 4
        /* request for VxLAN BUM group addresses */
        pim_zebra_vxlan_replay();
+#endif
 }
 
 static void pim_zebra_capabilities(struct zclient_capabilities *cap)
@@ -437,9 +453,10 @@ static void pim_zebra_capabilities(struct zclient_capabilities *cap)
 }
 
 static zclient_handler *const pim_handlers[] = {
-       [ZEBRA_ROUTER_ID_UPDATE] = pim_router_id_update_zebra,
        [ZEBRA_INTERFACE_ADDRESS_ADD] = pim_zebra_if_address_add,
        [ZEBRA_INTERFACE_ADDRESS_DELETE] = pim_zebra_if_address_del,
+#if PIM_IPV == 4
+       [ZEBRA_ROUTER_ID_UPDATE] = pim_router_id_update_zebra,
        [ZEBRA_INTERFACE_VRF_UPDATE] = pim_zebra_interface_vrf_update,
        [ZEBRA_NEXTHOP_UPDATE] = pim_parse_nexthop_update,
 
@@ -449,6 +466,7 @@ static zclient_handler *const pim_handlers[] = {
        [ZEBRA_MLAG_PROCESS_UP] = pim_zebra_mlag_process_up,
        [ZEBRA_MLAG_PROCESS_DOWN] = pim_zebra_mlag_process_down,
        [ZEBRA_MLAG_FORWARD_MSG] = pim_zebra_mlag_handle_msg,
+#endif
 };
 
 void pim_zebra_init(void)