]> git.proxmox.com Git - mirror_frr.git/commitdiff
isisd: implement the 'adjacency-state-change' notification
authorEmanuele Di Pascale <emanuele@voltanet.io>
Wed, 14 Nov 2018 14:24:00 +0000 (15:24 +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_adjacency.c
isisd/isis_northbound.c
isisd/isisd.h

index b0f2947ec6bbac2baa2506fc64701a83cfc2856f..e1cdfc30ea0abbde1d51e4992f1e491cab498e27 100644 (file)
@@ -258,6 +258,11 @@ void isis_adj_state_change(struct isis_adjacency *adj,
                        reason ? reason : "unspecified");
        }
 
+#ifndef FABRICD
+       /* send northbound notification */
+       isis_notif_adj_state_change(adj, new_state, reason);
+#endif /* ifndef FABRICD */
+
        if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
                del = false;
                for (int level = IS_LEVEL_1; level <= IS_LEVEL_2; level++) {
index 183879cadf43db2a08cefccd2fc0e59dec1c09a8..03a775faf5863d08fe166df0ea794b64a0ff03f5 100644 (file)
@@ -2658,6 +2658,56 @@ void isis_notif_authentication_failure(const struct isis_circuit *circuit,
        nb_notification_send(xpath, arguments);
 }
 
+/*
+ * XPath:
+ * /frr-isisd:adjacency-state-change
+ */
+void isis_notif_adj_state_change(const struct isis_adjacency *adj,
+                                int new_state, const char *reason)
+{
+       const char *xpath = "/frr-isisd:adjacency-state-change";
+       struct list *arguments = yang_data_list_new();
+       char xpath_arg[XPATH_MAXLEN];
+       struct yang_data *data;
+       struct isis_circuit *circuit = adj->circuit;
+       struct isis_area *area = circuit->area;
+       struct isis_dynhn *dyn = dynhn_find_by_id(adj->sysid);
+
+       notif_prep_instance_hdr(xpath, area, "default", arguments);
+       notif_prepr_iface_hdr(xpath, circuit, arguments);
+       if (dyn) {
+               snprintf(xpath_arg, sizeof(xpath_arg), "%s/neighbor", xpath);
+               data = yang_data_new_string(xpath_arg, dyn->hostname);
+               listnode_add(arguments, data);
+       }
+       snprintf(xpath_arg, sizeof(xpath_arg), "%s/neighbor-system-id", xpath);
+       data = yang_data_new_string(xpath_arg, sysid_print(adj->sysid));
+       listnode_add(arguments, data);
+
+       snprintf(xpath_arg, sizeof(xpath_arg), "%s/state", xpath);
+       switch (new_state) {
+       case ISIS_ADJ_DOWN:
+               data = yang_data_new_string(xpath_arg, "down");
+               break;
+       case ISIS_ADJ_UP:
+               data = yang_data_new_string(xpath_arg, "up");
+               break;
+       case ISIS_ADJ_INITIALIZING:
+               data = yang_data_new_string(xpath_arg, "init");
+               break;
+       default:
+               data = yang_data_new_string(xpath_arg, "failed");
+       }
+       listnode_add(arguments, data);
+       if (new_state == ISIS_ADJ_DOWN) {
+               snprintf(xpath_arg, sizeof(xpath_arg), "%s/reason", xpath);
+               data = yang_data_new_string(xpath_arg, reason);
+               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 6d7f0a485cac795a962acf73350afa51d59fb048..d1547c2fa5cab1576ba513f1aa47e83790a67737 100644 (file)
@@ -240,6 +240,8 @@ isis_notif_authentication_type_failure(const struct isis_circuit *circuit,
 extern void
 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);
 /* Master of threads. */
 extern struct thread_master *master;