summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2018-06-18 08:49:36 -0400
committerQuentin Young <qlyoung@cumulusnetworks.com>2018-08-14 20:02:05 +0000
commit4d43f68aeb2d26d7ea5e69a97970c4a4545882c5 (patch)
treecc713f5f29402d72a1d49e0a6ae9b2ced4ee9374
parent174482ef377034d2ab3c14df0b4f4191731f1316 (diff)
lib, zebra: Add LIB_ERR_INTERFACE
Add a error type that allows us to track bad interface states. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
-rw-r--r--lib/if.c1
-rw-r--r--lib/if.h12
-rw-r--r--lib/lib_errors.c6
-rw-r--r--lib/lib_errors.h1
-rw-r--r--zebra/if_ioctl.c8
-rw-r--r--zebra/if_netlink.c24
-rw-r--r--zebra/interface.c4
7 files changed, 37 insertions, 19 deletions
diff --git a/lib/if.c b/lib/if.c
index dd7d210381..6023624dc1 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -23,6 +23,7 @@
#include "linklist.h"
#include "vector.h"
+#include "lib_errors.h"
#include "vty.h"
#include "command.h"
#include "vrf.h"
diff --git a/lib/if.h b/lib/if.h
index 7b65bbd2e5..4379e1ad8c 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -297,28 +297,32 @@ DECLARE_QOBJ_TYPE(interface)
#define IFNAME_RB_INSERT(vrf, ifp) \
if (RB_INSERT(if_name_head, &vrf->ifaces_by_name, (ifp))) \
- zlog_err( \
+ zlog_ferr( \
+ LIB_ERR_INTERFACE, \
"%s(%s): corruption detected -- interface with this " \
"name exists already in VRF %u!", \
__func__, (ifp)->name, (ifp)->vrf_id);
#define IFNAME_RB_REMOVE(vrf, ifp) \
if (RB_REMOVE(if_name_head, &vrf->ifaces_by_name, (ifp)) == NULL) \
- zlog_err( \
+ zlog_ferr( \
+ LIB_ERR_INTERFACE, \
"%s(%s): corruption detected -- interface with this " \
"name doesn't exist in VRF %u!", \
__func__, (ifp)->name, (ifp)->vrf_id);
#define IFINDEX_RB_INSERT(vrf, ifp) \
if (RB_INSERT(if_index_head, &vrf->ifaces_by_index, (ifp))) \
- zlog_err( \
+ zlog_ferr( \
+ LIB_ERR_INTERFACE, \
"%s(%u): corruption detected -- interface with this " \
"ifindex exists already in VRF %u!", \
__func__, (ifp)->ifindex, (ifp)->vrf_id);
#define IFINDEX_RB_REMOVE(vrf, ifp) \
if (RB_REMOVE(if_index_head, &vrf->ifaces_by_index, (ifp)) == NULL) \
- zlog_err( \
+ zlog_ferr( \
+ LIB_ERR_INTERFACE, \
"%s(%u): corruption detected -- interface with this " \
"ifindex doesn't exist in VRF %u!", \
__func__, (ifp)->ifindex, (ifp)->vrf_id);
diff --git a/lib/lib_errors.c b/lib/lib_errors.c
index 44d9ecd033..d1db7b777a 100644
--- a/lib/lib_errors.c
+++ b/lib/lib_errors.c
@@ -77,6 +77,12 @@ static struct ferr_ref ferr_lib_err[] = {
.suggestion = "Examine callback message and ensure snmp is properly setup and working"
},
{
+ .code = LIB_ERR_INTERFACE,
+ .title = "Interface Subsystem Error",
+ .description = "FRR has detected a problem with interface data from the kernel as it deviates\nfrom what we would expect to happen via normal netlink messaging",
+ .suggestion = "Open an Issue with all relevant log files and restart FRR"
+ },
+ {
.code = END_FERR,
}
};
diff --git a/lib/lib_errors.h b/lib/lib_errors.h
index 671c768eb9..67feb68827 100644
--- a/lib/lib_errors.h
+++ b/lib/lib_errors.h
@@ -33,6 +33,7 @@ enum lib_ferr_refs {
LIB_ERR_SYSTEM_CALL,
LIB_ERR_VTY,
LIB_ERR_SNMP,
+ LIB_ERR_INTERFACE,
};
extern void lib_error_init(void);
diff --git a/zebra/if_ioctl.c b/zebra/if_ioctl.c
index f5ed945527..8e2e64edc6 100644
--- a/zebra/if_ioctl.c
+++ b/zebra/if_ioctl.c
@@ -181,7 +181,8 @@ static int if_getaddrs(void)
for (ifapfree = ifap; ifap; ifap = ifap->ifa_next) {
if (ifap->ifa_addr == NULL) {
- zlog_err(
+ zlog_ferr(
+ LIB_ERR_INTERFACE,
"%s: nonsensical ifaddr with NULL ifa_addr, ifname %s",
__func__,
(ifap->ifa_name ? ifap->ifa_name : "(null)"));
@@ -190,8 +191,9 @@ static int if_getaddrs(void)
ifp = if_lookup_by_name(ifap->ifa_name, VRF_DEFAULT);
if (ifp == NULL) {
- zlog_err("if_getaddrs(): Can't lookup interface %s\n",
- ifap->ifa_name);
+ zlog_ferr(LIB_ERR_INTERFACE,
+ "if_getaddrs(): Can't lookup interface %s\n",
+ ifap->ifa_name);
continue;
}
diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c
index cdf24eaf46..26aef2bb0a 100644
--- a/zebra/if_netlink.c
+++ b/zebra/if_netlink.c
@@ -80,9 +80,9 @@ static void set_ifindex(struct interface *ifp, ifindex_t ifi_index,
if (((oifp = if_lookup_by_index_per_ns(zns, ifi_index)) != NULL)
&& (oifp != ifp)) {
if (ifi_index == IFINDEX_INTERNAL)
- zlog_err(
- "Netlink is setting interface %s ifindex to reserved "
- "internal value %u",
+ zlog_ferr(
+ LIB_ERR_INTERFACE,
+ "Netlink is setting interface %s ifindex to reserved internal value %u",
ifp->name, ifi_index);
else {
if (IS_ZEBRA_DEBUG_KERNEL)
@@ -90,9 +90,9 @@ static void set_ifindex(struct interface *ifp, ifindex_t ifi_index,
"interface index %d was renamed from %s to %s",
ifi_index, oifp->name, ifp->name);
if (if_is_up(oifp))
- zlog_err(
- "interface rename detected on up interface: index %d "
- "was renamed from %s to %s, results are uncertain!",
+ zlog_ferr(
+ LIB_ERR_INTERFACE,
+ "interface rename detected on up interface: index %d was renamed from %s to %s, results are uncertain!",
ifi_index, oifp->name, ifp->name);
if_delete_update(oifp);
}
@@ -310,8 +310,8 @@ static void netlink_vrf_change(struct nlmsghdr *h, struct rtattr *tb,
vrf = vrf_get((vrf_id_t)ifi->ifi_index,
name); // It would create vrf
if (!vrf) {
- zlog_err("VRF %s id %u not created", name,
- ifi->ifi_index);
+ zlog_ferr(LIB_ERR_INTERFACE, "VRF %s id %u not created",
+ name, ifi->ifi_index);
return;
}
@@ -332,8 +332,9 @@ static void netlink_vrf_change(struct nlmsghdr *h, struct rtattr *tb,
/* Enable the created VRF. */
if (!vrf_enable(vrf)) {
- zlog_err("Failed to enable VRF %s id %u", name,
- ifi->ifi_index);
+ zlog_ferr(LIB_ERR_INTERFACE,
+ "Failed to enable VRF %s id %u", name,
+ ifi->ifi_index);
return;
}
@@ -916,7 +917,8 @@ int netlink_interface_addr(struct nlmsghdr *h, ns_id_t ns_id, int startup)
ifp = if_lookup_by_index_per_ns(zns, ifa->ifa_index);
if (ifp == NULL) {
- zlog_err(
+ zlog_ferr(
+ LIB_ERR_INTERFACE,
"netlink_interface_addr can't find interface by index %d",
ifa->ifa_index);
return -1;
diff --git a/zebra/interface.c b/zebra/interface.c
index 4211155c27..9811badfc4 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -22,6 +22,7 @@
#include <zebra.h>
#include "if.h"
+#include "lib_errors.h"
#include "vty.h"
#include "sockunion.h"
#include "prefix.h"
@@ -718,7 +719,8 @@ void if_delete_update(struct interface *ifp)
struct zebra_if *zif;
if (if_is_up(ifp)) {
- zlog_err(
+ zlog_ferr(
+ LIB_ERR_INTERFACE,
"interface %s vrf %u index %d is still up while being deleted.",
ifp->name, ifp->vrf_id, ifp->ifindex);
return;