#include "mlag.h"
#include "zebra/zebra_mlag.h"
-#include "zebra/zebra_mlag_private.h"
+#include "zebra/zebra_mlag_vty.h"
#include "zebra/zebra_router.h"
#include "zebra/zebra_memory.h"
#include "zebra/zapi_msg.h"
#include "zebra/debug.h"
-#ifndef VTYSH_EXTRACT_PL
-#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
* 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
} 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);
}
}
/*
* Send Notification to clean private data
*/
- zebra_mlag_private_cleanup_data();
+ hook_call(zebra_mlag_private_cleanup_data);
return 0;
}
"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
* 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)
return zrouter.mlag_info.role;
}
-DEFUN_HIDDEN (show_mlag,
- show_mlag_cmd,
- "show zebra mlag",
- SHOW_STR
- ZEBRA_STR
- "The mlag role on this machine\n")
-{
- char buf[MLAG_ROLE_STRSIZE];
-
- vty_out(vty, "MLag is configured to: %s\n",
- mlag_role2str(zrouter.mlag_info.role, buf, sizeof(buf)));
-
- return CMD_SUCCESS;
-}
-
-DEFPY_HIDDEN(test_mlag, test_mlag_cmd,
- "test zebra mlag <none$none|primary$primary|secondary$secondary>",
- "Test code\n"
- ZEBRA_STR
- "Modify the Mlag state\n"
- "Mlag is not setup on the machine\n"
- "Mlag is setup to be primary\n"
- "Mlag is setup to be the secondary\n")
+int32_t zebra_mlag_test_mlag_internal(const char *none, const char *primary,
+ const char *secondary)
{
enum mlag_role orig = zrouter.mlag_info.role;
char buf1[MLAG_ROLE_STRSIZE], buf2[MLAG_ROLE_STRSIZE];
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);
}
}
}
void zebra_mlag_init(void)
{
- install_element(VIEW_NODE, &show_mlag_cmd);
- install_element(ENABLE_NODE, &test_mlag_cmd);
+ zebra_mlag_vty_init();
/*
* Intialiaze the MLAG Global variables
* ProtoBuf Encoding APIs
*/
-#ifdef HAVE_PROTOBUF
+#ifdef HAVE_PROTOBUF_VERSION_3
DEFINE_MTYPE_STATIC(ZEBRA, MLAG_PBUF, "ZEBRA MLAG PROTOBUF")