}
static void
-ospf6_neighbor_state_change (u_char next_state, struct ospf6_neighbor *on)
+ospf6_neighbor_state_change (u_char next_state, struct ospf6_neighbor *on, int event)
{
u_char prev_state;
/* log */
if (IS_OSPF6_DEBUG_NEIGHBOR (STATE))
{
- zlog_debug ("Neighbor state change %s: [%s]->[%s]", on->name,
+ 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_state_str[next_state],
+ ospf6_neighbor_event_string(event));
}
+ /* Optionally notify about adjacency changes */
+ if (CHECK_FLAG(on->ospf6_if->area->ospf6->config_flags,
+ OSPF6_LOG_ADJACENCY_CHANGES) &&
+ (CHECK_FLAG(on->ospf6_if->area->ospf6->config_flags,
+ 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));
+
if (prev_state == OSPF6_NEIGHBOR_FULL || next_state == OSPF6_NEIGHBOR_FULL)
{
OSPF6_ROUTER_LSA_SCHEDULE (on->ospf6_if->area);
on->ospf6_if->dead_interval);
if (on->state <= OSPF6_NEIGHBOR_DOWN)
- ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on);
+ ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on,
+ OSPF6_NEIGHBOR_EVENT_HELLO_RCVD);
return 0;
}
if (! need_adjacency (on))
{
- ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY, on);
+ ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY, on,
+ OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD);
return 0;
}
- ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on);
+ ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on,
+ OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD);
SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
}
UNSET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
- ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXCHANGE, on);
+ ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXCHANGE, on,
+ OSPF6_NEIGHBOR_EVENT_NEGOTIATION_DONE);
return 0;
}
*/
if (on->request_list->count == 0)
- ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL, on);
+ ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL, on,
+ OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE);
else
{
- ospf6_neighbor_state_change (OSPF6_NEIGHBOR_LOADING, on);
+ ospf6_neighbor_state_change (OSPF6_NEIGHBOR_LOADING, on,
+ OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE);
if (on->thread_send_lsreq == NULL)
on->thread_send_lsreq =
assert (on->request_list->count == 0);
- ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL, on);
+ ospf6_neighbor_state_change (OSPF6_NEIGHBOR_FULL, on,
+ OSPF6_NEIGHBOR_EVENT_LOADING_DONE);
return 0;
}
if (on->state == OSPF6_NEIGHBOR_TWOWAY && need_adjacency (on))
{
- ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on);
+ ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on,
+ OSPF6_NEIGHBOR_EVENT_ADJ_OK);
SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
else if (on->state >= OSPF6_NEIGHBOR_EXSTART &&
! need_adjacency (on))
{
- ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY, on);
+ ospf6_neighbor_state_change (OSPF6_NEIGHBOR_TWOWAY, on,
+ OSPF6_NEIGHBOR_EVENT_ADJ_OK);
ospf6_lsdb_remove_all (on->summary_list);
ospf6_lsdb_remove_all (on->request_list);
for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;
if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
zlog_debug ("Neighbor Event %s: *SeqNumberMismatch*", on->name);
- ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on);
+ ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on,
+ OSPF6_NEIGHBOR_EVENT_SEQNUMBER_MISMATCH);
SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
zlog_debug ("Neighbor Event %s: *BadLSReq*", on->name);
- ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on);
+ ospf6_neighbor_state_change (OSPF6_NEIGHBOR_EXSTART, on,
+ OSPF6_NEIGHBOR_EVENT_BAD_LSREQ);
SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT);
SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT);
SET_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT);
if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))
zlog_debug ("Neighbor Event %s: *1Way-Received*", on->name);
- ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on);
+ ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on,
+ OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD);
thread_add_event (master, neighbor_change, on->ospf6_if, 0);
ospf6_lsdb_remove_all (on->summary_list);
on->drouter = on->prev_drouter = 0;
on->bdrouter = on->prev_bdrouter = 0;
- ospf6_neighbor_state_change (OSPF6_NEIGHBOR_DOWN, on);
+ ospf6_neighbor_state_change (OSPF6_NEIGHBOR_DOWN, on,
+ OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER);
thread_add_event (master, neighbor_change, on->ospf6_if, 0);
listnode_delete (on->ospf6_if->neighbor_list, on);
return CMD_SUCCESS;
}
+DEFUN (ospf6_log_adjacency_changes,
+ ospf6_log_adjacency_changes_cmd,
+ "log-adjacency-changes",
+ "Log changes in adjacency state\n")
+{
+ struct ospf6 *ospf6 = vty->index;
+
+ SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
+ return CMD_SUCCESS;
+}
+
+DEFUN (ospf6_log_adjacency_changes_detail,
+ ospf6_log_adjacency_changes_detail_cmd,
+ "log-adjacency-changes detail",
+ "Log changes in adjacency state\n"
+ "Log all state changes\n")
+{
+ struct ospf6 *ospf6 = vty->index;
+
+ SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
+ SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL);
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_ospf6_log_adjacency_changes,
+ no_ospf6_log_adjacency_changes_cmd,
+ "no log-adjacency-changes",
+ NO_STR
+ "Log changes in adjacency state\n")
+{
+ struct ospf6 *ospf6 = vty->index;
+
+ UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL);
+ UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_ospf6_log_adjacency_changes_detail,
+ no_ospf6_log_adjacency_changes_detail_cmd,
+ "no log-adjacency-changes detail",
+ NO_STR
+ "Log changes in adjacency state\n"
+ "Log all state changes\n")
+{
+ struct ospf6 *ospf6 = vty->index;
+
+ UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL);
+ return CMD_SUCCESS;
+}
+
DEFUN (ospf6_interface_area,
ospf6_interface_area_cmd,
"interface IFNAME area A.B.C.D",
vty_out (vty, " Number of areas in this router is %u%s",
listcount (o->area_list), VNL);
+ if (CHECK_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_CHANGES))
+ {
+ if (CHECK_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_DETAIL))
+ vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
+ else
+ vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
+ }
+
+ vty_out (vty, "%s",VTY_NEWLINE);
+
for (ALL_LIST_ELEMENTS_RO (o->area_list, n, oa))
ospf6_area_show (vty, oa);
}
if (ospf6->router_id_static != 0)
vty_out (vty, " router-id %s%s", router_id, VNL);
+ /* log-adjacency-changes flag print. */
+ if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES))
+ {
+ vty_out(vty, " log-adjacency-changes");
+ if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL))
+ vty_out(vty, " detail");
+ vty_out(vty, "%s", VTY_NEWLINE);
+ }
+
ospf6_stub_router_config_write (vty);
ospf6_redistribute_config_write (vty);
ospf6_area_config_write (vty);
install_default (OSPF6_NODE);
install_element (OSPF6_NODE, &ospf6_router_id_cmd);
+ install_element (OSPF6_NODE, &ospf6_log_adjacency_changes_cmd);
+ install_element (OSPF6_NODE, &ospf6_log_adjacency_changes_detail_cmd);
+ install_element (OSPF6_NODE, &no_ospf6_log_adjacency_changes_cmd);
+ install_element (OSPF6_NODE, &no_ospf6_log_adjacency_changes_detail_cmd);
install_element (OSPF6_NODE, &ospf6_interface_area_cmd);
install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd);
install_element (OSPF6_NODE, &ospf6_stub_router_admin_cmd);