diff options
Diffstat (limited to 'isisd/isis_pdu.c')
| -rw-r--r-- | isisd/isis_pdu.c | 116 |
1 files changed, 54 insertions, 62 deletions
diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c index b5377142b6..43b9f6685e 100644 --- a/isisd/isis_pdu.c +++ b/isisd/isis_pdu.c @@ -74,8 +74,10 @@ static int ack_lsp(struct isis_lsp_hdr *hdr, struct isis_circuit *circuit, fill_fixed_hdr(pdu_type, circuit->snd_stream); lenp = stream_get_endp(circuit->snd_stream); + stream_putw(circuit->snd_stream, 0); /* PDU length */ - stream_put(circuit->snd_stream, isis->sysid, ISIS_SYS_ID_LEN); + stream_put(circuit->snd_stream, circuit->area->isis->sysid, + ISIS_SYS_ID_LEN); stream_putc(circuit->snd_stream, circuit->idx); stream_putc(circuit->snd_stream, 9); /* code */ stream_putc(circuit->snd_stream, 16); /* len */ @@ -128,6 +130,7 @@ struct iih_info { static int process_p2p_hello(struct iih_info *iih) { struct isis_threeway_adj *tw_adj = iih->tlvs->threeway_adj; + if (tw_adj) { if (tw_adj->state > ISIS_THREEWAY_DOWN) { if (IS_DEBUG_ADJ_PACKETS) { @@ -140,8 +143,10 @@ static int process_p2p_hello(struct iih_info *iih) } if (tw_adj->neighbor_set - && (memcmp(tw_adj->neighbor_id, isis->sysid, ISIS_SYS_ID_LEN) - || tw_adj->neighbor_circuit_id != (uint32_t) iih->circuit->idx)) { + && (memcmp(tw_adj->neighbor_id, + iih->circuit->area->isis->sysid, ISIS_SYS_ID_LEN) + || tw_adj->neighbor_circuit_id + != (uint32_t)iih->circuit->idx)) { if (IS_DEBUG_ADJ_PACKETS) { zlog_debug("ISIS-Adj (%s): Rcvd P2P IIH from (%s) which lists IS/Circuit different from us as neighbor.", @@ -427,8 +432,7 @@ static int process_p2p_hello(struct iih_info *iih) if (IS_DEBUG_ADJ_PACKETS) { zlog_debug( - "ISIS-Adj (%s): Rcvd P2P IIH from (%s), cir type %s," - " cir id %hhu, length %" PRIu16, + "ISIS-Adj (%s): Rcvd P2P IIH from (%s), cir type %s, cir id %hhu, length %hu", iih->circuit->area->area_tag, iih->circuit->interface->name, circuit_t2string(iih->circuit->is_type), @@ -562,7 +566,6 @@ static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit, ? "P2P IIH" : (level == ISIS_LEVEL1) ? "L1 LAN IIH" : "L2 LAN IIH"; - stream_get_from(raw_pdu, circuit->rcv_stream, pdu_start, pdu_end - pdu_start); if (IS_DEBUG_ADJ_PACKETS) { @@ -647,7 +650,7 @@ static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit, if (pdu_len_validate(iih.pdu_len, circuit)) { zlog_warn( - "ISIS-Adj (%s): Rcvd %s from (%s) with invalid pdu length %" PRIu16, + "ISIS-Adj (%s): Rcvd %s from (%s) with invalid pdu length %hu", circuit->area->area_tag, pdu_name, circuit->interface->name, iih.pdu_len); circuit->rej_adjacencies++; @@ -725,7 +728,7 @@ static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit, goto out; } - if (!memcmp(iih.sys_id, isis->sysid, ISIS_SYS_ID_LEN)) { + if (!memcmp(iih.sys_id, circuit->area->isis->sysid, ISIS_SYS_ID_LEN)) { zlog_warn( "ISIS-Adj (%s): Received IIH with own sysid - discard", circuit->area->area_tag); @@ -860,16 +863,14 @@ static int process_lsp(uint8_t pdu_type, struct isis_circuit *circuit, #endif /* ifndef FABRICD */ if (pdu_len_validate(hdr.pdu_len, circuit)) { - zlog_debug("ISIS-Upd (%s): LSP %s invalid LSP length %" PRIu16, + zlog_debug("ISIS-Upd (%s): LSP %s invalid LSP length %hu", circuit->area->area_tag, rawlspid_print(hdr.lsp_id), hdr.pdu_len); return ISIS_WARNING; } if (IS_DEBUG_UPDATE_PACKETS) { - zlog_debug("ISIS-Upd (%s): Rcvd L%d LSP %s, seq 0x%08" PRIx32 - ", cksum 0x%04" PRIx16 ", lifetime %" PRIu16 - "s, len %" PRIu16 ", on %s", + zlog_debug("ISIS-Upd (%s): Rcvd L%d LSP %s, seq 0x%08x, cksum 0x%04hx, lifetime %hus, len %hu, on %s", circuit->area->area_tag, level, rawlspid_print(hdr.lsp_id), hdr.seqno, hdr.checksum, hdr.rem_lifetime, hdr.pdu_len, @@ -879,7 +880,7 @@ static int process_lsp(uint8_t pdu_type, struct isis_circuit *circuit, /* lsp is_type check */ if ((hdr.lsp_bits & IS_LEVEL_1) != IS_LEVEL_1) { zlog_debug( - "ISIS-Upd (%s): LSP %s invalid LSP is type 0x%" PRIx8, + "ISIS-Upd (%s): LSP %s invalid LSP is type 0x%x", circuit->area->area_tag, rawlspid_print(hdr.lsp_id), hdr.lsp_bits & IS_LEVEL_1_AND_2); /* continue as per RFC1122 Be liberal in what you accept, and @@ -891,7 +892,7 @@ static int process_lsp(uint8_t pdu_type, struct isis_circuit *circuit, if (iso_csum_verify(STREAM_DATA(circuit->rcv_stream) + 12, hdr.pdu_len - 12, hdr.checksum, 12)) { zlog_debug( - "ISIS-Upd (%s): LSP %s invalid LSP checksum 0x%04" PRIx16, + "ISIS-Upd (%s): LSP %s invalid LSP checksum 0x%04hx", circuit->area->area_tag, rawlspid_print(hdr.lsp_id), hdr.checksum); return ISIS_WARNING; @@ -900,8 +901,7 @@ static int process_lsp(uint8_t pdu_type, struct isis_circuit *circuit, /* 7.3.15.1 a) 1 - external domain circuit will discard lsps */ if (circuit->ext_domain) { zlog_debug( - "ISIS-Upd (%s): LSP %s received at level %d over circuit with " - "externalDomain = true", + "ISIS-Upd (%s): LSP %s received at level %d over circuit with externalDomain = true", circuit->area->area_tag, rawlspid_print(hdr.lsp_id), level); return ISIS_WARNING; @@ -910,8 +910,7 @@ static int process_lsp(uint8_t pdu_type, struct isis_circuit *circuit, /* 7.3.15.1 a) 2,3 - manualL2OnlyMode not implemented */ if (!(circuit->is_type & level)) { zlog_debug( - "ISIS-Upd (%s): LSP %s received at level %d over circuit of" - " type %s", + "ISIS-Upd (%s): LSP %s received at level %d over circuit of type %s", circuit->area->area_tag, rawlspid_print(hdr.lsp_id), level, circuit_t2string(circuit->is_type)); return ISIS_WARNING; @@ -986,9 +985,7 @@ static int process_lsp(uint8_t pdu_type, struct isis_circuit *circuit, if (circuit->circ_type == CIRCUIT_T_BROADCAST) { if (!isis_adj_lookup_snpa(ssnpa, circuit->u.bc.adjdb[level - 1])) { - zlog_debug("(%s): DS ======= LSP %s, seq 0x%08" PRIx32 - ", cksum 0x%04" PRIx16 ", lifetime %" PRIu16 - "s on %s", + zlog_debug("(%s): DS ======= LSP %s, seq 0x%08x, cksum 0x%04hx, lifetime %hus on %s", circuit->area->area_tag, rawlspid_print(hdr.lsp_id), hdr.seqno, hdr.checksum, hdr.rem_lifetime, @@ -1029,8 +1026,7 @@ dontcheckadj: if (lsp && (lsp->hdr.seqno == hdr.seqno) && (lsp->hdr.checksum != hdr.checksum) && hdr.rem_lifetime) { - zlog_warn("ISIS-Upd (%s): LSP %s seq 0x%08" PRIx32 - " with confused checksum received.", + zlog_warn("ISIS-Upd (%s): LSP %s seq 0x%08x with confused checksum received.", circuit->area->area_tag, rawlspid_print(hdr.lsp_id), hdr.seqno); hdr.rem_lifetime = 0; @@ -1048,7 +1044,8 @@ dontcheckadj: ack_lsp(&hdr, circuit, level); goto out; /* FIXME: do we need a purge? */ } else { - if (memcmp(hdr.lsp_id, isis->sysid, ISIS_SYS_ID_LEN)) { + if (memcmp(hdr.lsp_id, circuit->area->isis->sysid, + ISIS_SYS_ID_LEN)) { /* LSP by some other system -> do 7.3.16.4 b) */ /* 7.3.16.4 b) 1) */ if (comp == LSP_NEWER) { @@ -1125,9 +1122,7 @@ dontcheckadj: } if (IS_DEBUG_UPDATE_PACKETS) zlog_debug( - "ISIS-Upd (%s): (1) " - "re-originating LSP %s new seq " - "0x%08" PRIx32, + "ISIS-Upd (%s): (1) re-originating LSP %s new seq 0x%08x", circuit->area->area_tag, rawlspid_print(hdr.lsp_id), lsp->hdr.seqno); @@ -1144,7 +1139,8 @@ dontcheckadj: } /* 7.3.15.1 c) - If this is our own lsp and we don't have it initiate a * purge */ - if (memcmp(hdr.lsp_id, isis->sysid, ISIS_SYS_ID_LEN) == 0) { + if (memcmp(hdr.lsp_id, circuit->area->isis->sysid, ISIS_SYS_ID_LEN) + == 0) { if (!lsp) { /* 7.3.16.4: initiate a purge */ lsp_purge_non_exist(level, &hdr, circuit->area); @@ -1169,7 +1165,7 @@ dontcheckadj: #endif /* ifndef FABRICD */ if (IS_DEBUG_UPDATE_PACKETS) { zlog_debug( - "ISIS-Upd (%s): (2) re-originating LSP %s new seq 0x%08" PRIx32, + "ISIS-Upd (%s): (2) re-originating LSP %s new seq 0x%08x", circuit->area->area_tag, rawlspid_print(hdr.lsp_id), lsp->hdr.seqno); @@ -1314,8 +1310,7 @@ static int process_snp(uint8_t pdu_type, struct isis_circuit *circuit, if (circuit->ext_domain) { zlog_debug( - "ISIS-Snp (%s): Rcvd L%d %cSNP on %s, " - "skipping: circuit externalDomain = true", + "ISIS-Snp (%s): Rcvd L%d %cSNP on %s, skipping: circuit externalDomain = true", circuit->area->area_tag, level, typechar, circuit->interface->name); @@ -1325,8 +1320,7 @@ static int process_snp(uint8_t pdu_type, struct isis_circuit *circuit, /* 7.3.15.2 a) 2,3 - manualL2OnlyMode not implemented */ if (!(circuit->is_type & level)) { zlog_debug( - "ISIS-Snp (%s): Rcvd L%d %cSNP on %s, " - "skipping: circuit type %s does not match level %d", + "ISIS-Snp (%s): Rcvd L%d %cSNP on %s, skipping: circuit type %s does not match level %d", circuit->area->area_tag, level, typechar, circuit->interface->name, circuit_t2string(circuit->is_type), level); @@ -1338,8 +1332,7 @@ static int process_snp(uint8_t pdu_type, struct isis_circuit *circuit, if (!is_csnp && (circuit->circ_type == CIRCUIT_T_BROADCAST) && !circuit->u.bc.is_dr[level - 1]) { zlog_debug( - "ISIS-Snp (%s): Rcvd L%d %cSNP from %s on %s, " - "skipping: we are not the DIS", + "ISIS-Snp (%s): Rcvd L%d %cSNP from %s on %s, skipping: we are not the DIS", circuit->area->area_tag, level, typechar, snpa_print(ssnpa), circuit->interface->name); @@ -1383,6 +1376,7 @@ static int process_snp(uint8_t pdu_type, struct isis_circuit *circuit, struct isis_passwd *passwd = (level == IS_LEVEL_1) ? &circuit->area->area_passwd : &circuit->area->domain_passwd; + if (CHECK_FLAG(passwd->snp_auth, SNP_AUTH_RECV)) { int auth_code = isis_tlvs_auth_is_valid( tlvs, passwd, circuit->rcv_stream, false); @@ -1419,8 +1413,7 @@ static int process_snp(uint8_t pdu_type, struct isis_circuit *circuit, for (struct isis_lsp_entry *entry = entry_head; entry; entry = entry->next) { zlog_debug( - "ISIS-Snp (%s): %cSNP entry %s, seq 0x%08" PRIx32 - ", cksum 0x%04" PRIx16 ", lifetime %" PRIu16 "s", + "ISIS-Snp (%s): %cSNP entry %s, seq 0x%08x, cksum 0x%04hx, lifetime %hus", circuit->area->area_tag, typechar, rawlspid_print(entry->id), entry->seqno, entry->checksum, entry->rem_lifetime); @@ -1434,7 +1427,8 @@ static int process_snp(uint8_t pdu_type, struct isis_circuit *circuit, entry = entry->next) { struct isis_lsp *lsp = lsp_search(&circuit->area->lspdb[level - 1], entry->id); - bool own_lsp = !memcmp(entry->id, isis->sysid, ISIS_SYS_ID_LEN); + bool own_lsp = !memcmp(entry->id, circuit->area->isis->sysid, + ISIS_SYS_ID_LEN); if (lsp) { /* 7.3.15.2 b) 1) is this LSP newer */ int cmp = lsp_compare(circuit->area->area_tag, lsp, @@ -1473,8 +1467,9 @@ static int process_snp(uint8_t pdu_type, struct isis_circuit *circuit, * are not 0, * insert it and set SSN on it */ if (entry->rem_lifetime && entry->checksum - && entry->seqno && memcmp(entry->id, isis->sysid, - ISIS_SYS_ID_LEN)) { + && entry->seqno + && memcmp(entry->id, circuit->area->isis->sysid, + ISIS_SYS_ID_LEN)) { struct isis_lsp *lsp0 = NULL; if (LSP_FRAGMENT(entry->id)) { @@ -1613,18 +1608,18 @@ 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=%" PRIx8, idrp); + "No support for ES-IS packet IDRP=%hhx", idrp); return ISIS_ERROR; } if (idrp != ISO10589_ISIS) { - flog_err(EC_ISIS_PACKET, "Not an IS-IS packet IDRP=%" PRIx8, + flog_err(EC_ISIS_PACKET, "Not an IS-IS packet IDRP=%hhx", idrp); return ISIS_ERROR; } if (version1 != 1) { - zlog_warn("Unsupported ISIS version %" PRIu8, version1); + zlog_warn("Unsupported ISIS version %hhu", version1); #ifndef FABRICD /* send northbound notification */ isis_notif_version_skew(circuit, version1, raw_pdu); @@ -1635,8 +1630,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) if (id_len != 0 && id_len != ISIS_SYS_ID_LEN) { flog_err( EC_ISIS_PACKET, - "IDFieldLengthMismatch: ID Length field in a received PDU %" PRIu8 - ", while the parameter for this IS is %u", + "IDFieldLengthMismatch: ID Length field in a received PDU %hhu, while the parameter for this IS is %u", id_len, ISIS_SYS_ID_LEN); circuit->id_len_mismatches++; #ifndef FABRICD @@ -1648,14 +1642,13 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) uint8_t expected_length; if (pdu_size(pdu_type, &expected_length)) { - zlog_warn("Unsupported ISIS PDU %" PRIu8, pdu_type); + zlog_warn("Unsupported ISIS PDU %hhu", pdu_type); return ISIS_WARNING; } if (length != expected_length) { flog_err(EC_ISIS_PACKET, - "Expected fixed header length = %" PRIu8 - " but got %" PRIu8, + "Expected fixed header length = %hhu but got %hhu", expected_length, length); return ISIS_ERROR; } @@ -1668,7 +1661,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) } if (version2 != 1) { - zlog_warn("Unsupported ISIS PDU version %" PRIu8, version2); + zlog_warn("Unsupported ISIS PDU version %hhu", version2); #ifndef FABRICD /* send northbound notification */ isis_notif_version_skew(circuit, version2, raw_pdu); @@ -1683,14 +1676,14 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) } /* either 3 or 0 */ - if (pdu_type != FS_LINK_STATE /* FS PDU doesn't contain max area addr field */ + if (pdu_type != FS_LINK_STATE /* FS PDU doesn't contain max area addr + field */ && max_area_addrs != 0 - && max_area_addrs != isis->max_area_addrs) { + && max_area_addrs != circuit->area->isis->max_area_addrs) { flog_err( 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); + "maximumAreaAddressesMismatch: maximumAreaAdresses in a received PDU %hhu while the parameter for this IS is %u", + max_area_addrs, circuit->area->isis->max_area_addrs); circuit->max_area_addr_mismatches++; #ifndef FABRICD /* send northbound notification */ @@ -2069,8 +2062,10 @@ int send_csnp(struct isis_circuit *circuit, int level) 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_put(circuit->snd_stream, isis->sysid, ISIS_SYS_ID_LEN); + stream_put(circuit->snd_stream, circuit->area->isis->sysid, + ISIS_SYS_ID_LEN); /* with zero circuit id - ref 9.10, 9.11 */ stream_putc(circuit->snd_stream, 0); @@ -2247,7 +2242,8 @@ static int send_psnp(int level, struct isis_circuit *circuit) size_t len_pointer = stream_get_endp(circuit->snd_stream); stream_putw(circuit->snd_stream, 0); /* length is filled in later */ - stream_put(circuit->snd_stream, isis->sysid, ISIS_SYS_ID_LEN); + stream_put(circuit->snd_stream, circuit->area->isis->sysid, + ISIS_SYS_ID_LEN); stream_putc(circuit->snd_stream, circuit->idx); struct isis_passwd *passwd = (level == ISIS_LEVEL1) @@ -2409,9 +2405,7 @@ void send_lsp(struct isis_circuit *circuit, struct isis_lsp *lsp, if (stream_get_endp(lsp->pdu) > stream_get_size(circuit->snd_stream)) { flog_err( 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.", + "ISIS-Upd (%s): Can't send L%d LSP %s, seq 0x%08x, cksum 0x%04hx, lifetime %hus on %s. LSP Size is %zu while interface stream size is %zu.", circuit->area->area_tag, lsp->level, rawlspid_print(lsp->hdr.lsp_id), lsp->hdr.seqno, lsp->hdr.checksum, lsp->hdr.rem_lifetime, @@ -2439,9 +2433,7 @@ void send_lsp(struct isis_circuit *circuit, struct isis_lsp *lsp, } if (IS_DEBUG_UPDATE_PACKETS) { - zlog_debug("ISIS-Upd (%s): Sending %sL%d LSP %s, seq 0x%08" PRIx32 - ", cksum 0x%04" PRIx16 ", lifetime %" PRIu16 - "s on %s", + zlog_debug("ISIS-Upd (%s): Sending %sL%d LSP %s, seq 0x%08x, cksum 0x%04hx, lifetime %hus on %s", circuit->area->area_tag, (tx_type == TX_LSP_CIRCUIT_SCOPED) ? "Circuit scoped " : "", |
