Skip to content

Commit 2007f16

Browse files
rvaideeshPdoijode
authored andcommitted
ospfd: add error codes and improve operator messaging
Convert generic zlog_err() calls to specific flog_err() calls by adding appropriate error codes in ospfd component. This commit adds new error codes and converts logging calls to improve error categorization and diagnosis. Additionally, error message formatting has been improved to ensure character length per line. Signed-off-by: Vaideesh Ravi Shankar <[email protected]>
1 parent 7154ecc commit 2007f16

File tree

8 files changed

+37
-14
lines changed

8 files changed

+37
-14
lines changed

ospfd/ospf_errors.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,25 @@ static struct log_ref ferr_ospf_err[] = {
166166
.code = EC_OSPF_LARGE_HELLO,
167167
.title = "OSPF Encountered a Large Hello",
168168
.description = "OSPF attempted to send a Hello larger than MTU but did not",
169-
.suggestion = "Too many neighbors configured on a single interface. Suggestion is to decrease the number of neighbors on a single interface/subnet"
169+
.suggestion = "Too many neighbors configured on a single interface. Suggestion is to decrease the number of neighbors on a single interface/subnet",
170+
},
171+
{
172+
.code = EC_OSPF_LDP_SYNC_DOWN,
173+
.title = "OSPF LDP synchronization down",
174+
.description = "OSPF-LDP sync detected that LDP session went down",
175+
.suggestion = "Check LDP sessions and restart LDP if necessary. Verify OSPF-LDP sync configuration.",
176+
},
177+
{
178+
.code = EC_OSPF_CONFIG_TIMEOUT,
179+
.title = "OSPF configuration timeout",
180+
.description = "OSPF configuration end timer expired during config application",
181+
.suggestion = "Review configuration timing or increase the timeout limit.",
182+
},
183+
{
184+
.code = EC_OSPF_SR_RI_SCOPE,
185+
.title = "OSPF Segment Routing router-info scope error",
186+
.description = "OSPF Segment Routing router-info LSA uses incorrect flooding scope (should be Area scope, not AS scope)",
187+
.suggestion = "Change router-info flooding scope to Area flooding for Segment Routing configuration.",
170188
},
171189
{
172190
.code = END_FERR,

ospfd/ospf_errors.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ enum ospf_log_refs {
3636
EC_OSPF_PTP_NEIGHBOR,
3737
EC_OSPF_LSA_SIZE,
3838
EC_OSPF_LARGE_HELLO,
39+
EC_OSPF_LDP_SYNC_DOWN,
40+
EC_OSPF_CONFIG_TIMEOUT,
41+
EC_OSPF_SR_RI_SCOPE,
3942
};
4043

4144
extern void ospf_error_init(void);

ospfd/ospf_gr_helper.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "filter.h"
1919
#include "log.h"
2020
#include "jhash.h"
21+
#include "lib/lib_errors.h"
2122

2223
#include "ospfd/ospfd.h"
2324
#include "ospfd/ospf_interface.h"
@@ -688,8 +689,8 @@ void ospf_gr_helper_exit(struct ospf_neighbor *nbr,
688689
ospf->last_exit_reason = reason;
689690

690691
if (ospf->active_restarter_cnt <= 0) {
691-
zlog_err(
692-
"OSPF GR-Helper: active_restarter_cnt should be greater than zero here.");
692+
flog_err(EC_LIB_DEVELOPMENT,
693+
"OSPF GR-Helper: active_restarter_cnt should be greater than zero here.");
693694
return;
694695
}
695696
/* Decrement active Restarter count */

ospfd/ospf_ldp_sync.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <lib/json.h>
2121
#include "defaults.h"
2222
#include "ldp_sync.h"
23+
#include "ospfd/ospf_errors.h"
2324

2425
#include "ospfd.h"
2526
#include "ospf_interface.h"
@@ -213,7 +214,7 @@ void ospf_ldp_sync_handle_client_close(struct zapi_client_close_info *info)
213214
* set cost to LSInfinity
214215
* send request to LDP for LDP-SYNC state for each interface
215216
*/
216-
zlog_err("%s: LDP down", __func__);
217+
flog_err(EC_OSPF_LDP_SYNC_DOWN, "%s: LDP down", __func__);
217218

218219
vrf = vrf_lookup_by_id(ospf->vrf_id);
219220
FOR_ALL_INTERFACES (vrf, ifp)

ospfd/ospf_lsa.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "sockunion.h" /* for inet_aton() */
2020
#include "checksum.h"
2121
#include "network.h"
22+
#include "lib/lib_errors.h"
2223

2324
#include "ospfd/ospfd.h"
2425
#include "ospfd/ospf_interface.h"
@@ -887,7 +888,7 @@ static struct ospf_lsa *ospf_router_lsa_originate(struct ospf_area *area)
887888

888889
/* Create new router-LSA instance. */
889890
if ((new = ospf_router_lsa_new(area)) == NULL) {
890-
zlog_err("%s: ospf_router_lsa_new returned NULL", __func__);
891+
flog_err(EC_LIB_DEVELOPMENT, "%s: ospf_router_lsa_new returned NULL", __func__);
891892
return NULL;
892893
}
893894

@@ -935,7 +936,7 @@ static struct ospf_lsa *ospf_router_lsa_refresh(struct ospf_lsa *lsa)
935936

936937
/* Create new router-LSA instance. */
937938
if ((new = ospf_router_lsa_new(area)) == NULL) {
938-
zlog_err("%s: ospf_router_lsa_new returned NULL", __func__);
939+
flog_err(EC_LIB_DEVELOPMENT, "%s: ospf_router_lsa_new returned NULL", __func__);
939940
return NULL;
940941
}
941942

ospfd/ospf_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ FRR_DAEMON_INFO(ospfd, OSPF,
176176

177177
static void ospf_config_finish(struct event *t)
178178
{
179-
zlog_err("OSPF configuration end timer expired after %d seconds.",
179+
flog_err(EC_OSPF_CONFIG_TIMEOUT, "OSPF configuration end timer expired after %d seconds.",
180180
OSPF_PRE_CONFIG_MAX_WAIT_SECONDS);
181181
}
182182

ospfd/ospf_ri.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -603,10 +603,9 @@ void ospf_router_info_update_sr(bool enable, struct sr_node *srn)
603603

604604
/* Verify that scope is AREA */
605605
if (OspfRI.scope != OSPF_OPAQUE_AREA_LSA) {
606-
zlog_err(
607-
"RI (%s): Router Info is %s flooding: Change scope to Area flooding for Segment Routing",
608-
__func__,
609-
OspfRI.scope == OSPF_OPAQUE_AREA_LSA ? "Area" : "AS");
606+
flog_err(EC_OSPF_SR_RI_SCOPE,
607+
"RI (%s): Router Info is %s flooding: Change scope to Area flooding for Segment Routing",
608+
__func__, OspfRI.scope == OSPF_OPAQUE_AREA_LSA ? "Area" : "AS");
610609
return;
611610
}
612611

ospfd/ospf_sr.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ static int sr_local_block_init(uint32_t lower_bound, uint32_t upper_bound)
266266
*/
267267
size = upper_bound - lower_bound + 1;
268268
if (ospf_zebra_request_label_range(lower_bound, size)) {
269-
zlog_err("SR: Error reserving SRLB [%u/%u] %u labels",
269+
flog_err(EC_OSPF_SR_SID_OVERFLOW, "SR: Error reserving SRLB [%u/%u] %u labels",
270270
lower_bound, upper_bound, size);
271271
return -1;
272272
}
@@ -301,8 +301,8 @@ static int sr_global_block_init(uint32_t start, uint32_t size)
301301
/* request chunk */
302302
uint32_t end = start + size - 1;
303303
if (ospf_zebra_request_label_range(start, size) < 0) {
304-
zlog_err("SR: Error reserving SRGB [%u/%u], %u labels", start,
305-
end, size);
304+
flog_err(EC_OSPF_SR_SID_OVERFLOW, "SR: Error reserving SRGB [%u/%u], %u labels",
305+
start, end, size);
306306
return -1;
307307
}
308308

0 commit comments

Comments
 (0)