]> git.proxmox.com Git - mirror_frr.git/commitdiff
nhrpd: Add NHRP_ERR_XXXX for zlog_err to zlog_ferr conversion
authorDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 19 Jun 2018 19:28:01 +0000 (15:28 -0400)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 14 Aug 2018 20:02:05 +0000 (20:02 +0000)
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
nhrpd/nhrp_errors.c [new file with mode: 0644]
nhrpd/nhrp_errors.h [new file with mode: 0644]
nhrpd/nhrp_main.c
nhrpd/resolver.c
nhrpd/subdir.am
nhrpd/vici.c

diff --git a/nhrpd/nhrp_errors.c b/nhrpd/nhrp_errors.c
new file mode 100644 (file)
index 0000000..f0b2dcf
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * nhrp_errors - code for error messages that may occur in the
+ *              nhrp process
+ * Copyright (C) 2018 Cumulus Networks, Inc.
+ *               Donald Sharp
+ *
+ * FRR is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * FRR is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include <zebra.h>
+
+#include "nhrp_errors.h"
+
+static struct ferr_ref ferr_nhrp_err[] = {
+       {
+               .code = NHRP_ERR_SWAN,
+               .title = "NHRP Strong Swan Error",
+               .description = "NHRP has detected a error with the Strongswan code",
+               .suggestion = "Ensure that StrongSwan is configured correctly.  Restart StrongSwan and FRR"
+       },
+       {
+               .code = NHRP_ERR_RESOLVER,
+               .title = "NHRP DNS Resolution",
+               .description = "NHRP has detected an error in an attempt to resolve a hostname",
+               .suggestion = "Ensure that DNS is working properly and the hostname is configured in dns.  If you are still seeing this error, open an issue"
+       },
+       {
+               .code = END_FERR,
+       }
+};
+
+void nhrp_error_init(void)
+{
+       ferr_ref_init();
+
+       ferr_ref_add(ferr_nhrp_err);
+}
diff --git a/nhrpd/nhrp_errors.h b/nhrpd/nhrp_errors.h
new file mode 100644 (file)
index 0000000..2b3da04
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * nhrp_errors - header for error messages that may occur in the nhrp process
+ * Copyright (C) 2018 Cumulus Networks, Inc.
+ *               Donald Sharp
+ *
+ * FRR is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * FRR is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef __NHRP_ERRORS_H__
+#define __NHRP_ERRORS_H__
+
+#include "ferr.h"
+#include "nhrp_errors.h"
+
+enum nhrp_ferr_refs {
+       NHRP_ERR_SWAN = NHRP_FERR_START,
+       NHRP_ERR_RESOLVER,
+};
+
+extern void nhrp_error_init(void);
+
+#endif
index ba1e00deddf2dd795051fa9dad98de0ee127155c..e9f44e855862bc888ad5bab34cb66d53780a8357 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "nhrpd.h"
 #include "netlink.h"
+#include "nhrp_errors.h"
 
 DEFINE_MGROUP(NHRPD, "NHRP")
 
@@ -128,6 +129,7 @@ int main(int argc, char **argv)
 
        /* Library inits. */
        master = frr_init();
+       nhrp_error_init();
        vrf_init(NULL, NULL, NULL, NULL);
        nhrp_interface_init();
        resolver_init();
index 415e7523de047b67ddf3c65d94f9a6e5f3512b26..6515a97093738b2dea387c3ce2565b878844c82a 100644 (file)
 
 #include "vector.h"
 #include "thread.h"
+#include "lib_errors.h"
+
 #include "nhrpd.h"
+#include "nhrp_errors.h"
 
 struct resolver_state {
        ares_channel channel;
@@ -191,9 +194,9 @@ void resolver_resolve(struct resolver_query *query, int af,
                                       union sockunion *))
 {
        if (query->callback != NULL) {
-               zlog_err(
-                       "Trying to resolve '%s', but previous query was not finished yet",
-                       hostname);
+               zlog_ferr(NHRP_ERR_RESOLVER,
+                         "Trying to resolve '%s', but previous query was not finished yet",
+                         hostname);
                return;
        }
 
index 5b06946c891b4eff35ad05f9e5ff3c793a03e198..d66e96822417658ee574b05cede67ba54a3ff1f2 100644 (file)
@@ -13,6 +13,7 @@ nhrpd_nhrpd_SOURCES = \
        nhrpd/netlink_arp.c \
        nhrpd/netlink_gre.c \
        nhrpd/nhrp_cache.c \
+       nhrpd/nhrp_errors.c \
        nhrpd/nhrp_event.c \
        nhrpd/nhrp_interface.c \
        nhrpd/nhrp_main.c \
@@ -34,6 +35,7 @@ noinst_HEADERS += \
        nhrpd/debug.h \
        nhrpd/list.h \
        nhrpd/netlink.h \
+       nhrpd/nhrp_errors.h \
        nhrpd/nhrp_protocol.h \
        nhrpd/nhrpd.h \
        nhrpd/os.h \
index eb3827a12fdda935fea7773bd03999e0da29fc14..dae29e535acc0992b1d470014029b4059119685b 100644 (file)
 #include "thread.h"
 #include "zbuf.h"
 #include "log.h"
-#include "nhrpd.h"
+#include "lib_errors.h"
 
+#include "nhrpd.h"
 #include "vici.h"
+#include "nhrp_errors.h"
 
 #define ERRNO_IO_RETRY(EN) (((EN) == EAGAIN) || ((EN) == EWOULDBLOCK) || ((EN) == EINTR))
 
@@ -212,9 +214,9 @@ static void parse_sa_message(struct vici_message_ctx *ctx,
                                        if (str2sockunion(buf,
                                                          &sactx->local.host)
                                            < 0)
-                                               zlog_err(
-                                                       "VICI: bad strongSwan local-host: %s",
-                                                       buf);
+                                               zlog_ferr(NHRP_ERR_SWAN,
+                                                         "VICI: bad strongSwan local-host: %s",
+                                                         buf);
                        } else if (blob_equal(key, "local-id")
                                   && ctx->nsections == 1) {
                                sactx->local.id = *val;
@@ -230,9 +232,9 @@ static void parse_sa_message(struct vici_message_ctx *ctx,
                                        if (str2sockunion(buf,
                                                          &sactx->remote.host)
                                            < 0)
-                                               zlog_err(
-                                                       "VICI: bad strongSwan remote-host: %s",
-                                                       buf);
+                                               zlog_ferr(NHRP_ERR_SWAN,
+                                                         "VICI: bad strongSwan remote-host: %s",
+                                                         buf);
                        } else if (blob_equal(key, "remote-id")
                                   && ctx->nsections == 1) {
                                sactx->remote.id = *val;
@@ -275,7 +277,7 @@ static void parse_cmd_response(struct vici_message_ctx *ctx,
        case VICI_KEY_VALUE:
                if (blob_equal(key, "errmsg")
                    && blob2buf(val, buf, sizeof(buf)))
-                       zlog_err("VICI: strongSwan: %s", buf);
+                       zlog_ferr(NHRP_ERR_SWAN, "VICI: strongSwan: %s", buf);
                break;
        default:
                break;
@@ -334,7 +336,7 @@ static void vici_recv_message(struct vici_conn *vici, struct zbuf *msg)
                break;
        case VICI_EVENT_UNKNOWN:
        case VICI_CMD_UNKNOWN:
-               zlog_err(
+               zlog_ferr(NHRP_ERR_SWAN,
                        "VICI: StrongSwan does not support mandatory events (unpatched?)");
                break;
        case VICI_EVENT_CONFIRM: