]> git.proxmox.com Git - mirror_frr.git/blobdiff - isisd/isis_pdu.c
Merge pull request #3402 from pacovn/Coverity_1475198_1475199
[mirror_frr.git] / isisd / isis_pdu.c
index 88575f531943770c7155aba12fa36757fd96a075..2f18b98d3f2d6c9ba9f8a7fd9c76c341a4593d90 100644 (file)
@@ -90,10 +90,10 @@ static int ack_lsp(struct isis_lsp_hdr *hdr, struct isis_circuit *circuit,
 
        retval = circuit->tx(circuit, level);
        if (retval != ISIS_OK)
-               flog_err(ISIS_ERR_PACKET,
-                         "ISIS-Upd (%s): Send L%d LSP PSNP on %s failed",
-                         circuit->area->area_tag, level,
-                         circuit->interface->name);
+               flog_err(EC_ISIS_PACKET,
+                        "ISIS-Upd (%s): Send L%d LSP PSNP on %s failed",
+                        circuit->area->area_tag, level,
+                        circuit->interface->name);
 
        return retval;
 }
@@ -625,9 +625,9 @@ static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit,
        }
 
        if (!p2p_hello && !(level & iih.circ_type)) {
-               flog_err(ISIS_ERR_PACKET,
-                         "Level %d LAN Hello with Circuit Type %d", level,
-                         iih.circ_type);
+               flog_err(EC_ISIS_PACKET,
+                        "Level %d LAN Hello with Circuit Type %d", level,
+                        iih.circ_type);
                return ISIS_ERROR;
        }
 
@@ -1011,19 +1011,26 @@ dontcheckadj:
                 * is
                 * "greater" than that held by S, ... */
 
-               if (hdr.seqno > lsp->hdr.seqno) {
+               if (comp == LSP_NEWER) {
                        /* 7.3.16.1  */
                        lsp_inc_seqno(lsp, hdr.seqno);
-                       if (isis->debugs & DEBUG_UPDATE_PACKETS)
+                       if (isis->debugs & DEBUG_UPDATE_PACKETS) {
                                zlog_debug(
                                        "ISIS-Upd (%s): (2) re-originating LSP %s new seq 0x%08" PRIx32,
                                        circuit->area->area_tag,
                                        rawlspid_print(hdr.lsp_id),
                                        lsp->hdr.seqno);
+                       }
+                       lsp_flood(lsp, NULL);
+               } else if (comp == LSP_EQUAL) {
+                       isis_tx_queue_del(circuit->tx_queue, lsp);
+                       if (circuit->circ_type != CIRCUIT_T_BROADCAST)
+                               ISIS_SET_FLAG(lsp->SSNflags, circuit);
+               } else {
+                       isis_tx_queue_add(circuit->tx_queue, lsp,
+                                         TX_LSP_NORMAL);
+                       ISIS_CLEAR_FLAG(lsp->SSNflags, circuit);
                }
-               /* If the received LSP is older or equal,
-                * resend the LSP which will act as ACK */
-               lsp_flood(lsp, NULL);
        } else {
                /* 7.3.15.1 e) - This lsp originated on another system */
 
@@ -1311,8 +1318,7 @@ static int process_snp(uint8_t pdu_type, struct isis_circuit *circuit,
                                                continue;
                                        }
                                }
-                               struct isis_lsp *lsp =
-                                       lsp_new(circuit->area, entry->id,
+                               lsp = lsp_new(circuit->area, entry->id,
                                                entry->rem_lifetime, 0, 0,
                                                entry->checksum, lsp0, level);
                                lsp_insert(lsp,
@@ -1357,7 +1363,7 @@ static int process_snp(uint8_t pdu_type, struct isis_circuit *circuit,
                }
 
                /* lets free it */
-               list_delete_and_null(&lsp_list);
+               list_delete(&lsp_list);
        }
 
        if (fabricd_initial_sync_is_complete(circuit->area) && resync_needed)
@@ -1409,7 +1415,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa)
 
        /* Verify that at least the 8 bytes fixed header have been received */
        if (stream_get_endp(circuit->rcv_stream) < ISIS_FIXED_HDR_LEN) {
-               flog_err(ISIS_ERR_PACKET, "PDU is too short to be IS-IS.");
+               flog_err(EC_ISIS_PACKET, "PDU is too short to be IS-IS.");
                return ISIS_ERROR;
        }
 
@@ -1424,14 +1430,14 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa)
        uint8_t max_area_addrs = stream_getc(circuit->rcv_stream);
 
        if (idrp == ISO9542_ESIS) {
-               flog_err(LIB_ERR_DEVELOPMENT,
-                         "No support for ES-IS packet IDRP=%" PRIx8, idrp);
+               flog_err(EC_LIB_DEVELOPMENT,
+                        "No support for ES-IS packet IDRP=%" PRIx8, idrp);
                return ISIS_ERROR;
        }
 
        if (idrp != ISO10589_ISIS) {
-               flog_err(ISIS_ERR_PACKET, "Not an IS-IS packet IDRP=%" PRIx8,
-                         idrp);
+               flog_err(EC_ISIS_PACKET, "Not an IS-IS packet IDRP=%" PRIx8,
+                        idrp);
                return ISIS_ERROR;
        }
 
