+// SPDX-License-Identifier: GPL-2.0-or-later
/* Kernel routing table updates using netlink over GNU/Linux system.
* Copyright (C) 1997, 98, 99 Kunihiro Ishiguro
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra 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, or (at your option) any
- * later version.
- *
- * GNU Zebra 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>
struct zebra_ptm_cb ptm_cb;
static int zebra_ptm_socket_init(void);
-void zebra_ptm_sock_read(struct thread *thread);
+void zebra_ptm_sock_read(struct event *thread);
static void zebra_ptm_install_commands(void);
static int zebra_ptm_handle_msg_cb(void *arg, void *in_ctxt);
void zebra_bfd_peer_replay_req(void);
free(ptm_cb.in_data);
/* Cancel events. */
- thread_cancel(&ptm_cb.t_read);
- thread_cancel(&ptm_cb.t_write);
- thread_cancel(&ptm_cb.t_timer);
+ EVENT_OFF(ptm_cb.t_read);
+ EVENT_OFF(ptm_cb.t_write);
+ EVENT_OFF(ptm_cb.t_timer);
if (ptm_cb.wb)
buffer_free(ptm_cb.wb);
close(ptm_cb.ptm_sock);
}
-static void zebra_ptm_flush_messages(struct thread *thread)
+static void zebra_ptm_flush_messages(struct event *thread)
{
ptm_cb.t_write = NULL;
ptm_cb.ptm_sock = -1;
zebra_ptm_reset_status(0);
ptm_cb.t_timer = NULL;
- thread_add_timer(zrouter.master, zebra_ptm_connect, NULL,
- ptm_cb.reconnect_time, &ptm_cb.t_timer);
+ event_add_timer(zrouter.master, zebra_ptm_connect, NULL,
+ ptm_cb.reconnect_time, &ptm_cb.t_timer);
return;
case BUFFER_PENDING:
ptm_cb.t_write = NULL;
- thread_add_write(zrouter.master, zebra_ptm_flush_messages, NULL,
- ptm_cb.ptm_sock, &ptm_cb.t_write);
+ event_add_write(zrouter.master, zebra_ptm_flush_messages, NULL,
+ ptm_cb.ptm_sock, &ptm_cb.t_write);
break;
case BUFFER_EMPTY:
break;
ptm_cb.ptm_sock = -1;
zebra_ptm_reset_status(0);
ptm_cb.t_timer = NULL;
- thread_add_timer(zrouter.master, zebra_ptm_connect, NULL,
- ptm_cb.reconnect_time, &ptm_cb.t_timer);
+ event_add_timer(zrouter.master, zebra_ptm_connect, NULL,
+ ptm_cb.reconnect_time, &ptm_cb.t_timer);
return -1;
case BUFFER_EMPTY:
- thread_cancel(&ptm_cb.t_write);
+ EVENT_OFF(ptm_cb.t_write);
break;
case BUFFER_PENDING:
- thread_add_write(zrouter.master, zebra_ptm_flush_messages, NULL,
- ptm_cb.ptm_sock, &ptm_cb.t_write);
+ event_add_write(zrouter.master, zebra_ptm_flush_messages, NULL,
+ ptm_cb.ptm_sock, &ptm_cb.t_write);
break;
}
return 0;
}
-void zebra_ptm_connect(struct thread *t)
+void zebra_ptm_connect(struct event *t)
{
int init = 0;
if (ptm_cb.ptm_sock != -1) {
if (init) {
ptm_cb.t_read = NULL;
- thread_add_read(zrouter.master, zebra_ptm_sock_read,
- NULL, ptm_cb.ptm_sock, &ptm_cb.t_read);
+ event_add_read(zrouter.master, zebra_ptm_sock_read,
+ NULL, ptm_cb.ptm_sock, &ptm_cb.t_read);
zebra_bfd_peer_replay_req();
}
zebra_ptm_send_status_req();
ptm_cb.reconnect_time = ZEBRA_PTM_RECONNECT_TIME_MAX;
ptm_cb.t_timer = NULL;
- thread_add_timer(zrouter.master, zebra_ptm_connect, NULL,
- ptm_cb.reconnect_time, &ptm_cb.t_timer);
+ event_add_timer(zrouter.master, zebra_ptm_connect, NULL,
+ ptm_cb.reconnect_time, &ptm_cb.t_timer);
} else if (ptm_cb.reconnect_time >= ZEBRA_PTM_RECONNECT_TIME_MAX) {
ptm_cb.reconnect_time = ZEBRA_PTM_RECONNECT_TIME_INITIAL;
}
}
}
-void zebra_ptm_sock_read(struct thread *thread)
+void zebra_ptm_sock_read(struct event *thread)
{
int sock;
int rc;
errno = 0;
- sock = THREAD_FD(thread);
+ sock = EVENT_FD(thread);
if (sock == -1)
return;
ptm_cb.ptm_sock = -1;
zebra_ptm_reset_status(0);
ptm_cb.t_timer = NULL;
- thread_add_timer(zrouter.master, zebra_ptm_connect, NULL,
- ptm_cb.reconnect_time,
- &ptm_cb.t_timer);
+ event_add_timer(zrouter.master, zebra_ptm_connect, NULL,
+ ptm_cb.reconnect_time, &ptm_cb.t_timer);
return;
}
ptm_cb.t_read = NULL;
- thread_add_read(zrouter.master, zebra_ptm_sock_read, NULL,
- ptm_cb.ptm_sock, &ptm_cb.t_read);
+ event_add_read(zrouter.master, zebra_ptm_sock_read, NULL,
+ ptm_cb.ptm_sock, &ptm_cb.t_read);
}
/* BFD peer/dst register/update */
if (ptm_cb.ptm_sock == -1) {
ptm_cb.t_timer = NULL;
- thread_add_timer(zrouter.master, zebra_ptm_connect, NULL,
- ptm_cb.reconnect_time, &ptm_cb.t_timer);
+ event_add_timer(zrouter.master, zebra_ptm_connect, NULL,
+ ptm_cb.reconnect_time, &ptm_cb.t_timer);
return;
}
if (ptm_cb.ptm_sock == -1) {
ptm_cb.t_timer = NULL;
- thread_add_timer(zrouter.master, zebra_ptm_connect, NULL,
- ptm_cb.reconnect_time, &ptm_cb.t_timer);
+ event_add_timer(zrouter.master, zebra_ptm_connect, NULL,
+ ptm_cb.reconnect_time, &ptm_cb.t_timer);
return;
}
if (ptm_cb.ptm_sock == -1) {
ptm_cb.t_timer = NULL;
- thread_add_timer(zrouter.master, zebra_ptm_connect, NULL,
- ptm_cb.reconnect_time, &ptm_cb.t_timer);
+ event_add_timer(zrouter.master, zebra_ptm_connect, NULL,
+ ptm_cb.reconnect_time, &ptm_cb.t_timer);
return;
}
if (ptm_cb.ptm_sock == -1) {
ptm_cb.t_timer = NULL;
- thread_add_timer(zrouter.master, zebra_ptm_connect, NULL,
- ptm_cb.reconnect_time, &ptm_cb.t_timer);
+ event_add_timer(zrouter.master, zebra_ptm_connect, NULL,
+ ptm_cb.reconnect_time, &ptm_cb.t_timer);
return 0;
}
TAILQ_HEAD(ppqueue, ptm_process) ppqueue;
DEFINE_MTYPE_STATIC(ZEBRA, ZEBRA_PTM_BFD_PROCESS,
- "PTM BFD process registration table.");
+ "PTM BFD process reg table");
/*
* Prototypes.
/* Create copy for replication. */
msgc = stream_dup(msg);
- if (msgc == NULL) {
- zlog_debug("%s: not enough memory", __func__);
- return;
- }
/* Send message to all running BFDd daemons. */
for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client)) {
/* Allocate more messages. */
msg = stream_dup(msgc);
- if (msg == NULL) {
- zlog_debug("%s: not enough memory", __func__);
- return;
- }
}
stream_free(msgc);
/* Create copy for replication. */
msgc = stream_dup(msg);
- if (msgc == NULL) {
- zlog_debug("%s: not enough memory", __func__);
- return;
- }
/* Send message to all running client daemons. */
for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client)) {
/* Allocate more messages. */
msg = stream_dup(msgc);
- if (msg == NULL) {
- zlog_debug("%s: not enough memory", __func__);
- return;
- }
}
stream_free(msgc);