From 803375ac696dc82487c94587eedfa49fcc9cd5bb Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Sat, 8 Jul 2023 11:20:14 +0300 Subject: zebra: Do not check ifp for NULL It's already checked at the bottom of the function. Signed-off-by: Donatas Abraitis --- zebra/interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'zebra/interface.c') diff --git a/zebra/interface.c b/zebra/interface.c index e923c0a187..6be6f51598 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -1444,7 +1444,7 @@ static void zebra_if_netconf_update_ctx(struct zebra_dplane_ctx *ctx, linkdown_set = &zrouter.default_linkdownv6; } } else { - zif = ifp ? ifp->info : NULL; + zif = ifp->info; if (!zif) { if (IS_ZEBRA_DEBUG_KERNEL) zlog_debug( -- cgit v1.2.3 From f5fee8dd54e7e17d759ebe608b81af01dbd476b2 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Sat, 8 Jul 2023 11:23:51 +0300 Subject: zebra: Check if ifp is not NULL in zebra_if_update_ctx() Use the same logic as zebra_if_netconf_update_ctx(). Signed-off-by: Donatas Abraitis --- zebra/interface.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'zebra/interface.c') diff --git a/zebra/interface.c b/zebra/interface.c index 6be6f51598..cf36594b34 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -1368,6 +1368,13 @@ static void zebra_if_update_ctx(struct zebra_dplane_ctx *ctx, bool pd_reason_val; bool down; + if (!ifp) { + if (IS_ZEBRA_DEBUG_KERNEL) + zlog_debug("%s: Can't find ifp", __func__); + + return; + } + dp_res = dplane_ctx_get_status(ctx); pd_reason_val = dplane_ctx_get_intf_pd_reason_val(ctx); down = dplane_ctx_intf_is_protodown(ctx); -- cgit v1.2.3 From 4bd04364adb27e18052730a54ee9a85ae12386c2 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Sat, 8 Jul 2023 11:26:03 +0300 Subject: zebra: Guard printing an error by checking if VRF is not NULL Check if vrf_lookup_by_id() didn't return a NULL before dereferencing in flor_err(). Signed-off-by: Donatas Abraitis --- zebra/interface.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'zebra/interface.c') diff --git a/zebra/interface.c b/zebra/interface.c index cf36594b34..4c9f9f3092 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -1531,10 +1531,16 @@ static void interface_vrf_change(enum dplane_op_e op, ifindex_t ifindex, if (exist_id != VRF_DEFAULT) { vrf = vrf_lookup_by_id(exist_id); - flog_err( - EC_ZEBRA_VRF_MISCONFIGURED, - "VRF %s id %u table id overlaps existing vrf %s(%d), misconfiguration exiting", - name, ifindex, vrf->name, vrf->vrf_id); + if (vrf) + flog_err(EC_ZEBRA_VRF_MISCONFIGURED, + "VRF %s id %u table id overlaps existing vrf %s(%d), misconfiguration exiting", + name, ifindex, vrf->name, + vrf->vrf_id); + else + flog_err(EC_ZEBRA_VRF_NOT_FOUND, + "VRF %s id %u does not exist", + name, ifindex); + exit(-1); } } -- cgit v1.2.3