@@ -1442,7 +1448,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa)
 
        if (id_len != 0 && id_len != ISIS_SYS_ID_LEN) {
                flog_err(
-                       ISIS_ERR_PACKET,
+                       EC_ISIS_PACKET,
                        "IDFieldLengthMismatch: ID Length field in a received PDU  %" PRIu8
                        ", while the parameter for this IS is %u",
                        id_len, ISIS_SYS_ID_LEN);
@@ -1456,16 +1462,16 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa)
        }
 
        if (length != expected_length) {
-               flog_err(ISIS_ERR_PACKET,
-                         "Exepected fixed header length = %" PRIu8
-                         " but got %" PRIu8,
-                         expected_length, length);
+               flog_err(EC_ISIS_PACKET,
+                        "Exepected fixed header length = %" PRIu8
+                        " but got %" PRIu8,
+                        expected_length, length);
                return ISIS_ERROR;
        }
 
        if (stream_get_endp(circuit->rcv_stream) < length) {
                flog_err(
-                       ISIS_ERR_PACKET,
+                       EC_ISIS_PACKET,
                        "PDU is too short to contain fixed header of given PDU type.");
                return ISIS_ERROR;
        }
@@ -1486,7 +1492,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa)
            && max_area_addrs != 0
            && max_area_addrs != isis->max_area_addrs) {
                flog_err(
-                       ISIS_ERR_PACKET,
+                       EC_ISIS_PACKET,
                        "maximumAreaAddressesMismatch: maximumAreaAdresses in a received PDU %" PRIu8
                        " while the parameter for this IS is %u",
                        max_area_addrs, isis->max_area_addrs);
@@ -1728,10 +1734,10 @@ int send_hello(struct isis_circuit *circuit, int level)
 
        retval = circuit->tx(circuit, level);
        if (retval != ISIS_OK)
-               flog_err(ISIS_ERR_PACKET,
-                         "ISIS-Adj (%s): Send L%d IIH on %s failed",
-                         circuit->area->area_tag, level,
-                         circuit->interface->name);
+               flog_err(EC_ISIS_PACKET,
+                        "ISIS-Adj (%s): Send L%d IIH on %s failed",
+                        circuit->area->area_tag, level,
+                        circuit->interface->name);
 
        return retval;
 }
@@ -1926,10 +1932,10 @@ int send_csnp(struct isis_circuit *circuit, int level)
 
                int retval = circuit->tx(circuit, level);
                if (retval != ISIS_OK) {
-                       flog_err(ISIS_ERR_PACKET,
-                                 "ISIS-Snp (%s): Send L%d CSNP on %s failed",
-                                 circuit->area->area_tag, level,
-                                 circuit->interface->name);
+                       flog_err(EC_ISIS_PACKET,
+                                "ISIS-Snp (%s): Send L%d CSNP on %s failed",
+                                circuit->area->area_tag, level,
+                                circuit->interface->name);
                        isis_free_tlvs(tlvs);
                        return retval;
                }
@@ -2093,10 +2099,10 @@ static int send_psnp(int level, struct isis_circuit *circuit)
 
                int retval = circuit->tx(circuit, level);
                if (retval != ISIS_OK) {
-                       flog_err(ISIS_ERR_PACKET,
-                                 "ISIS-Snp (%s): Send L%d PSNP on %s failed",
-                                 circuit->area->area_tag, level,
-                                 circuit->interface->name);
+                       flog_err(EC_ISIS_PACKET,
+                                "ISIS-Snp (%s): Send L%d PSNP on %s failed",
+                                circuit->area->area_tag, level,
+                                circuit->interface->name);
                        isis_free_tlvs(tlvs);
                        return retval;
                }
@@ -2189,7 +2195,7 @@ void send_lsp(void *arg, struct isis_lsp *lsp, enum isis_tx_type tx_type)
         * the circuit's MTU. So handle and log this case here. */
        if (stream_get_endp(lsp->pdu) > stream_get_size(circuit->snd_stream)) {
                flog_err(
-                       ISIS_ERR_PACKET,
+                       EC_ISIS_PACKET,
                        "ISIS-Upd (%s): Can't send L%d LSP %s, seq 0x%08" PRIx32
                        ", cksum 0x%04" PRIx16 ", lifetime %" PRIu16
                        "s on %s. LSP Size is %zu while interface stream size is %zu.",
@@ -2229,12 +2235,12 @@ void send_lsp(void *arg, struct isis_lsp *lsp, enum isis_tx_type tx_type)
        clear_srm = 0;
        retval = circuit->tx(circuit, lsp->level);
        if (retval != ISIS_OK) {
-               flog_err(ISIS_ERR_PACKET,
-                         "ISIS-Upd (%s): Send L%d LSP on %s failed %s",
-                         circuit->area->area_tag, lsp->level,
-                         circuit->interface->name,
-                         (retval == ISIS_WARNING) ? "temporarily"
-                                                  : "permanently");
+               flog_err(EC_ISIS_PACKET,
+                        "ISIS-Upd (%s): Send L%d LSP on %s failed %s",
+                        circuit->area->area_tag, lsp->level,
+                        circuit->interface->name,
+                        (retval == ISIS_WARNING) ? "temporarily"
+                                                 : "permanently");
        }
 
 out: