]> git.proxmox.com Git - mirror_frr.git/blobdiff - isisd/isis_pdu.c
Merge pull request #12698 from Orange-OpenSource/isisd
[mirror_frr.git] / isisd / isis_pdu.c
index 9e5a6d23ae1ceded184f7e7780b48ea85d6baabc..0b84289f2d567962316295c57cde3a11a75ccc80 100644 (file)
@@ -11,7 +11,7 @@
 #include <zebra.h>
 
 #include "memory.h"
-#include "thread.h"
+#include "frrevent.h"
 #include "linklist.h"
 #include "log.h"
 #include "stream.h"
@@ -192,9 +192,9 @@ static int process_p2p_hello(struct iih_info *iih)
                                      adj);
 
        /* lets take care of the expiry */
-       THREAD_OFF(adj->t_expire);
-       thread_add_timer(master, isis_adj_expire, adj, (long)adj->hold_time,
-                        &adj->t_expire);
+       EVENT_OFF(adj->t_expire);
+       event_add_timer(master, isis_adj_expire, adj, (long)adj->hold_time,
+                       &adj->t_expire);
 
        /* While fabricds initial sync is in progress, ignore hellos from other
         * interfaces than the one we are performing the initial sync on. */
@@ -466,8 +466,8 @@ static int process_lan_hello(struct iih_info *iih)
                                       : iih->circuit->u.bc.l2_desig_is;
 
                if (memcmp(dis, iih->dis, ISIS_SYS_ID_LEN + 1)) {
-                       thread_add_event(master, isis_event_dis_status_change,
-                                        iih->circuit, 0, NULL);
+                       event_add_event(master, isis_event_dis_status_change,
+                                       iih->circuit, 0, NULL);
                        memcpy(dis, iih->dis, ISIS_SYS_ID_LEN + 1);
                }
        }
@@ -484,9 +484,9 @@ static int process_lan_hello(struct iih_info *iih)
                                      adj);
 
        /* lets take care of the expiry */
-       THREAD_OFF(adj->t_expire);
-       thread_add_timer(master, isis_adj_expire, adj, (long)adj->hold_time,
-                        &adj->t_expire);
+       EVENT_OFF(adj->t_expire);
+       event_add_timer(master, isis_adj_expire, adj, (long)adj->hold_time,
+                       &adj->t_expire);
 
        /*
         * If the snpa for this circuit is found from LAN Neighbours TLV
@@ -1651,12 +1651,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;
        }
 
@@ -1667,6 +1669,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;
        }
 
@@ -1690,12 +1693,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;
        }
 
@@ -1703,6 +1708,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;
        }
 
@@ -1710,6 +1716,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;
        }
 
@@ -1720,12 +1727,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;
        }
 
@@ -1744,6 +1753,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;
        }
 
@@ -1751,17 +1761,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:
@@ -1771,13 +1788,17 @@ 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;
 }
 
-void isis_receive(struct thread *thread)
+void isis_receive(struct event *thread)
 {
        struct isis_circuit *circuit;
        uint8_t ssnpa[ETH_ALEN];
@@ -1785,7 +1806,7 @@ void isis_receive(struct thread *thread)
        /*
         * Get the circuit
         */
-       circuit = THREAD_ARG(thread);
+       circuit = EVENT_ARG(thread);
        assert(circuit);
 
        circuit->t_read = NULL;
@@ -2006,9 +2027,9 @@ int send_hello(struct isis_circuit *circuit, int level)
        return retval;
 }
 
-static void send_hello_cb(struct thread *thread)
+static void send_hello_cb(struct event *thread)
 {
-       struct isis_circuit_arg *arg = THREAD_ARG(thread);
+       struct isis_circuit_arg *arg = EVENT_ARG(thread);
        assert(arg);
 
        struct isis_circuit *circuit = arg->circuit;
@@ -2047,20 +2068,18 @@ static void send_hello_cb(struct thread *thread)
 }
 
 static void _send_hello_sched(struct isis_circuit *circuit,
-                             struct thread **threadp,
-                             int level, long delay)
+                             struct event **threadp, int level, long delay)
 {
        if (*threadp) {
-               if (thread_timer_remain_msec(*threadp) < (unsigned long)delay)
+               if (event_timer_remain_msec(*threadp) < (unsigned long)delay)
                        return;
 
-               THREAD_OFF(*threadp);
+               EVENT_OFF(*threadp);
        }
 
-       thread_add_timer_msec(master, send_hello_cb,
-                             &circuit->level_arg[level - 1],
-                             isis_jitter(delay, IIH_JITTER),
-                             threadp);
+       event_add_timer_msec(master, send_hello_cb,
+                            &circuit->level_arg[level - 1],
+                            isis_jitter(delay, IIH_JITTER), threadp);
 }
 
 void send_hello_sched(struct isis_circuit *circuit, int level, long delay)
