]> git.proxmox.com Git - mirror_frr.git/commitdiff
isisd: Add debug output for tx-queues
authorChristian Franke <chris@opensourcerouting.org>
Fri, 16 Nov 2018 15:05:54 +0000 (16:05 +0100)
committerRodny Molina <rmolina@linkedin.com>
Fri, 7 Dec 2018 19:45:14 +0000 (19:45 +0000)
To allow easier debugging of LSP transmission scheduling, add a debug
mode where all tx-queue insertions/deletions are logged.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
isisd/isis_pdu.c
isisd/isis_pdu.h
isisd/isis_tx_queue.c
isisd/isis_tx_queue.h
isisd/isisd.c
isisd/isisd.h

index 900ce9f922e9a6dd5bd08f92b3797a83929053f7..4720b044ec123fce33190d963a991269e324620b 100644 (file)
@@ -2182,9 +2182,9 @@ int send_l2_psnp(struct thread *thread)
 /*
  * ISO 10589 - 7.3.14.3
  */
-void send_lsp(void *arg, struct isis_lsp *lsp, enum isis_tx_type tx_type)
+void send_lsp(struct isis_circuit *circuit, struct isis_lsp *lsp,
+             enum isis_tx_type tx_type)
 {
-       struct isis_circuit *circuit = arg;
        int clear_srm = 1;
        int retval = ISIS_OK;
 
@@ -2233,10 +2233,13 @@ void send_lsp(void *arg, struct isis_lsp *lsp, enum isis_tx_type tx_type)
        }
 
        if (isis->debugs & DEBUG_UPDATE_PACKETS) {
-               zlog_debug("ISIS-Upd (%s): Sending L%d LSP %s, seq 0x%08" PRIx32
+               zlog_debug("ISIS-Upd (%s): Sending %sL%d LSP %s, seq 0x%08" PRIx32
                           ", cksum 0x%04" PRIx16 ", lifetime %" PRIu16
                           "s on %s",
-                          circuit->area->area_tag, lsp->level,
+                          circuit->area->area_tag,
+                          (tx_type == TX_LSP_CIRCUIT_SCOPED)
+                               ? "Circuit scoped " : "",
+                          lsp->level,
                           rawlspid_print(lsp->hdr.lsp_id), lsp->hdr.seqno,
                           lsp->hdr.checksum, lsp->hdr.rem_lifetime,
                           circuit->interface->name);
index 0fa3b2c7ab06a40a83faaaa76aa5551746739dca..1e70a42f132121e0a9baa66ea1a20fb49a64379e 100644 (file)
@@ -214,7 +214,8 @@ int send_l1_csnp(struct thread *thread);
 int send_l2_csnp(struct thread *thread);
 int send_l1_psnp(struct thread *thread);
 int send_l2_psnp(struct thread *thread);
-void send_lsp(void *arg, struct isis_lsp *lsp, enum isis_tx_type tx_type);
+void send_lsp(struct isis_circuit *circuit,
+             struct isis_lsp *lsp, enum isis_tx_type tx_type);
 void fill_fixed_hdr(uint8_t pdu_type, struct stream *stream);
 int send_hello(struct isis_circuit *circuit, int level);
 int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa);
index fe67a3f4d19794b6c5d5871301d6f1b0efa87ce4..46d1595f0632f7cf9ed642d0c56a43288f29688c 100644 (file)
 #include "dict.h"
 #include "isisd/isis_circuit.h"
 #include "isisd/isis_lsp.h"
+#include "isisd/isis_misc.h"
 #include "isisd/isis_tx_queue.h"
 
 DEFINE_MTYPE_STATIC(ISISD, TX_QUEUE, "ISIS TX Queue")
 DEFINE_MTYPE_STATIC(ISISD, TX_QUEUE_ENTRY, "ISIS TX Queue Entry")
 
 struct isis_tx_queue {
-       void *arg;
-       void (*send_event)(void *arg, struct isis_lsp *, enum isis_tx_type);
+       struct isis_circuit *circuit;
+       void (*send_event)(struct isis_circuit *circuit,
+                          struct isis_lsp *, enum isis_tx_type);
        struct hash *hash;
 };
 
@@ -72,14 +74,15 @@ static bool tx_queue_hash_cmp(const void *a, const void *b)
        return true;
 }
 
