From f64adebdee6be8f17b8dec66b8dcce0b1a869220 Mon Sep 17 00:00:00 2001 From: Isabella de Leon Date: Tue, 28 Mar 2023 16:18:59 -0700 Subject: [PATCH] isisd: Add PDU drop counter to "show isis summary" Adding a new drop counters section to "show isis summary". New output: Drop counters per PDU type: P2P IIH: L2 LSP: L2 CSNP: L2 PSNP: ... Before: r1# show isis summary vrf : default Process Id : 972 System Id : 0000.0000.0001 Up time : 00:00:48 ago Number of areas : 1 Area TE: Net: 49.0000.0000.0000.0001.00 TX counters per PDU type: P2P IIH: 36 L2 LSP: 8 L2 CSNP: 12 L2 PSNP: 11 RX counters per PDU type: P2P IIH: 37 L2 LSP: 17 L2 CSNP: 12 L2 PSNP: 6 Advertise high metrics: Disabled ... After: r1# show isis summary vrf : default Process Id : 972 System Id : 0000.0000.0001 Up time : 00:00:19 ago Number of areas : 1 Area TE: Net: 49.0000.0000.0000.0001.00 TX counters per PDU type: P2P IIH: 16 L2 LSP: 2 L2 CSNP: 4 L2 PSNP: 6 LSP RXMT: 0 RX counters per PDU type: P2P IIH: 16 L2 LSP: 5 L2 CSNP: 4 L2 PSNP: 2 Drop counters per PDU type: P2P IIH: 2 Advertise high metrics: Disabled ... Signed-off-by: Isabella de Leon --- isisd/isis_pdu.c | 29 +++++++++++++++++++++++++---- isisd/isisd.c | 3 +++ isisd/isisd.h | 1 + 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c index dd442840d0..d53d43ad0e 100644 --- a/isisd/isis_pdu.c +++ b/isisd/isis_pdu.c @@ -1654,12 +1654,14 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) if (idrp == ISO9542_ESIS) { flog_err(EC_LIB_DEVELOPMENT, "No support for ES-IS packet IDRP=%hhx", idrp); + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_ERROR; } if (idrp != ISO10589_ISIS) { flog_err(EC_ISIS_PACKET, "Not an IS-IS packet IDRP=%hhx", idrp); + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_ERROR; } @@ -1670,6 +1672,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) isis_notif_version_skew(circuit, version1, raw_pdu, sizeof(raw_pdu)); #endif /* ifndef FABRICD */ + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_WARNING; } @@ -1693,12 +1696,14 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) isis_notif_id_len_mismatch(circuit, id_len, raw_pdu, sizeof(raw_pdu)); #endif /* ifndef FABRICD */ + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_ERROR; } uint8_t expected_length; if (pdu_size(pdu_type, &expected_length)) { zlog_warn("Unsupported ISIS PDU %hhu", pdu_type); + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_WARNING; } @@ -1706,6 +1711,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) flog_err(EC_ISIS_PACKET, "Expected fixed header length = %hhu but got %hhu", expected_length, length); + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_ERROR; } @@ -1713,6 +1719,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) flog_err( EC_ISIS_PACKET, "PDU is too short to contain fixed header of given PDU type."); + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_ERROR; } @@ -1723,12 +1730,14 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) isis_notif_version_skew(circuit, version2, raw_pdu, sizeof(raw_pdu)); #endif /* ifndef FABRICD */ + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_WARNING; } if (circuit->is_passive) { zlog_warn("Received ISIS PDU on passive circuit %s", circuit->interface->name); + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_WARNING; } @@ -1747,6 +1756,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) isis_notif_max_area_addr_mismatch(circuit, max_area_addrs, raw_pdu, sizeof(raw_pdu)); #endif /* ifndef FABRICD */ + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_ERROR; } @@ -1754,17 +1764,24 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) case L1_LAN_HELLO: case L2_LAN_HELLO: case P2P_HELLO: - if (fabricd && pdu_type != P2P_HELLO) + if (fabricd && pdu_type != P2P_HELLO) { + pdu_counter_count(circuit->area->pdu_drop_counters, + pdu_type); return ISIS_ERROR; + } + retval = process_hello(pdu_type, circuit, ssnpa); break; case L1_LINK_STATE: case L2_LINK_STATE: case FS_LINK_STATE: - if (fabricd - && pdu_type != L2_LINK_STATE - && pdu_type != FS_LINK_STATE) + if (fabricd && pdu_type != L2_LINK_STATE && + pdu_type != FS_LINK_STATE) { + pdu_counter_count(circuit->area->pdu_drop_counters, + pdu_type); return ISIS_ERROR; + } + retval = process_lsp(pdu_type, circuit, ssnpa, max_area_addrs); break; case L1_COMPLETE_SEQ_NUM: @@ -1774,9 +1791,13 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) retval = process_snp(pdu_type, circuit, ssnpa); break; default: + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_ERROR; } + if (retval != ISIS_OK) + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); + return retval; } diff --git a/isisd/isisd.c b/isisd/isisd.c index d216d100e1..c6369a884e 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -2503,6 +2503,9 @@ static void common_isis_summary_vty(struct vty *vty, struct isis *isis) vty_out(vty, " RX counters per PDU type:\n"); pdu_counter_print(vty, " ", area->pdu_rx_counters); + vty_out(vty, " Drop counters per PDU type:\n"); + pdu_counter_print(vty, " ", area->pdu_drop_counters); + vty_out(vty, " Advertise high metrics: %s\n", area->advertise_high_metrics ? "Enabled" : "Disabled"); diff --git a/isisd/isisd.h b/isisd/isisd.h index a06dc46a38..0b1f1cb620 100644 --- a/isisd/isisd.h +++ b/isisd/isisd.h @@ -232,6 +232,7 @@ struct isis_area { pdu_counter_t pdu_tx_counters; pdu_counter_t pdu_rx_counters; + pdu_counter_t pdu_drop_counters; uint64_t lsp_rxmt_count; /* Area counters */ -- 2.39.5