]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pimd: Add pim_errors and define some pim specific errors
authorDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 18 Jun 2018 17:21:27 +0000 (13:21 -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>
pimd/pim_errors.c [new file with mode: 0644]
pimd/pim_errors.h [new file with mode: 0644]
pimd/pim_main.c
pimd/pim_msdp_packet.c
pimd/pim_msdp_socket.c
pimd/pim_pim.c
pimd/pim_rp.c
pimd/pim_ssm.c
pimd/pim_zlookup.c
pimd/subdir.am

diff --git a/pimd/pim_errors.c b/pimd/pim_errors.c
new file mode 100644 (file)
index 0000000..ffffa8d
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * pim_errors - code for error messages that may occur in the
+ *              pim 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 "pim_errors.h"
+
+static struct ferr_ref ferr_pim_err[] = {
+       {
+               .code = PIM_ERR_MSDP_PACKET,
+               .title = "PIM MSDP Packet Error",
+               .description = "PIM has received a packet from a peer that does not correctly decode",
+               .suggestion = "Check MSDP peer and ensure it is correctly working"
+       },
+       {
+               .code = PIM_ERR_CONFIG,
+               .title = "PIM Configuration Error",
+               .description = "Pim has detected a configuration error",
+               .suggestion = "Ensure the configuration is correct and apply correct configuration"
+       },
+       {
+               .code = END_FERR,
+       }
+};
+
+void pim_error_init(void)
+{
+       ferr_ref_init();
+
+       ferr_ref_add(ferr_pim_err);
+}
diff --git a/pimd/pim_errors.h b/pimd/pim_errors.h
new file mode 100644 (file)
index 0000000..bcb1628
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * pim_errors - header for error messages that may occur in the pim 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 __PIM_ERRORS_H__
+#define __PIM_ERRORS_H__
+
+#include "ferr.h"
+#include "pim_errors.h"
+
+enum pim_ferr_refs {
+       PIM_ERR_MSDP_PACKET = PIM_FERR_START,
+       PIM_ERR_CONFIG,
+};
+
+extern void pim_error_init(void);
+
+#endif
index c4cab25ae9b202daa8d5f8b0ce395698e20f5b7d..578794086d5eb4c1b3ac3edf11868b1324571a04 100644 (file)
@@ -47,6 +47,7 @@
 #include "pim_msdp.h"
 #include "pim_iface.h"
 #include "pim_bfd.h"
+#include "pim_errors.h"
 
 extern struct host host;
 
@@ -108,6 +109,7 @@ int main(int argc, char **argv, char **envp)
        /*
         * Initializations
         */
+       pim_error_init();
        pim_vrf_init();
        access_list_init();
        prefix_list_init();
index 7aa9357b8535af1bb91407f5290018e12da083eb..5c950e8dc2952acd7d60b8d1cdde30d22b0af6e9 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "pimd.h"
 #include "pim_str.h"
+#include "pim_errors.h"
 
 #include "pim_msdp.h"
 #include "pim_msdp_packet.h"
@@ -483,8 +484,9 @@ static void pim_msdp_pkt_sa_rx_one(struct pim_msdp_peer *mp, struct in_addr rp)
 
        if (prefix_len != 32) {
                /* ignore SA update if the prefix length is not 32 */
-               zlog_err("rxed sa update with invalid prefix length %d",
-                        prefix_len);
+               zlog_ferr(PIM_ERR_MSDP_PACKET,
+                         "rxed sa update with invalid prefix length %d",
+                         prefix_len);
                return;
        }
        if (PIM_DEBUG_MSDP_PACKETS) {
index 5b1afb774b665da204cbdd3f568a93accc6d5f96..d5bd34557e81cdf3a8674c85239f3634d4bab349 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "pimd.h"
 #include "pim_sock.h"
+#include "pim_errors.h"
 
 #include "pim_msdp.h"
 #include "pim_msdp_socket.h"
@@ -93,8 +94,9 @@ static int pim_msdp_sock_accept(struct thread *thread)
        if (!mp || !PIM_MSDP_PEER_IS_LISTENER(mp)) {
                ++pim->msdp.rejected_accepts;
                if (PIM_DEBUG_MSDP_EVENTS) {
-                       zlog_err("msdp peer connection refused from %s",
-                                sockunion2str(&su, buf, SU_ADDRSTRLEN));
+                       zlog_ferr(PIM_ERR_MSDP_PACKET,
+                                 "msdp peer connection refused from %s",
+                                 sockunion2str(&su, buf, SU_ADDRSTRLEN));
                }
                close(msdp_sock);
                return -1;
index f506875282d3cb65f9d797b06e3f55b2f00bb474..6fb0b2892e0da205e49d1a50045e3887ba6ef744 100644 (file)
@@ -38,6 +38,7 @@
 #include "pim_assert.h"
 #include "pim_msg.h"
 #include "pim_register.h"
+#include "pim_errors.h"
 
 static int on_pim_hello_send(struct thread *t);
 static int pim_hello_send(struct interface *ifp, uint16_t holdtime);
@@ -115,8 +116,9 @@ void pim_sock_delete(struct interface *ifp, const char *delete_message)
                  delete_message);
 
        if (!ifp->info) {
-               zlog_err("%s: %s: but PIM not enabled on interface %s (!)",
-                        __PRETTY_FUNCTION__, delete_message, ifp->name);
+               zlog_ferr(PIM_ERR_CONFIG,
+                         "%s: %s: but PIM not enabled on interface %s (!)",
+                         __PRETTY_FUNCTION__, delete_message, ifp->name);
                return;
        }
 
index fd1b96505b23bea09fe44bdb8bcc619c9d4662f4..77e76c3b0b7a3b03a9038e8083acd0d8e09ca87b 100644 (file)
@@ -111,7 +111,8 @@ void pim_rp_init(struct pim_instance *pim)
        rp_info = XCALLOC(MTYPE_PIM_RP, sizeof(*rp_info));
 
        if (!str2prefix("224.0.0.0/4", &rp_info->group)) {
-               zlog_err("Unable to convert 224.0.0.0/4 to prefix");
+               zlog_ferr(LIB_ERR_DEVELOPMENT,
+                         "Unable to convert 224.0.0.0/4 to prefix");
                list_delete_and_null(&pim->rp_list);
                route_table_finish(pim->rp_table);
                XFREE(MTYPE_PIM_RP, rp_info);
index 1f7cfcaa91e5d0828e0f4fbe581bd3966c581066..f10cef9ce400dbcc2c40e4366f78acbef358d99d 100644 (file)
@@ -24,6 +24,7 @@
 #include <lib/vty.h>
 #include <lib/vrf.h>
 #include <lib/plist.h>
+#include <lib/lib_errors.h>
 
 #include "pimd.h"
 #include "pim_ssm.h"
@@ -72,8 +73,9 @@ static int pim_is_grp_standard_ssm(struct prefix *group)
 
        if (first) {
                if (!str2prefix(PIM_SSM_STANDARD_RANGE, &group_ssm))
-                       zlog_err("%s: Failure to Read Group Address: %s",
-                                __PRETTY_FUNCTION__, PIM_SSM_STANDARD_RANGE);
+                       zlog_ferr(LIB_ERR_DEVELOPMENT,
+                                 "%s: Failure to Read Group Address: %s",
+                                 __PRETTY_FUNCTION__, PIM_SSM_STANDARD_RANGE);
 
                first = 0;
        }
index 12958b0390a983382f20f6b6930cd54d6b5cbc7b..8b67fb7f59a6d518a31fb4a38860428ffd572898 100644 (file)
@@ -315,14 +315,15 @@ static int zclient_lookup_nexthop_once(struct pim_instance *pim,
 
        /* Check socket. */
        if (zlookup->sock < 0) {
-               zlog_err("%s: zclient lookup socket is not connected",
-                        __PRETTY_FUNCTION__);
+               zlog_ferr(LIB_ERR_ZAPI_SOCKET,
+                         "%s: zclient lookup socket is not connected",
+                         __PRETTY_FUNCTION__);
                zclient_lookup_failed(zlookup);
                return -1;
        }
 
        if (pim->vrf->vrf_id == VRF_UNKNOWN) {
-               zlog_err(
+               zlog_notice(
                        "%s: VRF: %s does not fully exist yet, delaying lookup",
                        __PRETTY_FUNCTION__, pim->vrf->name);
                return -1;
index 0696d9b1e81762fdeca60442fad45b5595224b39..55d56ece976255f88fee56472fdcda0b3c2c8e88 100644 (file)
@@ -15,6 +15,7 @@ pimd_libpim_a_SOURCES = \
        pimd/pim_bfd.c \
        pimd/pim_br.c \
        pimd/pim_cmd.c \
+       pimd/pim_errors.c \
        pimd/pim_hello.c \
        pimd/pim_iface.c \
        pimd/pim_ifchannel.c \
@@ -64,6 +65,7 @@ noinst_HEADERS += \
        pimd/pim_bfd.h \
        pimd/pim_br.h \
        pimd/pim_cmd.h \
+       pimd/pim_errors.h \
        pimd/pim_hello.h \
        pimd/pim_iface.h \
        pimd/pim_ifchannel.h \