]> git.proxmox.com Git - mirror_frr.git/commitdiff
isisd: add the 'lsp-error-detected' notification
authorEmanuele Di Pascale <emanuele@voltanet.io>
Wed, 14 Nov 2018 15:05:57 +0000 (16:05 +0100)
committerEmanuele Di Pascale <emanuele@voltanet.io>
Tue, 18 Dec 2018 14:24:46 +0000 (15:24 +0100)
Note that we do not return the actual tlv_type and offset
of the erroneous TLV. This is because unpacking tlvs currently
uses a chain of function calls, where the notification can only
be sent at the start of the chain, but the tlv_type and offset
information are only available at the end. Unless we change the
code to propagate those values, we have no way to feed them to
the notification. So these leafs are not generated.

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
isisd/isis_northbound.c
isisd/isis_pdu.c
isisd/isisd.h

index 593f5be054fb64199a2fea942e447bea97f40b48..1b6f46feb1ad57639cf0e0ae5291e3cae6b80c83 100644 (file)
@@ -2863,6 +2863,34 @@ void isis_notif_version_skew(const struct isis_circuit *circuit,
        nb_notification_send(xpath, arguments);
 }
 
+/*
+ * XPath:
+ * /frr-isisd:lsp-error-detected
+ */
+void isis_notif_lsp_error(const struct isis_circuit *circuit,
+                         const char *lsp_id, const char *raw_pdu,
+                         __attribute__((unused)) uint32_t offset,
+                         __attribute__((unused)) uint8_t tlv_type)
+{
+       const char *xpath = "/frr-isisd:lsp-error-detected";
+       struct list *arguments = yang_data_list_new();
+       char xpath_arg[XPATH_MAXLEN];
+       struct yang_data *data;
+       struct isis_area *area = circuit->area;
+
+       notif_prep_instance_hdr(xpath, area, "default", arguments);
+       notif_prepr_iface_hdr(xpath, circuit, arguments);
+       snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath);
+       data = yang_data_new_string(xpath_arg, lsp_id);
+       listnode_add(arguments, data);
+       snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath);
+       data = yang_data_new(xpath_arg, raw_pdu);
+       listnode_add(arguments, data);
+       /* ignore offset and tlv_type which cannot be set properly */
+
+       nb_notification_send(xpath, arguments);
+}
+
 /* clang-format off */
 const struct frr_yang_module_info frr_isisd_info = {
        .name = "frr-isisd",
index 219900bba0626be8cd12a6afdc3317a9fea36e54..2db07ea79ecc360c95e41b35e9a98f38bd7cfa84 100644 (file)
@@ -916,6 +916,17 @@ static int process_lsp(uint8_t pdu_type, struct isis_circuit *circuit,
                             circuit->rcv_stream, &tlvs, &error_log)) {
                zlog_warn("Something went wrong unpacking the LSP: %s",
                          error_log);
+#ifndef FABRICD
+               /* send northbound notification. Note that the tlv-type and
+                * offset cannot correctly be set here as they are not returned
+                * by isis_unpack_tlvs, but in there I cannot fire a
+                * notification because I have no circuit information. So until
+                * 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);
+#endif /* ifndef FABRICD */
                goto out;
        }
 
index 87d2065142d44f07c8e77490f2bda3a70908fafe..199e64b442a2e0652f6cc3ffc4ef09794a4aca77 100644 (file)
@@ -256,6 +256,9 @@ extern void isis_notif_id_len_mismatch(const struct isis_circuit *circuit,
                                       uint8_t rcv_id_len, const char *raw_pdu);
 extern void isis_notif_version_skew(const struct isis_circuit *circuit,
                                    uint8_t version, const char *raw_pdu);
+extern void isis_notif_lsp_error(const struct isis_circuit *circuit,
+                                const char *lsp_id, const char *raw_pdu,
+                                uint32_t offset, uint8_t tlv_type);
 /* Master of threads. */
 extern struct thread_master *master;