summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2018-05-09 01:35:04 -0300
committerRenato Westphal <renato@opensourcerouting.org>2018-10-27 16:16:12 -0200
commitfe339c9560ee3665c66033ccbbfc8b3eac02d035 (patch)
tree13ebaa4bffed12adee3e4007e5fe4dbde739f9cf
parent1137aef48fee571e51a1445e76647359d5701922 (diff)
ripd: implement two YANG notifications
Implement the 'authentication-failure' and 'authentication-type-failure' notifications defined in the frr-ripd YANG module. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
-rw-r--r--ripd/rip_northbound.c38
-rw-r--r--ripd/ripd.c5
-rw-r--r--ripd/ripd.h4
3 files changed, 47 insertions, 0 deletions
diff --git a/ripd/rip_northbound.c b/ripd/rip_northbound.c
index c6d2dc2162..bb32409a24 100644
--- a/ripd/rip_northbound.c
+++ b/ripd/rip_northbound.c
@@ -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",
diff --git a/ripd/ripd.c b/ripd/ripd.c
index 356de94931..4a6765308e 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -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;
}
diff --git a/ripd/ripd.h b/ripd/ripd.h
index 367b1d5bfb..d4fb230a20 100644
--- a/ripd/ripd.h
+++ b/ripd/ripd.h
@@ -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;