+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* This is an implementation of MLAG Functionality
*
* 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
*/
#include "zebra.h"
#include "hook.h"
#include "module.h"
-#include "thread.h"
+#include "frrevent.h"
#include "frr_pthread.h"
#include "libfrr.h"
-#include "version.h"
+#include "lib/version.h"
#include "network.h"
#include "lib/stream.h"
*
*/
-static struct thread_master *zmlag_master;
+static struct event_loop *zmlag_master;
static int mlag_socket;
-static int zebra_mlag_connect(struct thread *thread);
-static int zebra_mlag_read(struct thread *thread);
+static void zebra_mlag_connect(struct event *thread);
+static void zebra_mlag_read(struct event *thread);
/*
* Write the data to MLAGD
static void zebra_mlag_sched_read(void)
{
- thread_add_read(zmlag_master, zebra_mlag_read, NULL, mlag_socket,
- &zrouter.mlag_info.t_read);
+ event_add_read(zmlag_master, zebra_mlag_read, NULL, mlag_socket,
+ &zrouter.mlag_info.t_read);
}
-static int zebra_mlag_read(struct thread *thread)
+static void zebra_mlag_read(struct event *thread)
{
static uint32_t mlag_rd_buf_offset;
uint32_t *msglen;
mlag_socket);
close(mlag_socket);
zebra_mlag_handle_process_state(MLAG_DOWN);
- return -1;
+ return;
}
mlag_rd_buf_offset += data_len;
if (data_len != (ssize_t)(ZEBRA_MLAG_LEN_SIZE - curr_len)) {
/* Try again later */
zebra_mlag_sched_read();
- return 0;
+ return;
}
curr_len = ZEBRA_MLAG_LEN_SIZE;
}
mlag_socket);
close(mlag_socket);
zebra_mlag_handle_process_state(MLAG_DOWN);
- return -1;
+ return;
}
mlag_rd_buf_offset += data_len;
if (data_len != (ssize_t)(tot_len - curr_len)) {
/* Try again later */
zebra_mlag_sched_read();
- return 0;
+ return;
}
}
zebra_mlag_reset_read_buffer();
mlag_rd_buf_offset = 0;
zebra_mlag_sched_read();
- return 0;
}
-static int zebra_mlag_connect(struct thread *thread)
+static void zebra_mlag_connect(struct event *thread)
{
struct sockaddr_un svr = {0};
mlag_socket = socket(svr.sun_family, SOCK_STREAM, 0);
if (mlag_socket < 0)
- return -1;
+ return;
if (connect(mlag_socket, (struct sockaddr *)&svr, sizeof(svr)) == -1) {
if (IS_ZEBRA_DEBUG_MLAG)
svr.sun_path);
close(mlag_socket);
zrouter.mlag_info.timer_running = true;
- thread_add_timer(zmlag_master, zebra_mlag_connect, NULL, 10,
- &zrouter.mlag_info.t_read);
- return 0;
+ event_add_timer(zmlag_master, zebra_mlag_connect, NULL, 10,
+ &zrouter.mlag_info.t_read);
+ return;
}
set_nonblocking(mlag_socket);
zlog_debug("%s: Connection with MLAG is established ",
__func__);
- thread_add_read(zmlag_master, zebra_mlag_read, NULL, mlag_socket,
- &zrouter.mlag_info.t_read);
+ event_add_read(zmlag_master, zebra_mlag_read, NULL, mlag_socket,
+ &zrouter.mlag_info.t_read);
/*
* Connection is established with MLAGD, post to clients
*/
zebra_mlag_handle_process_state(MLAG_UP);
- return 0;
}
/*
*/
static int zebra_mlag_private_monitor_state(void)
{
- thread_add_event(zmlag_master, zebra_mlag_connect, NULL, 0,
- &zrouter.mlag_info.t_read);
+ event_add_event(zmlag_master, zebra_mlag_connect, NULL, 0,
+ &zrouter.mlag_info.t_read);
return 0;
}
/*
* Connect only if any clients are showing interest
*/
- thread_add_event(zmlag_master, zebra_mlag_connect, NULL, 0,
- &zrouter.mlag_info.t_read);
+ event_add_event(zmlag_master, zebra_mlag_connect, NULL, 0,
+ &zrouter.mlag_info.t_read);
}
return 0;
}