-struct isis_tx_queue *isis_tx_queue_new(void *arg,
-                                       void(*send_event)(void *arg,
-                                                         struct isis_lsp *,
-                                                         enum isis_tx_type))
+struct isis_tx_queue *isis_tx_queue_new(
+               struct isis_circuit *circuit,
+               void(*send_event)(struct isis_circuit *circuit,
+                                 struct isis_lsp *,
+                                 enum isis_tx_type))
 {
        struct isis_tx_queue *rv = XCALLOC(MTYPE_TX_QUEUE, sizeof(*rv));
 
-       rv->arg = arg;
+       rv->circuit = circuit;
        rv->send_event = send_event;
 
        rv->hash = hash_create(tx_queue_hash_key, tx_queue_hash_cmp, NULL);
@@ -121,19 +124,30 @@ static int tx_queue_send_event(struct thread *thread)
        e->retry = NULL;
        thread_add_timer(master, tx_queue_send_event, e, 5, &e->retry);
 
-       queue->send_event(queue->arg, e->lsp, e->type);
+       queue->send_event(queue->circuit, e->lsp, e->type);
        /* Don't access e here anymore, send_event might have destroyed it */
 
        return 0;
 }
 
-void isis_tx_queue_add(struct isis_tx_queue *queue,
-                      struct isis_lsp *lsp,
-                      enum isis_tx_type type)
+void _isis_tx_queue_add(struct isis_tx_queue *queue,
+                       struct isis_lsp *lsp,
+                       enum isis_tx_type type,
+                       const char *func, const char *file,
+                       int line)
 {
        if (!queue)
                return;
 
+       if (isis->debugs & DEBUG_TX_QUEUE) {
+               zlog_debug("Add LSP %s to %s queue as %s LSP. (From %s %s:%d)",
+                          rawlspid_print(lsp->hdr.lsp_id),
+                          queue->circuit->interface->name,
+                          (type == TX_LSP_CIRCUIT_SCOPED) ?
+                          "circuit scoped" : "regular",
+                          func, file, line);
+       }
+
        struct isis_tx_queue_entry *e = tx_queue_find(queue, lsp);
        if (!e) {
                e = XCALLOC(MTYPE_TX_QUEUE_ENTRY, sizeof(*e));
@@ -152,7 +166,8 @@ void isis_tx_queue_add(struct isis_tx_queue *queue,
        thread_add_event(master, tx_queue_send_event, e, 0, &e->retry);
 }
 
-void isis_tx_queue_del(struct isis_tx_queue *queue, struct isis_lsp *lsp)
+void _isis_tx_queue_del(struct isis_tx_queue *queue, struct isis_lsp *lsp,
+                       const char *func, const char *file, int line)
 {
        if (!queue)
                return;
@@ -161,6 +176,13 @@ void isis_tx_queue_del(struct isis_tx_queue *queue, struct isis_lsp *lsp)
        if (!e)
                return;
 
+       if (isis->debugs & DEBUG_TX_QUEUE) {
+               zlog_debug("Remove LSP %s from %s queue. (From %s %s:%d)",
+                          rawlspid_print(lsp->hdr.lsp_id),
+                          queue->circuit->interface->name,
+                          func, file, line);
+       }
+
        if (e->retry)
                thread_cancel(e->retry);
 
index ddecdf1e4f5589ec46c070daba53a78bc8472f21..7b01f1a3d4f83d9a1a95c77c785ed146a9326fb4 100644 (file)
@@ -29,18 +29,26 @@ enum isis_tx_type {
 
 struct isis_tx_queue;
 
-struct isis_tx_queue *isis_tx_queue_new(void *arg,
-                                       void(*send_event)(void *arg,
-                                                         struct isis_lsp *,
-                                                         enum isis_tx_type));
+struct isis_tx_queue *isis_tx_queue_new(
+               struct isis_circuit *circuit,
+               void(*send_event)(struct isis_circuit *circuit,
+                                 struct isis_lsp *,
+                                 enum isis_tx_type)
+);
 
 void isis_tx_queue_free(struct isis_tx_queue *queue);
 
-void isis_tx_queue_add(struct isis_tx_queue *queue,
-                      struct isis_lsp *lsp,
-                      enum isis_tx_type type);
-
-void isis_tx_queue_del(struct isis_tx_queue *queue, struct isis_lsp *lsp);
+#define isis_tx_queue_add(queue, lsp, type) \
+       _isis_tx_queue_add((queue), (lsp), (type), \
+                          __func__, __FILE__, __LINE__)
+void _isis_tx_queue_add(struct isis_tx_queue *queue, struct isis_lsp *lsp,
+                       enum isis_tx_type type, const char *func,
+                       const char *file, int line);
+
+#define isis_tx_queue_del(queue, lsp) \
+       _isis_tx_queue_del((queue), (lsp), __func__, __FILE__, __LINE__)
+void _isis_tx_queue_del(struct isis_tx_queue *queue, struct isis_lsp *lsp,
+                       const char *func, const char *file, int line);
 
 unsigned long isis_tx_queue_len(struct isis_tx_queue *queue);
 
index ce45ba65ece61f764b38513d10ad501cac77f223..279f7bfee1c5dbb81adf15bfd03c706419897362 100644 (file)
@@ -720,6 +720,9 @@ void print_debug(struct vty *vty, int flags, int onoff)
                vty_out(vty,
                        "IS-IS Adjacency related packets debugging is %s\n",
                        onoffs);
+       if (flags & DEBUG_TX_QUEUE)
+               vty_out(vty, "IS-IS TX queue debugging is %s\n",
+                       onoffs);
        if (flags & DEBUG_SNP_PACKETS)
                vty_out(vty, "IS-IS CSNP/PSNP packets debugging is %s\n",
                        onoffs);
@@ -771,6 +774,10 @@ static int config_write_debug(struct vty *vty)
                vty_out(vty, "debug " PROTO_NAME " adj-packets\n");
                write++;
        }
+       if (flags & DEBUG_TX_QUEUE) {
+               vty_out(vty, "debug " PROTO_NAME " tx-queue\n");
+               write++;
+       }
        if (flags & DEBUG_SNP_PACKETS) {
                vty_out(vty, "debug " PROTO_NAME " snp-packets\n");
                write++;
@@ -843,6 +850,33 @@ DEFUN (no_debug_isis_adj,
        return CMD_SUCCESS;
 }
 
+DEFUN (debug_isis_tx_queue,
+       debug_isis_tx_queue_cmd,
+       "debug " PROTO_NAME " tx-queue",
+       DEBUG_STR
+       PROTO_HELP
+       "IS-IS TX queues\n")
+{
+       isis->debugs |= DEBUG_TX_QUEUE;
+       print_debug(vty, DEBUG_TX_QUEUE, 1);
+
+       return CMD_SUCCESS;
+}
+
+DEFUN (no_debug_isis_tx_queue,
+       no_debug_isis_tx_queue_cmd,
+       "no debug " PROTO_NAME " tx-queue",
+       NO_STR
+       UNDEBUG_STR
+       PROTO_HELP
+       "IS-IS TX queues\n")
+{
+       isis->debugs &= ~DEBUG_TX_QUEUE;
+       print_debug(vty, DEBUG_TX_QUEUE, 0);
+
+       return CMD_SUCCESS;
+}
+
 DEFUN (debug_isis_snp,
        debug_isis_snp_cmd,
        "debug " PROTO_NAME " snp-packets",
@@ -2061,6 +2095,8 @@ void isis_init()
 
        install_element(ENABLE_NODE, &debug_isis_adj_cmd);
        install_element(ENABLE_NODE, &no_debug_isis_adj_cmd);
+       install_element(ENABLE_NODE, &debug_isis_tx_queue_cmd);
+       install_element(ENABLE_NODE, &no_debug_isis_tx_queue_cmd);
        install_element(ENABLE_NODE, &debug_isis_snp_cmd);
        install_element(ENABLE_NODE, &no_debug_isis_snp_cmd);
        install_element(ENABLE_NODE, &debug_isis_upd_cmd);
@@ -2082,6 +2118,8 @@ void isis_init()
 
        install_element(CONFIG_NODE, &debug_isis_adj_cmd);
        install_element(CONFIG_NODE, &no_debug_isis_adj_cmd);
+       install_element(CONFIG_NODE, &debug_isis_tx_queue_cmd);
+       install_element(CONFIG_NODE, &no_debug_isis_tx_queue_cmd);
        install_element(CONFIG_NODE, &debug_isis_snp_cmd);
        install_element(CONFIG_NODE, &no_debug_isis_snp_cmd);
        install_element(CONFIG_NODE, &debug_isis_upd_cmd);
index fe9abff93c1b19aa42953ef1c4a64cf51ac404e1..95fdb971b1514d0db0d354205928b2abfafeb1f9 100644 (file)
@@ -214,6 +214,7 @@ extern struct thread_master *master;
 #define DEBUG_LSP_SCHED                  (1<<8)
 #define DEBUG_FABRICD_FLOODING           (1<<9)
 #define DEBUG_BFD                        (1<<10)
+#define DEBUG_TX_QUEUE                   (1<<11)
 
 #define lsp_debug(...)                                                         \
        do {                                                                   \