]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: create zebra_cumulus_mlag module
authorDavid Lamparter <equinox@diac24.net>
Wed, 4 Dec 2019 03:18:12 +0000 (04:18 +0100)
committerDavid Lamparter <equinox@diac24.net>
Wed, 11 Dec 2019 10:40:47 +0000 (11:40 +0100)
This is pretty much just to get rid of the HAVE_CUMULUS.  The
hook/module API is as "wtf" as it was before...

Signed-off-by: David Lamparter <equinox@diac24.net>
configure.ac
debian/frr.install
redhat/frr.spec.in
zebra/subdir.am
zebra/zebra_mlag.c
zebra/zebra_mlag.h
zebra/zebra_mlag_private.c
zebra/zebra_mlag_private.h [deleted file]

index 124312b1e8c448bd590fc5443eeee19e588682a8..34c8bb6932f709771d5c6e90e9dc1a1debf7320a 100755 (executable)
@@ -1061,6 +1061,8 @@ FRR_INCLUDES
 
 dnl V6 headers are checked below, after we check for v6
 
+is_linux=false
+
 AC_MSG_CHECKING([which operating system interface to use])
 case "$host_os" in
   sunos* | solaris2*)
@@ -1089,6 +1091,8 @@ case "$host_os" in
     dnl how to fix it but no real progress on implementation
     dnl when they fix it, remove this
     AC_DEFINE([IPV6_MINHOPCOUNT], [73], [Linux ipv6 Min Hop Count])
+
+    is_linux=true
     ;;
   openbsd*)
     AC_MSG_RESULT([OpenBSD])
@@ -1116,6 +1120,7 @@ case "$host_os" in
     ;;
 esac
 AM_CONDITIONAL([SOLARIS], [test "${SOLARIS}" = "solaris"])
+AM_CONDITIONAL([LINUX], [${is_linux}])
 
 AC_SYS_LARGEFILE
 
index 09bddf0fc66672788615c304b80d365b3ff762d1..5917c0da8447957cef99c76dc7c41de407d1d392 100644 (file)
@@ -8,6 +8,7 @@ usr/lib/frr/*.sh
 usr/lib/frr/*d
 usr/lib/frr/watchfrr
 usr/lib/frr/zebra
+usr/lib/*/frr/modules/zebra_cumulus_mlag.so
 usr/lib/*/frr/modules/zebra_irdp.so
 usr/lib/*/frr/modules/zebra_fpm.so
 usr/lib/*/frr/modules/bgpd_bmp.so
index b3f9ac763085dc8157cb5d63fcc008fca53577a8..1a374ba26be85a1abcaa1c2bc52d5616f7a68c88 100644 (file)
@@ -633,6 +633,7 @@ fi
 %if %{with_rpki}
     %{_libdir}/frr/modules/bgpd_rpki.so
 %endif
+%{_libdir}/frr/modules/zebra_cumulus_mlag.so
 %{_libdir}/frr/modules/zebra_irdp.so
 %{_libdir}/frr/modules/bgpd_bmp.so
 %{_bindir}/*
index d0f32d6a14137c65985b9fe242bdfea07d278dba..e3ca01ff73ea69396e0e427cec85cc6799436aa4 100644 (file)
@@ -32,6 +32,9 @@ endif
 if FPM
 module_LTLIBRARIES += zebra/zebra_fpm.la
 endif
+if LINUX
+module_LTLIBRARIES += zebra/zebra_cumulus_mlag.la
+endif
 
 man8 += $(MANBUILD)/zebra.8
 ## endif ZEBRA
@@ -69,7 +72,6 @@ zebra_zebra_SOURCES = \
        zebra/rule_netlink.c \
        zebra/rule_socket.c \
        zebra/zebra_mlag.c \
-       zebra/zebra_mlag_private.c \
        zebra/zebra_l2.c \
        zebra/zebra_memory.c \
        zebra/zebra_dplane.c \
@@ -134,7 +136,6 @@ noinst_HEADERS += \
        zebra/rtadv.h \
        zebra/rule_netlink.h \
        zebra/zebra_mlag.h \
-       zebra/zebra_mlag_private.h \
        zebra/zebra_fpm_private.h \
        zebra/zebra_l2.h \
        zebra/zebra_dplane.h \
@@ -185,3 +186,6 @@ if DEV_BUILD
 zebra_zebra_fpm_la_SOURCES += zebra/zebra_fpm_dt.c
 endif
 endif
+
+zebra_zebra_cumulus_mlag_la_SOURCES = zebra/zebra_mlag_private.c
+zebra_zebra_cumulus_mlag_la_LDFLAGS = -avoid-version -module -shared -export-dynamic
index 1a911e429f66855c940d322e85483742d93af716..7fbc9c118b4db08475345840587abeed8f785424 100644 (file)
@@ -27,7 +27,6 @@
 #include "mlag.h"
 
 #include "zebra/zebra_mlag.h"
-#include "zebra/zebra_mlag_private.h"
 #include "zebra/zebra_router.h"
 #include "zebra/zebra_memory.h"
 #include "zebra/zapi_msg.h"
 #include "zebra/zebra_mlag_clippy.c"
 #endif
 
+DEFINE_HOOK(zebra_mlag_private_write_data,
+           (uint8_t *data, uint32_t len), (data, len))
+DEFINE_HOOK(zebra_mlag_private_monitor_state, (), ())
+DEFINE_HOOK(zebra_mlag_private_open_channel, (), ())
+DEFINE_HOOK(zebra_mlag_private_close_channel, (), ())
+DEFINE_HOOK(zebra_mlag_private_cleanup_data, (), ())
+
 #define ZEBRA_MLAG_METADATA_LEN 4
 #define ZEBRA_MLAG_MSG_BCAST 0xFFFFFFFF
 
@@ -175,7 +181,8 @@ static int zebra_mlag_client_msg_handler(struct thread *event)
                 * write to MCLAGD
                 */
                if (len > 0) {
-                       zebra_mlag_private_write_data(mlag_wr_buffer, len);
+                       hook_call(zebra_mlag_private_write_data,
+                                 mlag_wr_buffer, len);
 
                        /*
                         * If message type is De-register, send a signal to main
@@ -220,7 +227,7 @@ void zebra_mlag_handle_process_state(enum zebra_mlag_state state)
        } else if (state == MLAG_DOWN) {
                zrouter.mlag_info.connected = false;
                zebra_mlag_publish_process_state(NULL, ZEBRA_MLAG_PROCESS_DOWN);
-               zebra_mlag_private_monitor_state();
+               hook_call(zebra_mlag_private_monitor_state);
        }
 }
 
@@ -412,7 +419,7 @@ static int zebra_mlag_terminate_pthread(struct thread *event)
        /*
         * Send Notification to clean private data
         */
-       zebra_mlag_private_cleanup_data();
+       hook_call(zebra_mlag_private_cleanup_data);
        return 0;
 }
 
