]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd: move all MSDP code to its own place 17636/head
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Wed, 11 Dec 2024 14:53:36 +0000 (11:53 -0300)
committerRafael Zalamena <rzalamena@opensourcerouting.org>
Wed, 11 Dec 2024 14:58:25 +0000 (11:58 -0300)
Guard MSDP code to compile only on IPv4 and remove all MSDP code from
PIMv6.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
pimd/pim_instance.c
pimd/pim_instance.h
pimd/pim_msdp.c
pimd/pim_msdp.h
pimd/pim_register.c
pimd/pim_rp.c
pimd/pim_upstream.c
pimd/pim_upstream.h

index 9a76b5c92496bc6e40bf99ca83a4453e6d922003..5649e49835f914c232784764254b382dedfacdfb 100644 (file)
@@ -53,7 +53,9 @@ static void pim_instance_terminate(struct pim_instance *pim)
 
        pim_oil_terminate(pim);
 
+#if PIM_IPV == 4
        pim_msdp_exit(pim);
+#endif /* PIM_IPV == 4 */
 
        close(pim->reg_sock);
 
@@ -91,7 +93,9 @@ static struct pim_instance *pim_instance_init(struct vrf *vrf)
        pim->spt.switchover = PIM_SPT_IMMEDIATE;
        pim->spt.plist = NULL;
 
+#if PIM_IPV == 4
        pim_msdp_init(pim, router->master);
+#endif /* PIM_IPV == 4 */
        pim_vxlan_init(pim);
 
        snprintf(hash_name, sizeof(hash_name), "PIM %s RPF Hash", vrf->name);
