]> git.proxmox.com Git - mirror_frr.git/commitdiff
isisd: implement the 'rejected-adjacency' notification
authorEmanuele Di Pascale <emanuele@voltanet.io>
Wed, 14 Nov 2018 14:25:54 +0000 (15:25 +0100)
committerEmanuele Di Pascale <emanuele@voltanet.io>
Tue, 18 Dec 2018 14:24:46 +0000 (15:24 +0100)
Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
isisd/isis_northbound.c
isisd/isis_pdu.c
isisd/isisd.h

index 03a775faf5863d08fe166df0ea794b64a0ff03f5..ec8bd8f1d2c2344c23de808743b8b925f0248d18 100644 (file)
@@ -2708,6 +2708,31 @@ void isis_notif_adj_state_change(const struct isis_adjacency *adj,
        nb_notification_send(xpath, arguments);
 }
 
+/*
+ * XPath:
+ * /frr-isisd:rejected-adjacency
+ */
+void isis_notif_reject_adjacency(const struct isis_circuit *circuit,
+                                const char *reason, const char *raw_pdu)
+{
+       const char *xpath = "/frr-isisd:rejected-adjacency";
+       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/reason", xpath);
+       data = yang_data_new_string(xpath_arg, reason);
+       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);
+
+       nb_notification_send(xpath, arguments);
+}
+
 /* clang-format off */
 const struct frr_yang_module_info frr_isisd_info = {
        .name = "frr-isisd",
index c4a62a62cc82bf94d0eddfdeeb9cc06595a1afce..49869ccbab8d369b6aa9d8b047f0f596d5438968 100644 (file)
@@ -583,11 +583,21 @@ 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");
+#ifndef FABRICD
+                       isis_notif_reject_adjacency(
+                               circuit, "p2p hello on non p2p circuit",
+                               raw_pdu);
+#endif /* ifndef FABRICD */
                        return ISIS_WARNING;
                }
        } else {
                if (circuit->circ_type != CIRCUIT_T_BROADCAST) {
                        zlog_warn("lan hello on non broadcast circuit");
+#ifndef FABRICD
+                       isis_notif_reject_adjacency(
+                               circuit, "lan hello on non broadcast circuit",
+                               raw_pdu);
+#endif /* ifndef FABRICD */
                        return ISIS_WARNING;
                }
 
@@ -595,6 +605,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);
+#ifndef FABRICD
+                       isis_notif_reject_adjacency(
+                               circuit,
+                               "LAN Hello received over circuit with externalDomain = true",
+                               raw_pdu);
+#endif /* ifndef FABRICD */
                        return ISIS_WARNING;
                }
 
@@ -605,6 +621,10 @@ static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit,
                                        circuit->area->area_tag,
                                        circuit->interface->name);
                        }
+#ifndef FABRICD
+                       isis_notif_reject_adjacency(
+                               circuit, "Interface level mismatch", raw_pdu);
+#endif /* ifndef FABRICD */
                        return ISIS_WARNING;
                }
        }
@@ -630,6 +650,10 @@ static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit,
                        "ISIS-Adj (%s): Rcvd %s from (%s) with invalid pdu length %" PRIu16,
                        circuit->area->area_tag, pdu_name,
                        circuit->interface->name, iih.pdu_len);
+#ifndef FABRICD
+               isis_notif_reject_adjacency(circuit, "Invalid PDU length",
+                                           raw_pdu);
+#endif /* ifndef FABRICD */
                return ISIS_WARNING;
        }
 
@@ -637,6 +661,10 @@ 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);
+#ifndef FABRICD
+               isis_notif_reject_adjacency(
+                       circuit, "LAN Hello with wrong IS-level", raw_pdu);
+#endif /* ifndef FABRICD */
                return ISIS_ERROR;
        }
 
@@ -646,6 +674,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);
+#ifndef FABRICD
+               isis_notif_reject_adjacency(circuit, "Failed to unpack TLVs",
+                                           raw_pdu);
+#endif /* ifndef FABRICD */
                goto out;
        }
 
@@ -656,6 +688,10 @@ static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit,
 
        if (!iih.tlvs->protocols_supported.count) {
                zlog_warn("No supported protocols TLV in %s", pdu_name);
+#ifndef FABRICD
+               isis_notif_reject_adjacency(
+                       circuit, "No supported protocols TLV", raw_pdu);
+#endif /* ifndef FABRICD */
                goto out;
        }
 
@@ -682,6 +718,10 @@ static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit,
                zlog_warn(
                        "ISIS-Adj (%s): Received IIH with own sysid - discard",
                        circuit->area->area_tag);
+#ifndef FABRICD
+               isis_notif_reject_adjacency(
+                       circuit, "Received IIH with our own sysid", raw_pdu);
+#endif /* ifndef FABRICD */
                goto out;
        }
 
@@ -711,7 +751,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);
                }
-
+#ifndef FABRICD
+               isis_notif_reject_adjacency(
+                       circuit, "Neither IPv4 not IPv6 considered usable",
+                       raw_pdu);
+#endif /* ifndef FABRICD */
                goto out;
        }
 
index d1547c2fa5cab1576ba513f1aa47e83790a67737..f934d076de5cb712bcbd40c76b94618701fcf9e9 100644 (file)
@@ -242,6 +242,9 @@ isis_notif_authentication_failure(const struct isis_circuit *circuit,
                                  const char *raw_pdu);
 extern void isis_notif_adj_state_change(const struct isis_adjacency *adj,
                                        int new_state, const char *reason);
+extern void isis_notif_reject_adjacency(const struct isis_circuit *circuit,
+                                       const char *reason,
+                                       const char *raw_pdu);
 /* Master of threads. */
 extern struct thread_master *master;