fix ISIS holding timer #97

This commit is contained in:
Christian Giese
2022-07-06 13:27:17 +02:00
committed by Christian Giese
parent f2619a3356
commit 92fe68529c
4 changed files with 40 additions and 25 deletions
@@ -145,6 +145,7 @@ isis_adjacency_down(isis_adjacency_t *adjacency) {
timer_del(adjacency->timer_retry);
timer_del(adjacency->timer_csnp);
timer_del(adjacency->timer_csnp_next);
timer_del(adjacency->timer_holding);
if(ctx->routing_sessions) ctx->routing_sessions--;
}
+6 -4
View File
@@ -18,8 +18,9 @@ isis_ctrl_adjacency(isis_adjacency_t *adjacency) {
return NULL;
}
peer = json_pack("{ss}",
"system-id", isis_system_id_to_str(adjacency->peer->system_id));
peer = json_pack("{ss si}",
"system-id", isis_system_id_to_str(adjacency->peer->system_id),
"holding-timer", adjacency->peer->holding_time);
root = json_pack("{ss ss ss si ss so}",
"interface", adjacency->interface->name,
@@ -45,8 +46,9 @@ isis_ctrl_adjacency_p2p(isis_adjacency_p2p_t *adjacency) {
return NULL;
}
peer = json_pack("{ss}",
"system-id", isis_system_id_to_str(adjacency->peer->system_id));
peer = json_pack("{ss si}",
"system-id", isis_system_id_to_str(adjacency->peer->system_id),
"holding-timer", adjacency->peer->holding_time);
root = json_pack("{ss ss, ss si ss so}",
"interface", adjacency->interface->name,
+4 -3
View File
@@ -24,6 +24,7 @@
#define ISIS_OFFSET_P2P_HELLO_LEVEL 8
#define ISIS_OFFSET_P2P_HELLO_SYSTEM_ID 9
#define ISIS_OFFSET_P2P_HELLO_HOLD_TIME 15
#define ISIS_OFFSET_P2P_HELLO_LEN 17
#define ISIS_OFFSET_CSNP_LEN 8
@@ -237,6 +238,7 @@ typedef struct isis_config_ {
typedef struct isis_peer_ {
uint8_t level;
uint8_t system_id[ISIS_SYSTEM_ID_LEN];
uint16_t holding_time;
char *hostname;
} isis_peer_t;
@@ -258,12 +260,12 @@ typedef struct isis_adjacency_ {
struct timer_ *timer_csnp;
struct timer_ *timer_csnp_next;
struct timer_ *timer_psnp_next;
struct timer_ *timer_holding;
bool timer_psnp_started;
uint8_t level;
uint8_t state;
uint8_t timeout;
uint16_t window_size;
uint32_t metric;
@@ -289,7 +291,6 @@ typedef struct isis_adjacency_p2p_ {
uint8_t level;
uint8_t state;
uint8_t timeout;
struct {
uint32_t hello_rx;
+29 -18
View File
@@ -14,6 +14,31 @@ isis_hello_timeout (timer_s *timer) {
interface->send_requests |= BBL_IF_SEND_ISIS_P2P_HELLO;
}
void
isis_holding_timeout(timer_s *timer) {
isis_adjacency_t *adjacency = timer->data;
LOG(ISIS, "ISIS %s holding timeout on interface %s\n",
isis_level_string(adjacency->level), adjacency->interface->name);
isis_adjacency_down(adjacency);
isis_lsp_self_update(adjacency->instance, adjacency->level);
}
static void
isis_p2p_reset_holding_timers(bbl_interface_s *interface) {
isis_adjacency_t *adjacency;
for(int i=0; i<ISIS_LEVELS; i++) {
adjacency = interface->isis_adjacency[i];
if(adjacency) {
timer_add(&interface->ctx->timer_root, &adjacency->timer_holding,
"ISIS holding", adjacency->peer->holding_time, 0, adjacency,
&isis_holding_timeout);
}
}
}
/**
* isis_p2p_hello_encode
*
@@ -39,20 +64,6 @@ isis_p2p_hello_encode(bbl_interface_s *interface,
isis_auth_type auth = ISIS_AUTH_NONE;
char *key = NULL;
if(adjacency->timeout > 3 && adjacency->state != ISIS_P2P_ADJACENCY_STATE_DOWN) {
LOG(ISIS, "ISIS P2P-Hello timeout on interface %s\n",
interface->name);
adjacency->state = ISIS_P2P_ADJACENCY_STATE_DOWN;
for(int i=0; i<ISIS_LEVELS; i++) {
if(interface->isis_adjacency[i]) {
isis_adjacency_down(interface->isis_adjacency[i]);
isis_lsp_self_update(adjacency->instance, i+1);
}
}
}
/* Start next timer ... */
timer_add(&interface->ctx->timer_root, &interface->timer_isis_hello,
"ISIS hello", config->hello_interval, 0, interface,
@@ -98,7 +109,6 @@ isis_p2p_hello_encode(bbl_interface_s *interface,
LOG(DEBUG, "ISIS TX %s on interface %s\n",
isis_pdu_type_string(isis.type), interface->name);
adjacency->stats.hello_tx++;
adjacency->timeout++;
}
return result;
}
@@ -145,13 +155,14 @@ isis_p2p_hello_handler_rx(bbl_interface_s *interface, isis_pdu_t *pdu) {
LOG(ISIS, "ISIS RX P2P-Hello authentication failed on interface %s\n",
adjacency->interface->name);
}
adjacency->timeout = 0;
peer = adjacency->peer;
peer->level = *PDU_OFFSET(pdu, ISIS_OFFSET_P2P_HELLO_LEVEL) & 0x03;
memcpy(peer->system_id, PDU_OFFSET(pdu, ISIS_OFFSET_P2P_HELLO_SYSTEM_ID), ISIS_SYSTEM_ID_LEN);
peer->holding_time = be16toh(*(uint16_t*)PDU_OFFSET(pdu, ISIS_OFFSET_P2P_HELLO_HOLD_TIME));
isis_p2p_reset_holding_timers(interface);
tlv = isis_pdu_first_tlv(pdu);
while(tlv) {
switch (tlv->type) {