forked from Mirror/frr
zebra: create zebra_cumulus_mlag module
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>
This commit is contained in:
parent
7d708d3c01
commit
d621815a0e
|
@ -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
|
||||
|
||||
|
|
1
debian/frr.install
vendored
1
debian/frr.install
vendored
|
@ -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
|
||||
|
|
|
@ -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}/*
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
|
|
|
@ -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
|
Loading…
Reference in a new issue