Skip to content

Commit

Permalink
zebra: create zebra_cumulus_mlag module
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
eqvinox committed Dec 11, 2019
1 parent 7d708d3 commit d621815
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 75 deletions.
5 changes: 5 additions & 0 deletions configure.ac
Expand Up @@ -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*)
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -1116,6 +1120,7 @@ case "$host_os" in
;;
esac
AM_CONDITIONAL([SOLARIS], [test "${SOLARIS}" = "solaris"])
AM_CONDITIONAL([LINUX], [${is_linux}])

AC_SYS_LARGEFILE

Expand Down
1 change: 1 addition & 0 deletions debian/frr.install
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions redhat/frr.spec.in
Expand Up @@ -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}/*
Expand Down
8 changes: 6 additions & 2 deletions zebra/subdir.am
Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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
23 changes: 15 additions & 8 deletions zebra/zebra_mlag.c
Expand Up @@ -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"
Expand All @@ -37,6 +36,13 @@
#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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions zebra/zebra_mlag.h
Expand Up @@ -33,6 +33,13 @@
#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;
Expand Down
51 changes: 23 additions & 28 deletions zebra/zebra_mlag_private.c
Expand Up @@ -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>

Expand All @@ -46,8 +45,6 @@
*
*/

#ifdef HAVE_CUMULUS

static struct thread_master *zmlag_master;
static int mlag_socket;

Expand All @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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,
)
37 changes: 0 additions & 37 deletions zebra/zebra_mlag_private.h

This file was deleted.

0 comments on commit d621815

Please sign in to comment.