summaryrefslogtreecommitdiffstats
path: root/isisd/isis_pdu.c
diff options
context:
space:
mode:
authorlynne <lynne@voltanet.io>2020-09-15 22:46:15 +0200
committerlynne <lynne@voltanet.io>2021-03-02 16:06:31 +0100
commit1ee746d99035155bcd906436cfe957f3a357ef26 (patch)
tree7795a82fc730a35c1b74a9b53913c5f21a62385e /isisd/isis_pdu.c
parentMerge pull request #8015 from mjstapp/fix_topo_gen_support (diff)
downloadfrr-1ee746d99035155bcd906436cfe957f3a357ef26.tar.xz
frr-1ee746d99035155bcd906436cfe957f3a357ef26.zip
isisd: support for snmp
Add support for read only mib objects from RFC4444. Signed-off-by: Lynne Morrison <lynne@voltanet.io> Signed-off-by: Karen Schoener <karen@voltanet.io>
Diffstat (limited to 'isisd/isis_pdu.c')
-rw-r--r--isisd/isis_pdu.c180
1 files changed, 126 insertions, 54 deletions
diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c
index a02b48157..7256fcbbc 100644
--- a/isisd/isis_pdu.c
+++ b/isisd/isis_pdu.c
@@ -549,6 +549,19 @@ static int pdu_len_validate(uint16_t pdu_len, struct isis_circuit *circuit)
return 0;
}
+static void update_rej_adj_count(struct isis_circuit *circuit)
+{
+ circuit->rej_adjacencies++;
+ if (circuit->is_type == IS_LEVEL_1)
+ circuit->area->rej_adjacencies[0]++;
+ else if (circuit->is_type == IS_LEVEL_2)
+ circuit->area->rej_adjacencies[1]++;
+ else {
+ circuit->area->rej_adjacencies[0]++;
+ circuit->area->rej_adjacencies[1]++;
+ }
+}
+
static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit,
uint8_t *ssnpa)
{
@@ -581,22 +594,22 @@ static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit,
if (p2p_hello) {
if (circuit->circ_type != CIRCUIT_T_P2P) {
zlog_warn("p2p hello on non p2p circuit");
- circuit->rej_adjacencies++;
+ update_rej_adj_count(circuit);
#ifndef FABRICD
isis_notif_reject_adjacency(
circuit, "p2p hello on non p2p circuit",
- raw_pdu);
+ raw_pdu, sizeof(raw_pdu));
#endif /* ifndef FABRICD */
return ISIS_WARNING;
}
} else {
if (circuit->circ_type != CIRCUIT_T_BROADCAST) {
zlog_warn("lan hello on non broadcast circuit");
- circuit->rej_adjacencies++;
+ update_rej_adj_count(circuit);
#ifndef FABRICD
isis_notif_reject_adjacency(
circuit, "lan hello on non broadcast circuit",
- raw_pdu);
+ raw_pdu, sizeof(raw_pdu));
#endif /* ifndef FABRICD */
return ISIS_WARNING;
}
@@ -605,12 +618,12 @@ static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit,
zlog_debug(
"level %d LAN Hello received over circuit with externalDomain = true",
level);
- circuit->rej_adjacencies++;
+ update_rej_adj_count(circuit);
#ifndef FABRICD
isis_notif_reject_adjacency(
circuit,
"LAN Hello received over circuit with externalDomain = true",
- raw_pdu);
+ raw_pdu, sizeof(raw_pdu));
#endif /* ifndef FABRICD */
return ISIS_WARNING;
}
@@ -622,10 +635,11 @@ static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit,
circuit->area->area_tag,
circuit->interface->name);
}
- circuit->rej_adjacencies++;
+ update_rej_adj_count(circuit);
#ifndef FABRICD
- isis_notif_reject_adjacency(
- circuit, "Interface level mismatch", raw_pdu);
+ isis_notif_reject_adjacency(circuit,
+ "Interface level mismatch",
+ raw_pdu, sizeof(raw_pdu));
#endif /* ifndef FABRICD */
return ISIS_WARNING;
}
@@ -652,10 +666,10 @@ static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit,
"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++;
+ update_rej_adj_count(circuit);
#ifndef FABRICD
isis_notif_reject_adjacency(circuit, "Invalid PDU length",
- raw_pdu);
+ raw_pdu, sizeof(raw_pdu));
#endif /* ifndef FABRICD */
return ISIS_WARNING;
}
@@ -664,10 +678,11 @@ static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit,
flog_err(EC_ISIS_PACKET,
"Level %d LAN Hello with Circuit Type %d", level,
iih.circ_type);
- circuit->rej_adjacencies++;
+ update_rej_adj_count(circuit);
#ifndef FABRICD
- isis_notif_reject_adjacency(
- circuit, "LAN Hello with wrong IS-level", raw_pdu);
+ isis_notif_reject_adjacency(circuit,
+ "LAN Hello with wrong IS-level",
+ raw_pdu, sizeof(raw_pdu));
#endif /* ifndef FABRICD */
return ISIS_ERROR;
}
@@ -678,10 +693,10 @@ static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit,
if (isis_unpack_tlvs(STREAM_READABLE(circuit->rcv_stream),
circuit->rcv_stream, &iih.tlvs, &error_log)) {
zlog_warn("isis_unpack_tlvs() failed: %s", error_log);
- circuit->rej_adjacencies++;
+ update_rej_adj_count(circuit);
#ifndef FABRICD
isis_notif_reject_adjacency(circuit, "Failed to unpack TLVs",
- raw_pdu);
+ raw_pdu, sizeof(raw_pdu));
#endif /* ifndef FABRICD */
goto out;
}
@@ -690,17 +705,18 @@ static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit,
zlog_warn("No Area addresses TLV in %s", pdu_name);
#ifndef FABRICD
/* send northbound notification */
- isis_notif_area_mismatch(circuit, raw_pdu);
+ isis_notif_area_mismatch(circuit, raw_pdu, sizeof(raw_pdu));
#endif /* ifndef FABRICD */
goto out;
}
if (!iih.tlvs->protocols_supported.count) {
zlog_warn("No supported protocols TLV in %s", pdu_name);
- circuit->rej_adjacencies++;
+ update_rej_adj_count(circuit);
#ifndef FABRICD
- isis_notif_reject_adjacency(
- circuit, "No supported protocols TLV", raw_pdu);
+ isis_notif_reject_adjacency(circuit,
+ "No supported protocols TLV",
+ raw_pdu, sizeof(raw_pdu));
#endif /* ifndef FABRICD */
goto out;
}
@@ -716,12 +732,13 @@ static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit,
stream_get_from(raw_pdu, circuit->rcv_stream, pdu_start,
pdu_end - pdu_start);
if (auth_code == ISIS_AUTH_FAILURE) {
- circuit->auth_failures++;
- isis_notif_authentication_failure(circuit, raw_pdu);
+ update_rej_adj_count(circuit);
+ isis_notif_authentication_failure(circuit, raw_pdu,
+ sizeof(raw_pdu));
} else { /* AUTH_TYPE_FAILURE or NO_VALIDATOR */
- circuit->auth_type_failures++;
- isis_notif_authentication_type_failure(circuit,
- raw_pdu);
+ update_rej_adj_count(circuit);
+ isis_notif_authentication_type_failure(circuit, raw_pdu,
+ sizeof(raw_pdu));
}
#endif /* ifndef FABRICD */
goto out;
@@ -731,10 +748,11 @@ static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit,
zlog_warn(
"ISIS-Adj (%s): Received IIH with own sysid on %s - discard",
circuit->area->area_tag, circuit->interface->name);
- circuit->rej_adjacencies++;
+ update_rej_adj_count(circuit);
#ifndef FABRICD
- isis_notif_reject_adjacency(
- circuit, "Received IIH with our own sysid", raw_pdu);
+ isis_notif_reject_adjacency(circuit,
+ "Received IIH with our own sysid",
+ raw_pdu, sizeof(raw_pdu));
#endif /* ifndef FABRICD */
goto out;
}
@@ -752,7 +770,7 @@ static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit,
}
#ifndef FABRICD
/* send northbound notification */
- isis_notif_area_mismatch(circuit, raw_pdu);
+ isis_notif_area_mismatch(circuit, raw_pdu, sizeof(raw_pdu));
#endif /* ifndef FABRICD */
goto out;
}
@@ -769,11 +787,11 @@ static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit,
"ISIS-Adj (%s): Neither IPv4 nor IPv6 considered usable. Ignoring IIH",
circuit->area->area_tag);
}
- circuit->rej_adjacencies++;
+ update_rej_adj_count(circuit);
#ifndef FABRICD
isis_notif_reject_adjacency(
circuit, "Neither IPv4 not IPv6 considered usable",
- raw_pdu);
+ raw_pdu, sizeof(raw_pdu));
#endif /* ifndef FABRICD */
goto out;
}
@@ -857,8 +875,8 @@ static int process_lsp(uint8_t pdu_type, struct isis_circuit *circuit,
#ifndef FABRICD
/* send northbound notification */
- isis_notif_lsp_received(circuit, rawlspid_print(hdr.lsp_id), hdr.seqno,
- time(NULL), sysid_print(hdr.lsp_id));
+ isis_notif_lsp_received(circuit, hdr.lsp_id, hdr.seqno, time(NULL),
+ sysid_print(hdr.lsp_id));
#endif /* ifndef FABRICD */
if (pdu_len_validate(hdr.pdu_len, circuit)) {
@@ -931,8 +949,18 @@ static int process_lsp(uint8_t pdu_type, struct isis_circuit *circuit,
* we change the code above to return those extra fields, we
* will send dummy values which are ignored in the callback
*/
- isis_notif_lsp_error(circuit, rawlspid_print(hdr.lsp_id),
- raw_pdu, 0, 0);
+ circuit->lsp_error_counter++;
+ if (circuit->is_type == IS_LEVEL_1) {
+ circuit->area->lsp_error_counter[0]++;
+ } else if (circuit->is_type == IS_LEVEL_2) {
+ circuit->area->lsp_error_counter[1]++;
+ } else {
+ circuit->area->lsp_error_counter[0]++;
+ circuit->area->lsp_error_counter[1]++;
+ }
+
+ isis_notif_lsp_error(circuit, hdr.lsp_id, raw_pdu,
+ sizeof(raw_pdu), 0, 0);
#endif /* ifndef FABRICD */
goto out;
}
@@ -956,11 +984,28 @@ static int process_lsp(uint8_t pdu_type, struct isis_circuit *circuit,
/* send northbound notification */
if (auth_code == ISIS_AUTH_FAILURE) {
circuit->auth_failures++;
- isis_notif_authentication_failure(circuit, raw_pdu);
+ if (circuit->is_type == IS_LEVEL_1) {
+ circuit->area->auth_failures[0]++;
+ } else if (circuit->is_type == IS_LEVEL_2) {
+ circuit->area->auth_failures[1]++;
+ } else {
+ circuit->area->auth_failures[0]++;
+ circuit->area->auth_failures[1]++;
+ }
+ isis_notif_authentication_failure(circuit, raw_pdu,
+ sizeof(raw_pdu));
} else { /* AUTH_TYPE_FAILURE or NO_VALIDATOR */
circuit->auth_type_failures++;
- isis_notif_authentication_type_failure(circuit,
- raw_pdu);
+ if (circuit->is_type == IS_LEVEL_1) {
+ circuit->area->auth_type_failures[0]++;
+ } else if (circuit->is_type == IS_LEVEL_2) {
+ circuit->area->auth_type_failures[1]++;
+ } else {
+ circuit->area->auth_type_failures[0]++;
+ circuit->area->auth_type_failures[1]++;
+ }
+ isis_notif_authentication_type_failure(circuit, raw_pdu,
+ sizeof(raw_pdu));
}
#endif /* ifndef FABRICD */
goto out;
@@ -1105,10 +1150,10 @@ dontcheckadj:
if (lsp->hdr.seqno < hdr.seqno) {
/* send northbound
* notification */
+ circuit->area
+ ->lsp_seqno_skipped_counter++;
isis_notif_seqno_skipped(
- circuit,
- rawlspid_print(
- hdr.lsp_id));
+ circuit, hdr.lsp_id);
}
#endif /* ifndef FABRICD */
lsp_inc_seqno(lsp, hdr.seqno);
@@ -1129,8 +1174,7 @@ dontcheckadj:
/* our own LSP with 0 remaining life time */
#ifndef FABRICD
/* send northbound notification */
- isis_notif_own_lsp_purge(
- circuit, rawlspid_print(hdr.lsp_id));
+ isis_notif_own_lsp_purge(circuit, hdr.lsp_id);
#endif /* ifndef FABRICD */
}
}
@@ -1158,8 +1202,8 @@ dontcheckadj:
lsp_inc_seqno(lsp, hdr.seqno);
#ifndef FABRICD
/* send northbound notification */
- isis_notif_seqno_skipped(circuit,
- rawlspid_print(hdr.lsp_id));
+ circuit->area->lsp_seqno_skipped_counter++;
+ isis_notif_seqno_skipped(circuit, hdr.lsp_id);
#endif /* ifndef FABRICD */
if (IS_DEBUG_UPDATE_PACKETS) {
zlog_debug(
@@ -1388,12 +1432,28 @@ static int process_snp(uint8_t pdu_type, struct isis_circuit *circuit,
pdu_end - pdu_start);
if (auth_code == ISIS_AUTH_FAILURE) {
circuit->auth_failures++;
- isis_notif_authentication_failure(circuit,
- raw_pdu);
+ if (circuit->is_type == IS_LEVEL_1) {
+ circuit->area->auth_failures[0]++;
+ } else if (circuit->is_type == IS_LEVEL_2) {
+ circuit->area->auth_failures[1]++;
+ } else {
+ circuit->area->auth_failures[0]++;
+ circuit->area->auth_failures[1]++;
+ }
+ isis_notif_authentication_failure(
+ circuit, raw_pdu, sizeof(raw_pdu));
} else { /* AUTH_TYPE_FAILURE or NO_VALIDATOR */
circuit->auth_type_failures++;
- isis_notif_authentication_type_failure(circuit,
- raw_pdu);
+ if (circuit->is_type == IS_LEVEL_1) {
+ circuit->area->auth_type_failures[0]++;
+ } else if (circuit->is_type == IS_LEVEL_2) {
+ circuit->area->auth_type_failures[1]++;
+ } else {
+ circuit->area->auth_type_failures[0]++;
+ circuit->area->auth_type_failures[1]++;
+ }
+ isis_notif_authentication_type_failure(
+ circuit, raw_pdu, sizeof(raw_pdu));
}
#endif /* ifndef FABRICD */
goto out;
@@ -1620,7 +1680,8 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa)
zlog_warn("Unsupported ISIS version %hhu", version1);
#ifndef FABRICD
/* send northbound notification */
- isis_notif_version_skew(circuit, version1, raw_pdu);
+ isis_notif_version_skew(circuit, version1, raw_pdu,
+ sizeof(raw_pdu));
#endif /* ifndef FABRICD */
return ISIS_WARNING;
}
@@ -1631,9 +1692,19 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa)
"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++;
+ if (circuit->is_type == IS_LEVEL_1) {
+ circuit->area->id_len_mismatches[0]++;
+ } else if (circuit->is_type == IS_LEVEL_2) {
+ circuit->area->id_len_mismatches[1]++;
+ } else {
+ circuit->area->id_len_mismatches[0]++;
+ circuit->area->id_len_mismatches[1]++;
+ }
+
#ifndef FABRICD
/* send northbound notification */
- isis_notif_id_len_mismatch(circuit, id_len, raw_pdu);
+ isis_notif_id_len_mismatch(circuit, id_len, raw_pdu,
+ sizeof(raw_pdu));
#endif /* ifndef FABRICD */
return ISIS_ERROR;
}
@@ -1662,7 +1733,8 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa)
zlog_warn("Unsupported ISIS PDU version %hhu", version2);
#ifndef FABRICD
/* send northbound notification */
- isis_notif_version_skew(circuit, version2, raw_pdu);
+ isis_notif_version_skew(circuit, version2, raw_pdu,
+ sizeof(raw_pdu));
#endif /* ifndef FABRICD */
return ISIS_WARNING;
}
@@ -1686,7 +1758,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa)
#ifndef FABRICD
/* send northbound notification */
isis_notif_max_area_addr_mismatch(circuit, max_area_addrs,
- raw_pdu);
+ raw_pdu, sizeof(raw_pdu));
#endif /* ifndef FABRICD */
return ISIS_ERROR;
}
@@ -2409,7 +2481,7 @@ void send_lsp(struct isis_circuit *circuit, struct isis_lsp *lsp,
#ifndef FABRICD
/* send a northbound notification */
isis_notif_lsp_too_large(circuit, stream_get_endp(lsp->pdu),
- rawlspid_print(lsp->hdr.lsp_id));
+ lsp->hdr.lsp_id);
#endif /* ifndef FABRICD */
if (IS_DEBUG_PACKET_DUMP)
zlog_dump_data(STREAM_DATA(lsp->pdu),