From: Renato Westphal Date: Wed, 9 May 2018 04:35:04 +0000 (-0300) Subject: ripd: implement two YANG notifications X-Git-Tag: frr-7.1-dev~228^2~10 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=fe339c9560ee3665c66033ccbbfc8b3eac02d035;p=matthieu%2Ffrr.git 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 --- 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;