Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error reference cards #8

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/command_parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ yyerror (CMD_YYLTYPE *loc, struct parser_ctx *ctx, char const *msg)
char spacing[256];
int lineno = 0;

zlog_err ("%s: FATAL parse error: %s", __func__, msg);
zlog_err ("%s: %d:%d-%d of this command definition:", __func__, loc->first_line, loc->first_column, loc->last_column);
zlog_notice ("%s: FATAL parse error: %s", __func__, msg);
zlog_notice ("%s: %d:%d-%d of this command definition:", __func__, loc->first_line, loc->first_column, loc->last_column);

line = tmpstr;
do {
Expand All @@ -414,7 +414,7 @@ yyerror (CMD_YYLTYPE *loc, struct parser_ctx *ctx, char const *msg)
if (eol)
*eol++ = '\0';

zlog_err ("%s: | %s", __func__, line);
zlog_notice ("%s: | %s", __func__, line);
if (lineno == loc->first_line && lineno == loc->last_line
&& loc->first_column < (int)sizeof(spacing) - 1
&& loc->last_column < (int)sizeof(spacing) - 1) {
Expand All @@ -426,7 +426,7 @@ yyerror (CMD_YYLTYPE *loc, struct parser_ctx *ctx, char const *msg)
memset(spacing, ' ', loc->first_column - 1);
memset(spacing + loc->first_column - 1, '^', len);
spacing[loc->first_column - 1 + len] = '\0';
zlog_err ("%s: | %s", __func__, spacing);
zlog_notice ("%s: | %s", __func__, spacing);
}
} while ((line = eol));
free(tmpstr);
Expand Down
1 change: 1 addition & 0 deletions lib/lib_errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "ferr.h"
#include "lib_errors.h"

/* clang-format off */
Expand Down
4 changes: 2 additions & 2 deletions ospf6d/ospf6_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ int ospf6_serv_sock(void)
zlog_warn("Network: can't create OSPF6 socket.");
if (ospf6d_privs.change(ZPRIVS_LOWER))
zlog_ferr(LIB_ERR_PRIVILEGES,
"ospf_sock_init: could not lower privs");
"ospf6_sock_init: could not lower privs");
return -1;
}
if (ospf6d_privs.change(ZPRIVS_LOWER))
zlog_ferr(LIB_ERR_PRIVILEGES,
"ospf_sock_init: could not lower privs");
"ospf6_sock_init: could not lower privs");

/* set socket options */
#if 1
Expand Down
84 changes: 84 additions & 0 deletions ospfd/ospf_errors.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* ospf_errors - code for error messages that may occur in the
* ospf process
* Copyright (C) 2018 Cumulus Networks, Inc.
* Chirag Shah
*
* 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 "ospf_errors.h"

static struct ferr_ref ferr_ospf_err[] = {
{
.code = OSPF_ERR_PKT_PROCESS,
.title = "Failure to process a packet",
.description = "OSPF attempted to process a received packet but could not",
.suggestion = "Most likely a bug. If the problem persists, report the problem for troubleshooting"
},
{
.code = OSPF_ERR_ROUTER_LSA_MISMATCH,
.title = "Failure to process Router LSA",
.description = "OSPF attempted to process a Router LSA but Advertising ID mismtach with link id",
.suggestion = "Check OSPF network config for any config issue, If the problem persists, report the problem for troubleshooting"
},
{
.code = OSPF_ERR_DOMAIN_CORRUPT,
.title = "OSPF Domain Corruption",
.description = "OSPF attempted to process a Router LSA but Advertising ID mismtach with link id",
.suggestion = "Check OSPF network Database for corrupted LSA, If the problem persists, shutdown ospf domain and report the problem for troubleshooting"
},
{
.code = OSPF_ERR_INIT_FAIL,
.title = "OSPF Initialization failure",
.description = "OSPF failed to initialized ospf default insance",
.suggestion = "Ensure there is adequate memory on the device. If the problem persists, report the problem for troubleshooting"
},
{
.code = OSPF_ERR_SR_INVALID_DB,
.title = "OSPF SR Invalid DB",
.description = "OSPF Segment Routing Database is invalid",
.suggestion = "Most likely a bug. If the problem persists, report the problem for troubleshooting"
},
{
.code = OSPF_ERR_SR_NODE_CREATE,
.title = "OSPF SR hash node creation failed",
.description = "OSPF Segment Routing node creation failed",
.suggestion = "Most likely a bug. If the problem persists, report the problem for troubleshooting"
},
{
.code = OSPF_ERR_SR_INVALID_LSA_ID,
.title = "OSPF SR Invalid lsa id",
.description = "OSPF Segment Routing invalid lsa id",
.suggestion = "Restart ospf instance, If the problem persists, report the problem for troubleshooting"
},
{
.code = OSPF_ERR_SR_INVALID_ALGORITHM,
.title = "OSPF SR Invalid Algorithm",
.description = "OSPF Segment Routing invalid Algorithm",
.suggestion = "Most likely a bug. If the problem persists, report the problem for troubleshooting"
},

{
.code = END_FERR,
}
};

void ospf_error_init(void)
{
ferr_ref_init();

ferr_ref_add(ferr_ospf_err);
}
38 changes: 38 additions & 0 deletions ospfd/ospf_errors.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* ospf_errors - header for error messages that may occur in the ospf process
* Copyright (C) 2018 Cumulus Networks, Inc.
* Chirag Shah
*
* 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 __OSPF_ERRORS_H__
#define __OSPF_ERRORS_H__

#include "ferr.h"

