]> git.puffer.fish Git - mirror/frr.git/commitdiff
ripd: implement two YANG notifications
authorRenato Westphal <renato@opensourcerouting.org>
Wed, 9 May 2018 04:35:04 +0000 (01:35 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Sat, 27 Oct 2018 18:16:12 +0000 (16:16 -0200)
Implement the 'authentication-failure' and 'authentication-type-failure'
notifications defined in the frr-ripd YANG module.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
ripd/rip_northbound.c
ripd/ripd.c
ripd/ripd.h

index c6d2dc2162eb62308e75ffecaca42559bfe291b9..bb32409a2488d420747b57b9a993f1f3afdbce6e 100644 (file)
@@ -1243,6 +1243,44 @@ static int clear_rip_route_rpc(const char *xpath, const struct list *input,
        return NB_OK;
 }
 
+/*
+ * XPath: /frr-ripd:authentication-type-failure
+ */
+void ripd_notif_send_auth_type_failure(const char *ifname)
+{
+       const char *xpath = "/frr-ripd:authentication-type-failure";
+       struct list *arguments;
+       char xpath_arg[XPATH_MAXLEN];
+       struct yang_data *data;
+
+       arguments = yang_data_list_new();
+
+       snprintf(xpath_arg, sizeof(xpath_arg), "%s/interface-name", xpath);
+       data = yang_data_new_string(xpath_arg, ifname);
+       listnode_add(arguments, data);
+
+       nb_notification_send(xpath, arguments);
+}
+
+/*
+ * XPath: /frr-ripd:authentication-failure
+ */
+void ripd_notif_send_auth_failure(const char *ifname)
+{
+       const char *xpath = "/frr-ripd:authentication-failure";
+       struct list *arguments;
+       char xpath_arg[XPATH_MAXLEN];
+       struct yang_data *data;
+
+       arguments = yang_data_list_new();
+
+       snprintf(xpath_arg, sizeof(xpath_arg), "%s/interface-name", xpath);
+       data = yang_data_new_string(xpath_arg, ifname);
+       listnode_add(arguments, data);
+
+       nb_notification_send(xpath, arguments);
+}
+
 /* clang-format off */
 const struct frr_yang_module_info frr_ripd_info = {
        .name = "frr-ripd",
index 356de94931bfed6d709c2240fec23df511174ec0..4a6765308e59d541cbfe773e0c4835a6501091cc 100644 (file)
@@ -1871,6 +1871,7 @@ static int rip_read(struct thread *t)
                        zlog_debug(
                                "packet RIPv%d is dropped because authentication disabled",
                                packet->version);
+               ripd_notif_send_auth_type_failure(ifp->name);
                rip_peer_bad_packet(&from);
                return -1;
        }
@@ -1907,6 +1908,7 @@ static int rip_read(struct thread *t)
                                zlog_debug(
                                        "RIPv1"
                                        " dropped because authentication enabled");
+                       ripd_notif_send_auth_type_failure(ifp->name);
                        rip_peer_bad_packet(&from);
                        return -1;
                }
@@ -1919,6 +1921,7 @@ static int rip_read(struct thread *t)
                        if (IS_RIP_DEBUG_PACKET)
                                zlog_debug(
                                        "RIPv2 authentication failed: no auth RTE in packet");
+                       ripd_notif_send_auth_type_failure(ifp->name);
                        rip_peer_bad_packet(&from);
                        return -1;
                }
@@ -1929,6 +1932,7 @@ static int rip_read(struct thread *t)
                                zlog_debug(
                                        "RIPv2"
                                        " dropped because authentication enabled");
+                       ripd_notif_send_auth_type_failure(ifp->name);
                        rip_peer_bad_packet(&from);
                        return -1;
                }
@@ -1964,6 +1968,7 @@ static int rip_read(struct thread *t)
                        if (IS_RIP_DEBUG_PACKET)
                                zlog_debug("RIPv2 %s authentication failure",
                                           auth_desc);
+                       ripd_notif_send_auth_failure(ifp->name);
                        rip_peer_bad_packet(&from);
                        return -1;
                }
index 367b1d5bfbd3e5a92753eea7f59c958b5397e898..d4fb230a20a504e6331cf9f22302c80f50305e6f 100644 (file)
@@ -452,6 +452,10 @@ extern int rip_offset_list_apply_out(struct prefix_ipv4 *, struct interface *,
 extern void rip_offset_init(void);
 extern void rip_offset_clean(void);
 
+/* YANG notifications */
+extern void ripd_notif_send_auth_type_failure(const char *ifname);
+extern void ripd_notif_send_auth_failure(const char *ifname);
+
 /* There is only one rip strucutre. */
 extern struct rip *rip;