@@ -470,7 +477,7 @@ void zebra_mlag_client_register(ZAPI_HANDLER_ARGS)
                                "First client, opening the channel with MLAG");
 
                zebra_mlag_spawn_pthread();
-               rc = zebra_mlag_private_open_channel();
+               rc = hook_call(zebra_mlag_private_open_channel);
                if (rc < 0) {
                        /*
                         * For some reason, zebra not able to open the
@@ -530,7 +537,7 @@ void zebra_mlag_client_unregister(ZAPI_HANDLER_ARGS)
                 * signal back to main thread to do the thread cleanup
                 * this was mainly to make sure De-register is posted to MCLAGD.
                 */
-               zebra_mlag_private_close_channel();
+               hook_call(zebra_mlag_private_close_channel);
        }
 
        if (IS_ZEBRA_DEBUG_MLAG)
@@ -627,13 +634,13 @@ DEFPY_HIDDEN(test_mlag, test_mlag_cmd,
                                        zebra_mlag_spawn_pthread();
                                zrouter.mlag_info.clients_interested_cnt++;
                                test_mlag_in_progress = true;
-                               zebra_mlag_private_open_channel();
+                               hook_call(zebra_mlag_private_open_channel);
                        }
                } else {
                        if (test_mlag_in_progress == true) {
                                test_mlag_in_progress = false;
                                zrouter.mlag_info.clients_interested_cnt--;
-                               zebra_mlag_private_close_channel();
+                               hook_call(zebra_mlag_private_close_channel);
                        }
                }
        }
index 6f7ef8319f3ab00d8868d475978a156f6f07840b..1f024516c51026a30c55843ccc5b2a066f6287be 100644 (file)
 #define ZEBRA_MLAG_BUF_LIMIT 2048
 #define ZEBRA_MLAG_LEN_SIZE 4
 
+DECLARE_HOOK(zebra_mlag_private_write_data,
+            (uint8_t *data, uint32_t len), (data, len))
+DECLARE_HOOK(zebra_mlag_private_monitor_state, (), ())
+DECLARE_HOOK(zebra_mlag_private_open_channel, (), ())
+DECLARE_HOOK(zebra_mlag_private_close_channel, (), ())
+DECLARE_HOOK(zebra_mlag_private_cleanup_data, (), ())
+
 extern uint8_t mlag_wr_buffer[ZEBRA_MLAG_BUF_LIMIT];
 extern uint8_t mlag_rd_buffer[ZEBRA_MLAG_BUF_LIMIT];
 extern uint32_t mlag_rd_buf_offset;
index 4df7b6dd114cc746c64149b6a371b77a6014dd81..f7bf920b9c4e51fd5ee09b4fa1eb4a47d48ffa2d 100644 (file)
@@ -36,7 +36,6 @@
 #include "zebra/debug.h"
 #include "zebra/zebra_router.h"
 #include "zebra/zebra_mlag.h"
-#include "zebra/zebra_mlag_private.h"
 
 #include <sys/un.h>
 
@@ -46,8 +45,6 @@
  *
  */
 
-#ifdef HAVE_CUMULUS
-
 static struct thread_master *zmlag_master;
 static int mlag_socket;
 
@@ -57,7 +54,7 @@ static int zebra_mlag_read(struct thread *thread);
 /*
  * Write the data to MLAGD
  */
-int zebra_mlag_private_write_data(uint8_t *data, uint32_t len)
+static int zebra_mlag_private_write_data(uint8_t *data, uint32_t len)
 {
        int rc = 0;
 
@@ -207,13 +204,14 @@ static int zebra_mlag_connect(struct thread *thread)
 /*
  * Currently we are doing polling later we will look for better options
  */
-void zebra_mlag_private_monitor_state(void)
+static int zebra_mlag_private_monitor_state(void)
 {
        thread_add_event(zmlag_master, zebra_mlag_connect, NULL, 0,
                         &zrouter.mlag_info.t_read);
+       return 0;
 }
 
-int zebra_mlag_private_open_channel(void)
+static int zebra_mlag_private_open_channel(void)
 {
        zmlag_master = zrouter.mlag_info.th_master;
 
@@ -242,7 +240,7 @@ int zebra_mlag_private_open_channel(void)
        return 0;
 }
 
-int zebra_mlag_private_close_channel(void)
+static int zebra_mlag_private_close_channel(void)
 {
        if (zmlag_master == NULL)
                return -1;
@@ -263,37 +261,34 @@ int zebra_mlag_private_close_channel(void)
        return 0;
 }
 
-void zebra_mlag_private_cleanup_data(void)
+static int zebra_mlag_private_cleanup_data(void)
 {
        zmlag_master = NULL;
        zrouter.mlag_info.connected = false;
        zrouter.mlag_info.timer_running = false;
 
        close(mlag_socket);
-}
-
-#else  /*HAVE_CUMULUS */
-
-int zebra_mlag_private_write_data(uint8_t *data, uint32_t len)
-{
        return 0;
 }
 
-void zebra_mlag_private_monitor_state(void)
-{
-}
-
-int zebra_mlag_private_open_channel(void)
+static int zebra_mlag_module_init(void)
 {
+       hook_register(zebra_mlag_private_write_data,
+                     zebra_mlag_private_write_data);
+       hook_register(zebra_mlag_private_monitor_state,
+                     zebra_mlag_private_monitor_state);
+       hook_register(zebra_mlag_private_open_channel,
+                     zebra_mlag_private_open_channel);
+       hook_register(zebra_mlag_private_close_channel,
+                     zebra_mlag_private_close_channel);
+       hook_register(zebra_mlag_private_cleanup_data,
+                     zebra_mlag_private_cleanup_data);
        return 0;
 }
 
-int zebra_mlag_private_close_channel(void)
-{
-       return 0;
-}
-
-void zebra_mlag_private_cleanup_data(void)
-{
-}
-#endif /*HAVE_CUMULUS*/
+FRR_MODULE_SETUP(
+       .name = "zebra_cumulus_mlag",
+       .version = FRR_VERSION,
+       .description = "zebra Cumulus MLAG interface",
+       .init = zebra_mlag_module_init,
+)
diff --git a/zebra/zebra_mlag_private.h b/zebra/zebra_mlag_private.h
deleted file mode 100644 (file)
index f7b68e9..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * This is an implementation of MLAG Functionality
- *
- * Module name: Zebra MLAG
- *
- * Author: sathesh Kumar karra <sathk@cumulusnetworks.com>
- *
- * Copyright (C) 2019 Cumulus Networks http://www.cumulusnetworks.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-#ifndef __ZEBRA_MLAG_PRIVATE_H__
-#define __ZEBRA_MLAG_PRIVATE_H__
-
-
-/*
- * all the platform specific API's
- */
-
-int zebra_mlag_private_open_channel(void);
-int zebra_mlag_private_close_channel(void);
-void zebra_mlag_private_monitor_state(void);
-int zebra_mlag_private_write_data(uint8_t *data, uint32_t len);
-void zebra_mlag_private_cleanup_data(void);
-#endif