#include "isisd/isis_errors.h"
#include "isisd/fabricd.h"
#include "isisd/isis_tx_queue.h"
+#include "isisd/isis_pdu_counter.h"
static int ack_lsp(struct isis_lsp_hdr *hdr, struct isis_circuit *circuit,
int level)
/* Update PDU length */
stream_putw_at(circuit->snd_stream, lenp, length);
+ pdu_counter_count(circuit->area->pdu_tx_counters, pdu_type);
retval = circuit->tx(circuit, level);
if (retval != ISIS_OK)
flog_err(EC_ISIS_PACKET,
stream_forward_getp(circuit->rcv_stream, 1); /* reserved */
uint8_t max_area_addrs = stream_getc(circuit->rcv_stream);
+ pdu_counter_count(circuit->area->pdu_rx_counters, pdu_type);
+
if (idrp == ISO9542_ESIS) {
flog_err(EC_LIB_DEVELOPMENT,
"No support for ES-IS packet IDRP=%" PRIx8, idrp);
stream_putc(stream, 0); /* Max Area Addresses 0 => 3 */
}
-static void put_hello_hdr(struct isis_circuit *circuit, int level,
- size_t *len_pointer)
+static uint8_t hello_pdu_type(struct isis_circuit *circuit, int level)
{
- uint8_t pdu_type;
-
if (circuit->circ_type == CIRCUIT_T_BROADCAST)
- pdu_type = (level == IS_LEVEL_1) ? L1_LAN_HELLO : L2_LAN_HELLO;
+ return (level == IS_LEVEL_1) ? L1_LAN_HELLO : L2_LAN_HELLO;
else
- pdu_type = P2P_HELLO;
+ return P2P_HELLO;
+}
+
+static void put_hello_hdr(struct isis_circuit *circuit, int level,
+ size_t *len_pointer)
+{
+ uint8_t pdu_type = hello_pdu_type(circuit, level);
isis_circuit_stream(circuit, &circuit->snd_stream);
fill_fixed_hdr(pdu_type, circuit->snd_stream);
isis_free_tlvs(tlvs);
+ pdu_counter_count(circuit->area->pdu_tx_counters, hello_pdu_type(circuit, level));
retval = circuit->tx(circuit, level);
if (retval != ISIS_OK)
flog_err(EC_ISIS_PACKET,
|| dict_count(circuit->area->lspdb[level - 1]) == 0)
return ISIS_OK;
+ uint8_t pdu_type = (level == ISIS_LEVEL1) ? L1_COMPLETE_SEQ_NUM
+ : L2_COMPLETE_SEQ_NUM;
+
isis_circuit_stream(circuit, &circuit->snd_stream);
- fill_fixed_hdr((level == ISIS_LEVEL1) ? L1_COMPLETE_SEQ_NUM
- : L2_COMPLETE_SEQ_NUM,
- circuit->snd_stream);
+ fill_fixed_hdr(pdu_type, circuit->snd_stream);
size_t len_pointer = stream_get_endp(circuit->snd_stream);
stream_putw(circuit->snd_stream, 0);
stream_get_endp(circuit->snd_stream));
}
+ pdu_counter_count(circuit->area->pdu_tx_counters, pdu_type);
int retval = circuit->tx(circuit, level);
if (retval != ISIS_OK) {
flog_err(EC_ISIS_PACKET,
if (!circuit->snd_stream)
return ISIS_ERROR;
+ uint8_t pdu_type = (level == ISIS_LEVEL1) ? L1_PARTIAL_SEQ_NUM
+ : L2_PARTIAL_SEQ_NUM;
+
isis_circuit_stream(circuit, &circuit->snd_stream);
- fill_fixed_hdr((level == ISIS_LEVEL1) ? L1_PARTIAL_SEQ_NUM
- : L2_PARTIAL_SEQ_NUM,
- circuit->snd_stream);
+ fill_fixed_hdr(pdu_type, circuit->snd_stream);
size_t len_pointer = stream_get_endp(circuit->snd_stream);
stream_putw(circuit->snd_stream, 0); /* length is filled in later */
stream_get_endp(circuit->snd_stream));
}
+ pdu_counter_count(circuit->area->pdu_tx_counters, pdu_type);
int retval = circuit->tx(circuit, level);
if (retval != ISIS_OK) {
flog_err(EC_ISIS_PACKET,
stream_get_endp(circuit->snd_stream));
}
+ uint8_t pdu_type = (tx_type == TX_LSP_CIRCUIT_SCOPED) ? FS_LINK_STATE
+ : (lsp->level == ISIS_LEVEL1) ? L1_LINK_STATE
+ : L2_LINK_STATE;
+
clear_srm = 0;
+ pdu_counter_count(circuit->area->pdu_tx_counters, pdu_type);
retval = circuit->tx(circuit, lsp->level);
if (retval != ISIS_OK) {
flog_err(EC_ISIS_PACKET,
--- /dev/null
+/*
+ * IS-IS Routing protocol - isis_pdu_counter.c
+ * Copyright (C) 2018 Christian Franke, for NetDEF Inc.
+ *
+ * This program 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 of the License, or (at your option)
+ * any later version.
+ *
+ * This program 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 "vty.h"
+
+#include "isisd/isis_pdu_counter.h"
+#include "isisd/isisd.h"
+#include "isisd/isis_circuit.h"
+#include "isisd/isis_pdu.h"
+
+static int pdu_type_to_counter_index(uint8_t pdu_type)
+{
+ switch (pdu_type) {
+ case L1_LAN_HELLO:
+ return L1_LAN_HELLO_INDEX;
+ case L2_LAN_HELLO:
+ return L2_LAN_HELLO_INDEX;
+ case P2P_HELLO:
+ return P2P_HELLO_INDEX;
+ case L1_LINK_STATE:
+ return L1_LINK_STATE_INDEX;
+ case L2_LINK_STATE:
+ return L2_LINK_STATE_INDEX;
+ case FS_LINK_STATE:
+ return FS_LINK_STATE_INDEX;
+ case L1_COMPLETE_SEQ_NUM:
+ return L1_COMPLETE_SEQ_NUM_INDEX;
+ case L2_COMPLETE_SEQ_NUM:
+ return L2_COMPLETE_SEQ_NUM_INDEX;
+ case L1_PARTIAL_SEQ_NUM:
+ return L1_PARTIAL_SEQ_NUM_INDEX;
+ case L2_PARTIAL_SEQ_NUM:
+ return L2_PARTIAL_SEQ_NUM_INDEX;
+ default:
+ return -1;
+ }
+}
+
+static const char *pdu_counter_index_to_name(enum pdu_counter_index index)
+{
+ switch(index) {
+ case L1_LAN_HELLO_INDEX:
+ return " L1 IIH";
+ case L2_LAN_HELLO_INDEX:
+ return " L2 IIH";
+ case P2P_HELLO_INDEX:
+ return "P2P IIH";
+ case L1_LINK_STATE_INDEX:
+ return " L1 LSP";
+ case L2_LINK_STATE_INDEX:
+ return " L2 LSP";
+ case FS_LINK_STATE_INDEX:
+ return " FS LSP";
+ case L1_COMPLETE_SEQ_NUM_INDEX:
+ return "L1 CSNP";
+ case L2_COMPLETE_SEQ_NUM_INDEX:
+ return "L2 CSNP";
+ case L1_PARTIAL_SEQ_NUM_INDEX:
+ return "L1 PSNP";
+ case L2_PARTIAL_SEQ_NUM_INDEX:
+ return "L2 PSNP";
+ default:
+ return "???????";
+ }
+}
+
+void pdu_counter_count(pdu_counter_t counter, uint8_t pdu_type)
+{
+ int index = pdu_type_to_counter_index(pdu_type);
+
+ if (index < 0)
+ return;
+
+ counter[index]++;
+}
+
+void pdu_counter_print(struct vty *vty, const char *prefix,
+ pdu_counter_t counter)
+{
+ for (int i = 0; i < PDU_COUNTER_SIZE; i++) {
+ if (!counter[i])
+ continue;
+ vty_out(vty, "%s%s: %" PRIu64 "\n", prefix,
+ pdu_counter_index_to_name(i), counter[i]);
+ }
+}
--- /dev/null
+/*
+ * IS-IS Routing protocol - isis_pdu_counter.c
+ * Copyright (C) 2018 Christian Franke, for NetDEF Inc.
+ *
+ * This program 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 of the License, or (at your option)
+ * any later version.
+ *
+ * This program 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
+ */
+#ifndef ISIS_PDU_COUNTER_H
+#define ISIS_PDU_COUNTER_H
+
+enum pdu_counter_index {
+ L1_LAN_HELLO_INDEX = 0,
+ L2_LAN_HELLO_INDEX,
+ P2P_HELLO_INDEX,
+ L1_LINK_STATE_INDEX,
+ L2_LINK_STATE_INDEX,
+ FS_LINK_STATE_INDEX,
+ L1_COMPLETE_SEQ_NUM_INDEX,
+ L2_COMPLETE_SEQ_NUM_INDEX,
+ L1_PARTIAL_SEQ_NUM_INDEX,
+ L2_PARTIAL_SEQ_NUM_INDEX,
+ PDU_COUNTER_SIZE
+};
+typedef uint64_t pdu_counter_t[PDU_COUNTER_SIZE];
+
+void pdu_counter_print(struct vty *vty, const char *prefix,
+ pdu_counter_t counter);
+void pdu_counter_count(pdu_counter_t counter, uint8_t pdu_type);
+
+#endif
}
}
+ vty_out(vty, " TX counters per PDU type:\n");
+ pdu_counter_print(vty, " ", area->pdu_tx_counters);
+ vty_out(vty, " RX counters per PDU type:\n");
+ pdu_counter_print(vty, " ", area->pdu_rx_counters);
+
for (level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) {
if ((area->is_type & level) == 0)
continue;
#include "isisd/isis_constants.h"
#include "isisd/isis_common.h"
#include "isisd/isis_redist.h"
+#include "isisd/isis_pdu_counter.h"
#include "isis_flags.h"
#include "dict.h"
#include "isis_memory.h"
struct lsp_refresh_arg lsp_refresh_arg[ISIS_LEVELS];
+ pdu_counter_t pdu_tx_counters;
+ pdu_counter_t pdu_rx_counters;
+
QOBJ_FIELDS
};
DECLARE_QOBJ_TYPE(isis_area)
isisd/isis_mt.h \
isisd/isis_network.h \
isisd/isis_pdu.h \
+ isisd/isis_pdu_counter.h \
isisd/isis_redist.h \
isisd/isis_route.h \
isisd/isis_routemap.h \
isisd/isis_misc.c \
isisd/isis_mt.c \
isisd/isis_pdu.c \
+ isisd/isis_pdu_counter.c \
isisd/isis_redist.c \
isisd/isis_route.c \
isisd/isis_routemap.c \