@@ -2237,11 +2256,11 @@ int send_csnp(struct isis_circuit *circuit, int level)
        return ISIS_OK;
 }
 
-void send_l1_csnp(struct thread *thread)
+void send_l1_csnp(struct event *thread)
 {
        struct isis_circuit *circuit;
 
-       circuit = THREAD_ARG(thread);
+       circuit = EVENT_ARG(thread);
        assert(circuit);
 
        circuit->t_send_csnp[0] = NULL;
@@ -2252,16 +2271,16 @@ void send_l1_csnp(struct thread *thread)
                send_csnp(circuit, 1);
        }
        /* set next timer thread */
-       thread_add_timer(master, send_l1_csnp, circuit,
-                        isis_jitter(circuit->csnp_interval[0], CSNP_JITTER),
-                        &circuit->t_send_csnp[0]);
+       event_add_timer(master, send_l1_csnp, circuit,
+                       isis_jitter(circuit->csnp_interval[0], CSNP_JITTER),
+                       &circuit->t_send_csnp[0]);
 }
 
-void send_l2_csnp(struct thread *thread)
+void send_l2_csnp(struct event *thread)
 {
        struct isis_circuit *circuit;
 
-       circuit = THREAD_ARG(thread);
+       circuit = EVENT_ARG(thread);
        assert(circuit);
 
        circuit->t_send_csnp[1] = NULL;
@@ -2272,9 +2291,9 @@ void send_l2_csnp(struct thread *thread)
                send_csnp(circuit, 2);
        }
        /* set next timer thread */
-       thread_add_timer(master, send_l2_csnp, circuit,
-                        isis_jitter(circuit->csnp_interval[1], CSNP_JITTER),
-                        &circuit->t_send_csnp[1]);
+       event_add_timer(master, send_l2_csnp, circuit,
+                       isis_jitter(circuit->csnp_interval[1], CSNP_JITTER),
+                       &circuit->t_send_csnp[1]);
 }
 
 /*
@@ -2391,32 +2410,32 @@ static int send_psnp(int level, struct isis_circuit *circuit)
        return ISIS_OK;
 }
 
-void send_l1_psnp(struct thread *thread)
+void send_l1_psnp(struct event *thread)
 {
 
        struct isis_circuit *circuit;
 
-       circuit = THREAD_ARG(thread);
+       circuit = EVENT_ARG(thread);
        assert(circuit);
 
        circuit->t_send_psnp[0] = NULL;
 
        send_psnp(1, circuit);
        /* set next timer thread */
-       thread_add_timer(master, send_l1_psnp, circuit,
-                        isis_jitter(circuit->psnp_interval[0], PSNP_JITTER),
-                        &circuit->t_send_psnp[0]);
+       event_add_timer(master, send_l1_psnp, circuit,
+                       isis_jitter(circuit->psnp_interval[0], PSNP_JITTER),
+                       &circuit->t_send_psnp[0]);
 }
 
 /*
  *  7.3.15.4 action on expiration of partial SNP interval
  *  level 2
  */
-void send_l2_psnp(struct thread *thread)
+void send_l2_psnp(struct event *thread)
 {
        struct isis_circuit *circuit;
 
-       circuit = THREAD_ARG(thread);
+       circuit = EVENT_ARG(thread);
        assert(circuit);
 
        circuit->t_send_psnp[1] = NULL;
@@ -2424,9 +2443,9 @@ void send_l2_psnp(struct thread *thread)
        send_psnp(2, circuit);
 
        /* set next timer thread */
-       thread_add_timer(master, send_l2_psnp, circuit,
-                        isis_jitter(circuit->psnp_interval[1], PSNP_JITTER),
-                        &circuit->t_send_psnp[1]);
+       event_add_timer(master, send_l2_psnp, circuit,
+                       isis_jitter(circuit->psnp_interval[1], PSNP_JITTER),
+                       &circuit->t_send_psnp[1]);
 }
 
 /*