enum ospf_ferr_refs {
OSPF_ERR_PKT_PROCESS = OSPF_FERR_START,
OSPF_ERR_ROUTER_LSA_MISMATCH,
OSPF_ERR_DOMAIN_CORRUPT,
OSPF_ERR_INIT_FAIL,
OSPF_ERR_SR_INVALID_DB,
OSPF_ERR_SR_NODE_CREATE,
OSPF_ERR_SR_INVALID_LSA_ID,
OSPF_ERR_SR_INVALID_ALGORITHM,
};

extern void ospf_error_init(void);

#endif
4 changes: 3 additions & 1 deletion ospfd/ospf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include "ospfd/ospf_zebra.h"
#include "ospfd/ospf_vty.h"
#include "ospfd/ospf_bfd.h"
#include "ospfd/ospf_errors.h"

/* ospfd privileges */
zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND, ZCAP_NET_ADMIN,
Expand Down Expand Up @@ -211,7 +212,8 @@ int main(int argc, char **argv)
ospf',
when quagga(ospfd) is restarted */
if (!ospf_get_instance(instance)) {
zlog_err("OSPF instance init failed: %s", strerror(errno));
zlog_ferr(OSPF_ERR_INIT_FAIL, "OSPF instance init failed: %s",
strerror(errno));
exit(1);
}

Expand Down
26 changes: 14 additions & 12 deletions ospfd/ospf_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "log.h"
#include "sockopt.h"
#include "privs.h"
#include "lib_errors.h"

#include "ospfd/ospfd.h"
#include "ospfd/ospf_network.h"
Expand Down Expand Up @@ -185,21 +186,21 @@ int ospf_sock_init(struct ospf *ospf)
/* silently return since VRF is not ready */
return -1;
}
if (ospfd_privs.change(ZPRIVS_RAISE)) {
zlog_err("ospf_sock_init: could not raise privs, %s",
safe_strerror(errno));
}
if (ospfd_privs.change(ZPRIVS_RAISE))
zlog_ferr(LIB_ERR_PRIVILEGES,
"ospf_sock_init: could not raise privs, %s",
safe_strerror(errno));

ospf_sock = vrf_socket(AF_INET, SOCK_RAW, IPPROTO_OSPFIGP, ospf->vrf_id,
ospf->name);
if (ospf_sock < 0) {
int save_errno = errno;

if (ospfd_privs.change(ZPRIVS_LOWER))
zlog_err("ospf_sock_init: could not lower privs, %s",
safe_strerror(errno));
zlog_err("ospf_read_sock_init: socket: %s",
safe_strerror(save_errno));
zlog_ferr(LIB_ERR_PRIVILEGES,
"ospf_sock_init: could not lower privs, %s",
safe_strerror(save_errno));

exit(1);
}

Expand Down Expand Up @@ -242,9 +243,10 @@ int ospf_sock_init(struct ospf *ospf)

ospf->fd = ospf_sock;
out:
if (ospfd_privs.change(ZPRIVS_LOWER)) {
zlog_err("ospf_sock_init: could not lower privs, %s",
safe_strerror(errno));
}
if (ospfd_privs.change(ZPRIVS_LOWER))
zlog_ferr(LIB_ERR_PRIVILEGES,
"ospf_sock_init: could not lower privs, %s",
safe_strerror(errno));

return ret;
}
30 changes: 17 additions & 13 deletions ospfd/ospf_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "checksum.h"
#include "md5.h"
#include "vrf.h"
#include "ospf_errors.h"

#include "ospfd/ospfd.h"
#include "ospfd/ospf_network.h"
Expand Down Expand Up @@ -232,7 +233,8 @@ void ospf_fifo_free(struct ospf_fifo *fifo)
void ospf_packet_add(struct ospf_interface *oi, struct ospf_packet *op)
{
if (!oi->obuf) {
zlog_err(
zlog_ferr(
OSPF_ERR_PKT_PROCESS,
"ospf_packet_add(interface %s in state %d [%s], packet type %s, "
"destination %s) called with NULL obuf, ignoring "
"(please report this bug)!\n",
Expand All @@ -255,7 +257,8 @@ static void ospf_packet_add_top(struct ospf_interface *oi,
struct ospf_packet *op)
{
if (!oi->obuf) {
zlog_err(
zlog_ferr(
OSPF_ERR_PKT_PROCESS,
"ospf_packet_add(interface %s in state %d [%s], packet type %s, "
"destination %s) called with NULL obuf, ignoring "
"(please report this bug)!\n",
Expand Down Expand Up @@ -1917,17 +1920,18 @@ static void ospf_ls_upd(struct ospf *ospf, struct ip *iph,
char buf2[INET_ADDRSTRLEN];
char buf3[INET_ADDRSTRLEN];

zlog_err(
"Incoming Router-LSA from %s with "
"Adv-ID[%s] != LS-ID[%s]",
inet_ntop(AF_INET, &ospfh->router_id,
buf1, INET_ADDRSTRLEN),
inet_ntop(AF_INET, &lsa->data->id, buf2,
INET_ADDRSTRLEN),
inet_ntop(AF_INET,
&lsa->data->adv_router, buf3,
INET_ADDRSTRLEN));
zlog_err(
zlog_ferr(OSPF_ERR_ROUTER_LSA_MISMATCH,
"Incoming Router-LSA from %s with "
"Adv-ID[%s] != LS-ID[%s]",
inet_ntop(AF_INET, &ospfh->router_id,
buf1, INET_ADDRSTRLEN),
inet_ntop(AF_INET, &lsa->data->id,
buf2, INET_ADDRSTRLEN),
inet_ntop(AF_INET,
&lsa->data->adv_router,
buf3, INET_ADDRSTRLEN));
zlog_ferr(
OSPF_ERR_DOMAIN_CORRUPT,
"OSPF domain compromised by attack or corruption. "
"Verify correct operation of -ALL- OSPF routers.");
DISCARD_LSA(lsa, 0);
Expand Down
Loading