mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-04-29 04:25:43 +00:00
isisd: Provide statistics about sent/received PDU count
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
This commit is contained in:
parent
2cd971af00
commit
39bb53d67a
@ -58,6 +58,7 @@
|
||||
#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)
|
||||
@ -88,6 +89,7 @@ static int ack_lsp(struct isis_lsp_hdr *hdr, struct isis_circuit *circuit,
|
||||
/* 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,
|
||||
@ -1436,6 +1438,8 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa)
|
||||
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);
|
||||
@ -1588,15 +1592,18 @@ void fill_fixed_hdr(uint8_t pdu_type, struct stream *stream)
|
||||
stream_putc(stream, 0); /* Max Area Addresses 0 => 3 */
|
||||
}
|
||||
|
||||
static uint8_t hello_pdu_type(struct isis_circuit *circuit, int level)
|
||||
{
|
||||
if (circuit->circ_type == CIRCUIT_T_BROADCAST)
|
||||
return (level == IS_LEVEL_1) ? L1_LAN_HELLO : L2_LAN_HELLO;
|
||||
else
|
||||
return P2P_HELLO;
|
||||
}
|
||||
|
||||
static void put_hello_hdr(struct isis_circuit *circuit, int level,
|
||||
size_t *len_pointer)
|
||||
{
|
||||
uint8_t pdu_type;
|
||||
|
||||
if (circuit->circ_type == CIRCUIT_T_BROADCAST)
|
||||
pdu_type = (level == IS_LEVEL_1) ? L1_LAN_HELLO : L2_LAN_HELLO;
|
||||
else
|
||||
pdu_type = P2P_HELLO;
|
||||
uint8_t pdu_type = hello_pdu_type(circuit, level);
|
||||
|
||||
isis_circuit_stream(circuit, &circuit->snd_stream);
|
||||
fill_fixed_hdr(pdu_type, circuit->snd_stream);
|
||||
@ -1739,6 +1746,7 @@ int send_hello(struct isis_circuit *circuit, int level)
|
||||
|
||||
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,
|
||||
@ -1865,10 +1873,11 @@ int send_csnp(struct isis_circuit *circuit, int level)
|
||||
|| 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);
|
||||
@ -1950,6 +1959,7 @@ int send_csnp(struct isis_circuit *circuit, int level)
|
||||
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,
|
||||
@ -2043,10 +2053,11 @@ static int send_psnp(int level, struct isis_circuit *circuit)
|
||||
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 */
|
||||
@ -2117,6 +2128,7 @@ static int send_psnp(int level, struct isis_circuit *circuit)
|
||||
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,
|
||||
@ -2255,7 +2267,12 @@ void send_lsp(struct isis_circuit *circuit, struct isis_lsp *lsp,
|
||||
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,
|
||||
|
104
isisd/isis_pdu_counter.c
Normal file
104
isisd/isis_pdu_counter.c
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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]);
|
||||
}
|
||||
}
|
41
isisd/isis_pdu_counter.h
Normal file
41
isisd/isis_pdu_counter.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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
|
@ -1258,6 +1258,11 @@ DEFUN (show_isis_summary,
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -28,6 +28,7 @@
|
||||
#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"
|
||||
@ -168,6 +169,9 @@ struct isis_area {
|
||||
|
||||
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)
|
||||
|
@ -43,6 +43,7 @@ noinst_HEADERS += \
|
||||
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 \
|
||||
@ -74,6 +75,7 @@ LIBISIS_SOURCES = \
|
||||
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 \
|
||||
|
Loading…
Reference in New Issue
Block a user