summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2018-06-19 21:28:01 +0200
committerQuentin Young <qlyoung@cumulusnetworks.com>2018-08-14 22:02:05 +0200
commitaed070112489e92dbdcc4eb02243aec8af2d66af (patch)
tree3f9be78c9061266899d1025bd2098ebd8bc0ebe9
parentbgpd: Add some FLowspec specific Error Codes. (diff)
downloadfrr-aed070112489e92dbdcc4eb02243aec8af2d66af.tar.xz
frr-aed070112489e92dbdcc4eb02243aec8af2d66af.zip
nhrpd: Add NHRP_ERR_XXXX for zlog_err to zlog_ferr conversion
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
-rw-r--r--nhrpd/nhrp_errors.c48
-rw-r--r--nhrpd/nhrp_errors.h33
-rw-r--r--nhrpd/nhrp_main.c2
-rw-r--r--nhrpd/resolver.c9
-rw-r--r--nhrpd/subdir.am2
-rw-r--r--nhrpd/vici.c20
6 files changed, 102 insertions, 12 deletions
diff --git a/nhrpd/nhrp_errors.c b/nhrpd/nhrp_errors.c
new file mode 100644
index 000000000..f0b2dcfc5
--- /dev/null
+++ b/nhrpd/nhrp_errors.c
@@ -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
index 000000000..2b3da04f7
--- /dev/null
+++ b/nhrpd/nhrp_errors.h
@@ -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
diff --git a/nhrpd/nhrp_main.c b/nhrpd/nhrp_main.c
index ba1e00ded..e9f44e855 100644
--- a/nhrpd/nhrp_main.c
+++ b/nhrpd/nhrp_main.c
@@ -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();
diff --git a/nhrpd/resolver.c b/nhrpd/resolver.c
index 415e7523d..6515a9709 100644
--- a/nhrpd/resolver.c
+++ b/nhrpd/resolver.c
@@ -12,7 +12,10 @@
#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;
}
diff --git a/nhrpd/subdir.am b/nhrpd/subdir.am
index 5b06946c8..d66e96822 100644
--- a/nhrpd/subdir.am
+++ b/nhrpd/subdir.am
@@ -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 \
diff --git a/nhrpd/vici.c b/nhrpd/vici.c
index eb3827a12..dae29e535 100644
--- a/nhrpd/vici.c
+++ b/nhrpd/vici.c
@@ -14,9 +14,11 @@
#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: