+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2003 Yasuhiro Ohara
- *
- * 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>
#include "log.h"
#include "memory.h"
-#include "thread.h"
+#include "frrevent.h"
#include "linklist.h"
#include "vty.h"
#include "command.h"
ospf6_lsdb_delete(on->lsupdate_list);
ospf6_lsdb_delete(on->lsack_list);
- THREAD_OFF(on->inactivity_timer);
+ EVENT_OFF(on->inactivity_timer);
- THREAD_OFF(on->last_dbdesc_release_timer);
+ EVENT_OFF(on->last_dbdesc_release_timer);
- THREAD_OFF(on->thread_send_dbdesc);
- THREAD_OFF(on->thread_send_lsreq);
- THREAD_OFF(on->thread_send_lsupdate);
- THREAD_OFF(on->thread_send_lsack);
- THREAD_OFF(on->thread_exchange_done);
- THREAD_OFF(on->thread_adj_ok);
+ EVENT_OFF(on->thread_send_dbdesc);
+ EVENT_OFF(on->thread_send_lsreq);
+ EVENT_OFF(on->thread_send_lsupdate);
+ EVENT_OFF(on->thread_send_lsack);
+ EVENT_OFF(on->thread_exchange_done);
+ EVENT_OFF(on->thread_adj_ok);
- THREAD_OFF(on->gr_helper_info.t_grace_timer);
+ EVENT_OFF(on->gr_helper_info.t_grace_timer);
bfd_sess_free(&on->bfd_session);
XFREE(MTYPE_OSPF6_NEIGHBOR, on);
/* log */
if (IS_OSPF6_DEBUG_NEIGHBOR(STATE)) {
- zlog_debug("Neighbor state change %s: [%s]->[%s] (%s)",
- on->name, ospf6_neighbor_state_str[prev_state],
- ospf6_neighbor_state_str[next_state],
- ospf6_neighbor_event_string(event));
+ zlog_debug(
+ "Neighbor state change %s (Router-ID: %pI4): [%s]->[%s] (%s)",
+ on->name, &on->router_id,
+ ospf6_neighbor_state_str[prev_state],
+ ospf6_neighbor_state_str[next_state],
+ ospf6_neighbor_event_string(event));
}
/* Optionally notify about adjacency changes */
OSPF6_LOG_ADJACENCY_DETAIL)
|| (next_state == OSPF6_NEIGHBOR_FULL)
|| (next_state < prev_state)))
- zlog_notice("AdjChg: Nbr %s: %s -> %s (%s)", on->name,
- ospf6_neighbor_state_str[prev_state],
- ospf6_neighbor_state_str[next_state],
- ospf6_neighbor_event_string(event));
+ zlog_notice(
+ "AdjChg: Nbr %pI4(%s) on %s: %s -> %s (%s)",
+ &on->router_id,
+ vrf_id_to_name(on->ospf6_if->interface->vrf->vrf_id),
+ on->name, ospf6_neighbor_state_str[prev_state],
+ ospf6_neighbor_state_str[next_state],
+ ospf6_neighbor_event_string(event));
if (prev_state == OSPF6_NEIGHBOR_FULL
|| next_state == OSPF6_NEIGHBOR_FULL) {
return 0;
}
-void hello_received(struct thread *thread)
+void hello_received(struct event *thread)
{
struct ospf6_neighbor *on;
- on = (struct ospf6_neighbor *)THREAD_ARG(thread);
+ on = (struct ospf6_neighbor *)EVENT_ARG(thread);
assert(on);
if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
zlog_debug("Neighbor Event %s: *HelloReceived*", on->name);
/* reset Inactivity Timer */
- THREAD_OFF(on->inactivity_timer);
- thread_add_timer(master, inactivity_timer, on,
- on->ospf6_if->dead_interval, &on->inactivity_timer);
+ EVENT_OFF(on->inactivity_timer);
+ event_add_timer(master, inactivity_timer, on,
+ on->ospf6_if->dead_interval, &on->inactivity_timer);
if (on->state <= OSPF6_NEIGHBOR_DOWN)
ospf6_neighbor_state_change(OSPF6_NEIGHBOR_INIT, on,
OSPF6_NEIGHBOR_EVENT_HELLO_RCVD);
}
-void twoway_received(struct thread *thread)
+void twoway_received(struct event *thread)
{
struct ospf6_neighbor *on;
- on = (struct ospf6_neighbor *)THREAD_ARG(thread);
+ on = (struct ospf6_neighbor *)EVENT_ARG(thread);
assert(on);
if (on->state > OSPF6_NEIGHBOR_INIT)
if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
zlog_debug("Neighbor Event %s: *2Way-Received*", on->name);
- thread_add_event(master, neighbor_change, on->ospf6_if, 0, NULL);
+ event_add_event(master, neighbor_change, on->ospf6_if, 0, NULL);
if (!need_adjacency(on)) {
ospf6_neighbor_state_change(OSPF6_NEIGHBOR_TWOWAY, on,
SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT);
SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT);
- THREAD_OFF(on->thread_send_dbdesc);
- thread_add_event(master, ospf6_dbdesc_send, on, 0,
- &on->thread_send_dbdesc);
+ EVENT_OFF(on->thread_send_dbdesc);
+ event_add_event(master, ospf6_dbdesc_send, on, 0,
+ &on->thread_send_dbdesc);
}
-void negotiation_done(struct thread *thread)
+void negotiation_done(struct event *thread)
{
struct ospf6_neighbor *on;
struct ospf6_lsa *lsa, *lsanext;
- on = (struct ospf6_neighbor *)THREAD_ARG(thread);
+ on = (struct ospf6_neighbor *)EVENT_ARG(thread);
assert(on);
if (on->state != OSPF6_NEIGHBOR_EXSTART)
OSPF6_NEIGHBOR_EVENT_NEGOTIATION_DONE);
}
-static void ospf6_neighbor_last_dbdesc_release(struct thread *thread)
+static void ospf6_neighbor_last_dbdesc_release(struct event *thread)
{
- struct ospf6_neighbor *on = THREAD_ARG(thread);
+ struct ospf6_neighbor *on = EVENT_ARG(thread);
assert(on);
memset(&on->dbdesc_last, 0, sizeof(struct ospf6_dbdesc));
}
-void exchange_done(struct thread *thread)
+void exchange_done(struct event *thread)
{
struct ospf6_neighbor *on;
- on = (struct ospf6_neighbor *)THREAD_ARG(thread);
+ on = (struct ospf6_neighbor *)EVENT_ARG(thread);
assert(on);
if (on->state != OSPF6_NEIGHBOR_EXCHANGE)
if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
zlog_debug("Neighbor Event %s: *ExchangeDone*", on->name);
- THREAD_OFF(on->thread_send_dbdesc);
+ EVENT_OFF(on->thread_send_dbdesc);
ospf6_lsdb_remove_all(on->dbdesc_list);
/* RFC 2328 (10.8): Release the last dbdesc after dead_interval */
if (!CHECK_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MSBIT)) {
- THREAD_OFF(on->last_dbdesc_release_timer);
- thread_add_timer(master, ospf6_neighbor_last_dbdesc_release, on,
- on->ospf6_if->dead_interval,
- &on->last_dbdesc_release_timer);
+ EVENT_OFF(on->last_dbdesc_release_timer);
+ event_add_timer(master, ospf6_neighbor_last_dbdesc_release, on,
+ on->ospf6_if->dead_interval,
+ &on->last_dbdesc_release_timer);
}
if (on->request_list->count == 0)
ospf6_neighbor_state_change(OSPF6_NEIGHBOR_LOADING, on,
OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE);
- thread_add_event(master, ospf6_lsreq_send, on, 0,
- &on->thread_send_lsreq);
+ event_add_event(master, ospf6_lsreq_send, on, 0,
+ &on->thread_send_lsreq);
}
}
if ((on->state == OSPF6_NEIGHBOR_LOADING)
|| (on->state == OSPF6_NEIGHBOR_EXCHANGE)) {
if (on->request_list->count == 0)
- thread_add_event(master, loading_done, on, 0, NULL);
+ event_add_event(master, loading_done, on, 0, NULL);
else if (on->last_ls_req == NULL) {
- THREAD_OFF(on->thread_send_lsreq);
- thread_add_event(master, ospf6_lsreq_send, on, 0,
- &on->thread_send_lsreq);
+ EVENT_OFF(on->thread_send_lsreq);
+ event_add_event(master, ospf6_lsreq_send, on, 0,
+ &on->thread_send_lsreq);
}
}
}
-void loading_done(struct thread *thread)
+void loading_done(struct event *thread)
{
struct ospf6_neighbor *on;
- on = (struct ospf6_neighbor *)THREAD_ARG(thread);
+ on = (struct ospf6_neighbor *)EVENT_ARG(thread);
assert(on);
if (on->state != OSPF6_NEIGHBOR_LOADING)
OSPF6_NEIGHBOR_EVENT_LOADING_DONE);
}
-void adj_ok(struct thread *thread)
+void adj_ok(struct event *thread)
{
struct ospf6_neighbor *on;
- on = (struct ospf6_neighbor *)THREAD_ARG(thread);
+ on = (struct ospf6_neighbor *)EVENT_ARG(thread);
assert(on);
if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_MBIT);
SET_FLAG(on->dbdesc_bits, OSPF6_DBDESC_IBIT);
- THREAD_OFF(on->thread_send_dbdesc);
- thread_add_event(master, ospf6_dbdesc_send, on, 0,
- &on->thread_send_dbdesc);
+ EVENT_OFF(on->thread_send_dbdesc);
+ event_add_event(master, ospf6_dbdesc_send, on, 0,
+ &on->thread_send_dbdesc);
} else if (on->state >= OSPF6_NEIGHBOR_EXSTART && !need_adjacency(on)) {
ospf6_neighbor_state_change(OSPF6_NEIGHBOR_TWOWAY, on,
}
}
-void seqnumber_mismatch(struct thread *thread)
+void seqnumber_mismatch(struct event *thread)
{
struct ospf6_neighbor *on;
- on = (struct ospf6_neighbor *)THREAD_ARG(thread);
+ on = (struct ospf6_neighbor *)EVENT_ARG(thread);
assert(on);
if (on->state < OSPF6_NEIGHBOR_EXCHANGE)
ospf6_neighbor_clear_ls_lists(on);
- THREAD_OFF(on->thread_send_dbdesc);
+ EVENT_OFF(on->thread_send_dbdesc);
on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */
- thread_add_event(master, ospf6_dbdesc_send, on, 0,
- &on->thread_send_dbdesc);
+ event_add_event(master, ospf6_dbdesc_send, on, 0,
+ &on->thread_send_dbdesc);
}
-void bad_lsreq(struct thread *thread)
+void bad_lsreq(struct event *thread)
{
struct ospf6_neighbor *on;
- on = (struct ospf6_neighbor *)THREAD_ARG(thread);
+ on = (struct ospf6_neighbor *)EVENT_ARG(thread);
assert(on);
if (on->state < OSPF6_NEIGHBOR_EXCHANGE)
ospf6_neighbor_clear_ls_lists(on);
- THREAD_OFF(on->thread_send_dbdesc);
+ EVENT_OFF(on->thread_send_dbdesc);
on->dbdesc_seqnum++; /* Incr seqnum as per RFC2328, sec 10.3 */
- thread_add_event(master, ospf6_dbdesc_send, on, 0,
- &on->thread_send_dbdesc);
-
+ event_add_event(master, ospf6_dbdesc_send, on, 0,
+ &on->thread_send_dbdesc);
}
-void oneway_received(struct thread *thread)
+void oneway_received(struct event *thread)
{
struct ospf6_neighbor *on;
- on = (struct ospf6_neighbor *)THREAD_ARG(thread);
+ on = (struct ospf6_neighbor *)EVENT_ARG(thread);
assert(on);
if (on->state < OSPF6_NEIGHBOR_TWOWAY)
ospf6_neighbor_state_change(OSPF6_NEIGHBOR_INIT, on,
OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD);
- thread_add_event(master, neighbor_change, on->ospf6_if, 0, NULL);
+ event_add_event(master, neighbor_change, on->ospf6_if, 0, NULL);
ospf6_neighbor_clear_ls_lists(on);
- THREAD_OFF(on->thread_send_dbdesc);
- THREAD_OFF(on->thread_send_lsreq);
- THREAD_OFF(on->thread_send_lsupdate);
- THREAD_OFF(on->thread_send_lsack);
- THREAD_OFF(on->thread_exchange_done);
- THREAD_OFF(on->thread_adj_ok);
+ EVENT_OFF(on->thread_send_dbdesc);
+ EVENT_OFF(on->thread_send_lsreq);
+ EVENT_OFF(on->thread_send_lsupdate);
+ EVENT_OFF(on->thread_send_lsack);
+ EVENT_OFF(on->thread_exchange_done);
+ EVENT_OFF(on->thread_adj_ok);
}
-void inactivity_timer(struct thread *thread)
+void inactivity_timer(struct event *thread)
{
struct ospf6_neighbor *on;
- on = (struct ospf6_neighbor *)THREAD_ARG(thread);
+ on = (struct ospf6_neighbor *)EVENT_ARG(thread);
assert(on);
if (IS_OSPF6_DEBUG_NEIGHBOR(EVENT))
ospf6_neighbor_state_change(
OSPF6_NEIGHBOR_DOWN, on,
OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER);
- thread_add_event(master, neighbor_change, on->ospf6_if, 0,
- NULL);
+ event_add_event(master, neighbor_change, on->ospf6_if, 0, NULL);
listnode_delete(on->ospf6_if->neighbor_list, on);
ospf6_neighbor_delete(on);
"%s, Acting as HELPER for this neighbour, So restart the dead timer.",
__PRETTY_FUNCTION__);
- thread_add_timer(master, inactivity_timer, on,
- on->ospf6_if->dead_interval,
- &on->inactivity_timer);
+ event_add_timer(master, inactivity_timer, on,
+ on->ospf6_if->dead_interval,
+ &on->inactivity_timer);
}
}
timerclear(&res);
- if (thread_is_scheduled(on->thread_send_dbdesc))
+ if (event_is_scheduled(on->thread_send_dbdesc))
timersub(&on->thread_send_dbdesc->u.sands, &now, &res);
timerstring(&res, duration, sizeof(duration));
json_object_int_add(json_neighbor, "pendingLsaDbDescCount",
duration);
json_object_string_add(
json_neighbor, "dbDescSendThread",
- (thread_is_scheduled(on->thread_send_dbdesc) ? "on"
- : "off"));
+ (event_is_scheduled(on->thread_send_dbdesc) ? "on"
+ : "off"));
json_array = json_object_new_array();
for (ALL_LSDB(on->dbdesc_list, lsa, lsanext))
json_object_array_add(
json_array);
timerclear(&res);
- if (thread_is_scheduled(on->thread_send_lsreq))
+ if (event_is_scheduled(on->thread_send_lsreq))
timersub(&on->thread_send_lsreq->u.sands, &now, &res);
timerstring(&res, duration, sizeof(duration));
json_object_int_add(json_neighbor, "pendingLsaLsReqCount",
duration);
json_object_string_add(
json_neighbor, "lsReqSendThread",
- (thread_is_scheduled(on->thread_send_lsreq) ? "on"
- : "off"));
+ (event_is_scheduled(on->thread_send_lsreq) ? "on"
+ : "off"));
json_array = json_object_new_array();
for (ALL_LSDB(on->request_list, lsa, lsanext))
json_object_array_add(
timerclear(&res);
- if (thread_is_scheduled(on->thread_send_lsupdate))
+ if (event_is_scheduled(on->thread_send_lsupdate))
timersub(&on->thread_send_lsupdate->u.sands, &now,
&res);
timerstring(&res, duration, sizeof(duration));
duration);
json_object_string_add(
json_neighbor, "lsUpdateSendThread",
- (thread_is_scheduled(on->thread_send_lsupdate)
- ? "on"
- : "off"));
+ (event_is_scheduled(on->thread_send_lsupdate) ? "on"
+ : "off"));
json_array = json_object_new_array();
for (ALL_LSDB(on->lsupdate_list, lsa, lsanext))
json_object_array_add(
json_array);
timerclear(&res);
- if (thread_is_scheduled(on->thread_send_lsack))
+ if (event_is_scheduled(on->thread_send_lsack))
timersub(&on->thread_send_lsack->u.sands, &now, &res);
timerstring(&res, duration, sizeof(duration));
json_object_int_add(json_neighbor, "pendingLsaLsAckCount",
duration);
json_object_string_add(
json_neighbor, "lsAckSendThread",
- (thread_is_scheduled(on->thread_send_lsack) ? "on"
- : "off"));
+ (event_is_scheduled(on->thread_send_lsack) ? "on"
+ : "off"));
json_array = json_object_new_array();
for (ALL_LSDB(on->lsack_list, lsa, lsanext))
json_object_array_add(
vty_out(vty, " %s\n", lsa->name);
timerclear(&res);
- if (thread_is_scheduled(on->thread_send_dbdesc))
+ if (event_is_scheduled(on->thread_send_dbdesc))
timersub(&on->thread_send_dbdesc->u.sands, &now, &res);
timerstring(&res, duration, sizeof(duration));
vty_out(vty,
" %d Pending LSAs for DbDesc in Time %s [thread %s]\n",
on->dbdesc_list->count, duration,
- (thread_is_scheduled(on->thread_send_dbdesc) ? "on"
- : "off"));
+ (event_is_scheduled(on->thread_send_dbdesc) ? "on"
+ : "off"));
for (ALL_LSDB(on->dbdesc_list, lsa, lsanext))
vty_out(vty, " %s\n", lsa->name);
timerclear(&res);
- if (thread_is_scheduled(on->thread_send_lsreq))
+ if (event_is_scheduled(on->thread_send_lsreq))
timersub(&on->thread_send_lsreq->u.sands, &now, &res);
timerstring(&res, duration, sizeof(duration));
vty_out(vty,
" %d Pending LSAs for LSReq in Time %s [thread %s]\n",
on->request_list->count, duration,
- (thread_is_scheduled(on->thread_send_lsreq) ? "on"
- : "off"));
+ (event_is_scheduled(on->thread_send_lsreq) ? "on"
+ : "off"));
for (ALL_LSDB(on->request_list, lsa, lsanext))
vty_out(vty, " %s\n", lsa->name);
timerclear(&res);
- if (thread_is_scheduled(on->thread_send_lsupdate))
+ if (event_is_scheduled(on->thread_send_lsupdate))
timersub(&on->thread_send_lsupdate->u.sands, &now,
&res);
timerstring(&res, duration, sizeof(duration));
vty_out(vty,
" %d Pending LSAs for LSUpdate in Time %s [thread %s]\n",
on->lsupdate_list->count, duration,
- (thread_is_scheduled(on->thread_send_lsupdate)
- ? "on"
- : "off"));
+ (event_is_scheduled(on->thread_send_lsupdate) ? "on"
+ : "off"));
for (ALL_LSDB(on->lsupdate_list, lsa, lsanext))
vty_out(vty, " %s\n", lsa->name);
timerclear(&res);
- if (thread_is_scheduled(on->thread_send_lsack))
+ if (event_is_scheduled(on->thread_send_lsack))
timersub(&on->thread_send_lsack->u.sands, &now, &res);
timerstring(&res, duration, sizeof(duration));
vty_out(vty,
" %d Pending LSAs for LSAck in Time %s [thread %s]\n",
on->lsack_list->count, duration,
- (thread_is_scheduled(on->thread_send_lsack) ? "on"
- : "off"));
+ (event_is_scheduled(on->thread_send_lsack) ? "on"
+ : "off"));
for (ALL_LSDB(on->lsack_list, lsa, lsanext))
vty_out(vty, " %s\n", lsa->name);