index dab7ed2698284f018c1efa789aa7060827181498..93acb5e9fd6b3378c806e5ba45e8a7eb3124530d 100644 (file)
@@ -150,7 +150,9 @@ struct pim_instance {
 
        struct rb_pim_oil_head channel_oil_head;
 
+#if PIM_IPV == 4
        struct pim_msdp msdp;
+#endif /* PIM_IPV == 4 */
        struct pim_vxlan_instance vxlan;
 
        struct pim_autorp *autorp;
@@ -225,7 +227,4 @@ extern struct pim_router *router;
 
 struct pim_instance *pim_get_pim_instance(vrf_id_t vrf_id);
 
-extern bool pim_msdp_log_neighbor_events(const struct pim_instance *pim);
-extern bool pim_msdp_log_sa_events(const struct pim_instance *pim);
-
 #endif
index 1a1e1b723707c665762743a00bc9dcae18c1dddf..f5260c68cab580e6ff7e011d6d0714f3741e1c9e 100644 (file)
@@ -31,8 +31,6 @@
 #include "pim_msdp_packet.h"
 #include "pim_msdp_socket.h"
 
-// struct pim_msdp pim_msdp, *msdp = &pim_msdp;
-
 static void pim_msdp_peer_listen(struct pim_msdp_peer *mp);
 static void pim_msdp_peer_cr_timer_setup(struct pim_msdp_peer *mp, bool start);
 static void pim_msdp_peer_ka_timer_setup(struct pim_msdp_peer *mp, bool start);
@@ -1468,6 +1466,25 @@ struct pim_msdp_mg_mbr *pim_msdp_mg_mbr_add(struct pim_instance *pim,
        return mbr;
 }
 
+/* MSDP on RP needs to know if a source is registerable to this RP */
+static void pim_upstream_msdp_reg_timer(struct event *t)
+{
+       struct pim_upstream *up = EVENT_ARG(t);
+       struct pim_instance *pim = up->channel_oil->pim;
+
+       /* source is no longer active - pull the SA from MSDP's cache */
+       pim_msdp_sa_local_del(pim, &up->sg);
+}
+
+void pim_upstream_msdp_reg_timer_start(struct pim_upstream *up)
+{
+       EVENT_OFF(up->t_msdp_reg_timer);
+       event_add_timer(router->master, pim_upstream_msdp_reg_timer, up, PIM_MSDP_REG_RXED_PERIOD,
+                       &up->t_msdp_reg_timer);
+
+       pim_msdp_sa_local_update(up);
+}
+
 void pim_msdp_shutdown(struct pim_instance *pim, bool state)
 {
        struct pim_msdp_peer *peer;
index 15ed685b3c6a9d42d2e770d0001513cdead99961..7e0e5c1218254c262136d808914e23d22259abd6 100644 (file)
@@ -235,8 +235,6 @@ struct pim_msdp {
 #define PIM_MSDP_PEER_READ_OFF(mp) event_cancel(&mp->t_read)
 #define PIM_MSDP_PEER_WRITE_OFF(mp) event_cancel(&mp->t_write)
 
-#if PIM_IPV != 6
-// struct pim_msdp *msdp;
 struct pim_instance;
 void pim_msdp_init(struct pim_instance *pim, struct event_loop *master);
 void pim_msdp_exit(struct pim_instance *pim);
@@ -263,6 +261,8 @@ void pim_msdp_up_del(struct pim_instance *pim, pim_sgaddr *sg);
 enum pim_msdp_err pim_msdp_mg_del(struct pim_instance *pim,
                                  const char *mesh_group_name);
 
+extern void pim_upstream_msdp_reg_timer_start(struct pim_upstream *up);
+
 /**
  * Allocates a new mesh group data structure under PIM instance.
  */
@@ -341,53 +341,7 @@ void pim_msdp_peer_restart(struct pim_msdp_peer *mp);
  */
 void pim_msdp_shutdown(struct pim_instance *pim, bool state);
 
-#else /* PIM_IPV == 6 */
-static inline void pim_msdp_init(struct pim_instance *pim,
-                                struct event_loop *master)
-{
-}
-
-static inline void pim_msdp_exit(struct pim_instance *pim)
-{
-}
-
-static inline void pim_msdp_i_am_rp_changed(struct pim_instance *pim)
-{
-}
-
-static inline void pim_msdp_up_join_state_changed(struct pim_instance *pim,
-                                                 struct pim_upstream *xg_up)
-{
-}
-
-static inline void pim_msdp_up_del(struct pim_instance *pim, pim_sgaddr *sg)
-{
-}
-
-static inline void pim_msdp_sa_local_update(struct pim_upstream *up)
-{
-}
-
-static inline void pim_msdp_sa_local_del(struct pim_instance *pim,
-                                        pim_sgaddr *sg)
-{
-}
-
-static inline int pim_msdp_config_write(struct pim_instance *pim,
-                                       struct vty *vty)
-{
-       return 0;
-}
-
-static inline bool pim_msdp_peer_config_write(struct vty *vty,
-                                             struct pim_instance *pim)
-{
-       return false;
-}
-
-static inline void pim_msdp_shutdown(struct pim_instance *pim, bool state)
-{
-}
-#endif /* PIM_IPV == 6 */
+extern bool pim_msdp_log_neighbor_events(const struct pim_instance *pim);
+extern bool pim_msdp_log_sa_events(const struct pim_instance *pim);
 
 #endif
index b149b5a2a97c236ecd45167aebf00ec60a0388b5..f776a59b7fd8dc76be8d5573b4f3244baab84ba7 100644 (file)
@@ -709,7 +709,10 @@ int pim_register_recv(struct interface *ifp, pim_addr dest_addr,
                        // inherited_olist(S,G,rpt)
                        // This is taken care of by the kernel for us
                }
+
+#if PIM_IPV == 4
                pim_upstream_msdp_reg_timer_start(upstream);
+#endif /* PIM_IPV == 4 */
        } else {
                if (PIM_DEBUG_PIM_REG) {
                        if (!i_am_rp)
index e6de991a1435bbeab45f5e227adbec6df30a19a7..6266f42591e36a0ffc8d0049ba242ad5f602215c 100644 (file)
@@ -343,7 +343,9 @@ struct rp_info *pim_rp_find_match_group(struct pim_instance *pim,
  */
 void pim_rp_refresh_group_to_rp_mapping(struct pim_instance *pim)
 {
+#if PIM_IPV == 4
        pim_msdp_i_am_rp_changed(pim);
+#endif /* PIM_IPV == 4 */
        pim_upstream_reeval_use_rpt(pim);
 }
 
@@ -1030,7 +1032,9 @@ void pim_rp_check_on_if_add(struct pim_interface *pim_ifp)
        }
 
        if (i_am_rp_changed) {
+#if PIM_IPV == 4
                pim_msdp_i_am_rp_changed(pim);
+#endif /* PIM_IPV == 4 */
                pim_upstream_reeval_use_rpt(pim);
        }
 }
@@ -1072,7 +1076,9 @@ void pim_i_am_rp_re_evaluate(struct pim_instance *pim)
        }
 
        if (i_am_rp_changed) {
+#if PIM_IPV == 4
                pim_msdp_i_am_rp_changed(pim);
+#endif /* PIM_IPV == 4 */
                pim_upstream_reeval_use_rpt(pim);
        }
 }
index 7417f311377f11deb9733f8a27ff9f8e8a4b632d..8aa61b687dbc557c98ec6c79226540c573e5f166 100644 (file)
@@ -178,7 +178,9 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim,
 {
        struct listnode *node, *nnode;
        struct pim_ifchannel *ch;
+#if PIM_IPV == 4
        bool notify_msdp = false;
+#endif /* PIM_IPV == 4 */
 
        if (PIM_DEBUG_PIM_TRACE)
                zlog_debug(
@@ -206,12 +208,14 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim,
        if (up->join_state == PIM_UPSTREAM_JOINED) {
                pim_jp_agg_single_upstream_send(&up->rpf, up, 0);
 
+#if PIM_IPV == 4
                if (pim_addr_is_any(up->sg.src)) {
                        /* if a (*, G) entry in the joined state is being
                         * deleted we
                         * need to notify MSDP */
                        notify_msdp = true;
                }
+#endif /* PIM_IPV == 4 */
        }
 
        join_timer_stop(up);
@@ -221,7 +225,9 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim,
        if (!pim_addr_is_any(up->sg.src)) {
                if (pim->upstream_sg_wheel)
                        wheel_remove_item(pim->upstream_sg_wheel, up);
+#if PIM_IPV == 4
                notify_msdp = true;
+#endif /* PIM_IPV == 4 */
        }
 
        pim_mroute_del(up->channel_oil, __func__);
@@ -241,9 +247,11 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim,
 
        rb_pim_upstream_del(&pim->upstream_head, up);
 
+#if PIM_IPV == 4
        if (notify_msdp) {
                pim_msdp_up_del(pim, &up->sg);
        }
+#endif /* PIM_IPV == 4 */
 
        /* When RP gets deleted, pim_rp_del() deregister addr with Zebra NHT
         * and assign up->upstream_addr as INADDR_ANY.
@@ -723,7 +731,9 @@ void pim_upstream_switch(struct pim_instance *pim, struct pim_upstream *up,
                if (old_state != PIM_UPSTREAM_JOINED) {
                        int old_fhr = PIM_UPSTREAM_FLAG_TEST_FHR(up->flags);
 
+#if PIM_IPV == 4
                        pim_msdp_up_join_state_changed(pim, up);
+#endif /* PIM_IPV == 4 */
                        if (pim_upstream_could_register(up)) {
                                PIM_UPSTREAM_FLAG_SET_FHR(up->flags);
                                if (!old_fhr
@@ -753,8 +763,10 @@ void pim_upstream_switch(struct pim_instance *pim, struct pim_upstream *up,
                if (!pim_addr_is_any(up->sg.src))
                        up->sptbit = PIM_UPSTREAM_SPTBIT_FALSE;
 
+#if PIM_IPV == 4
                if (old_state == PIM_UPSTREAM_JOINED)
                        pim_msdp_up_join_state_changed(pim, up);
+#endif /* PIM_IPV == 4 */
 
                if (old_state != new_state) {
                        old_use_rpt =
@@ -1424,8 +1436,10 @@ struct pim_upstream *pim_upstream_keep_alive_timer_proc(
                 */
        }
 
+#if PIM_IPV == 4
        /* source is no longer active - pull the SA from MSDP's cache */
        pim_msdp_sa_local_del(pim, &up->sg);
+#endif /* PIM_IPV == 4 */
 
        /* JoinDesired can change when KAT is started or stopped */
        pim_upstream_update_join_desired(pim, up);
@@ -1493,32 +1507,15 @@ void pim_upstream_keep_alive_timer_start(struct pim_upstream *up, uint32_t time)
        event_add_timer(router->master, pim_upstream_keep_alive_timer, up, time,
                        &up->t_ka_timer);
 
+#if PIM_IPV == 4
        /* any time keepalive is started against a SG we will have to
         * re-evaluate our active source database */
        pim_msdp_sa_local_update(up);
+#endif /* PIM_IPV == 4 */
        /* JoinDesired can change when KAT is started or stopped */
        pim_upstream_update_join_desired(up->pim, up);
 }
 
-/* MSDP on RP needs to know if a source is registerable to this RP */
-static void pim_upstream_msdp_reg_timer(struct event *t)
-{
-       struct pim_upstream *up = EVENT_ARG(t);
-       struct pim_instance *pim = up->channel_oil->pim;
-
-       /* source is no longer active - pull the SA from MSDP's cache */
-       pim_msdp_sa_local_del(pim, &up->sg);
-}
-
-void pim_upstream_msdp_reg_timer_start(struct pim_upstream *up)
-{
-       EVENT_OFF(up->t_msdp_reg_timer);
-       event_add_timer(router->master, pim_upstream_msdp_reg_timer, up,
-                       PIM_MSDP_REG_RXED_PERIOD, &up->t_msdp_reg_timer);
-
-       pim_msdp_sa_local_update(up);
-}
-
 /*
  * 4.2.1 Last-Hop Switchover to the SPT
  *
index 8b4a35be398cfc0c0805404addeee20599106312..1d4b2128a8f7f080d86c1d3779f0dfb5665c82f3 100644 (file)
@@ -350,7 +350,6 @@ int pim_upstream_inherited_olist(struct pim_instance *pim,
 int pim_upstream_empty_inherited_olist(struct pim_upstream *up);
 
 void pim_upstream_find_new_rpf(struct pim_instance *pim);
-void pim_upstream_msdp_reg_timer_start(struct pim_upstream *up);
 
 void pim_upstream_init(struct pim_instance *pim);
 void pim_upstream_terminate(struct pim_instance *pim);