summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarmine Scarpitta <cscarpit@cisco.com>2024-05-05 07:25:57 +0200
committerton31337 <3352707+ton31337@users.noreply.github.com>2024-05-06 19:08:02 +0000
commitd78ec6a55f91d1c72e3a60c4abf8cf626f8cbc45 (patch)
tree055c84c81e94f8f59de537d00b25d2084718f034
parent8a07a253c756742efc45514dafaf770bab0b8e38 (diff)
bgpd: Fix the order of NULL check and ZAPI decode
When BGP receives an SRV6_LOCATOR_ADD message from zebra, it calls the `bgp_zebra_process_srv6_locator_add()` function to process the message. `bgp_zebra_process_srv6_locator_add()` decodes the message first, and then if the pointer to the default BGP instance is NULL (i.e. the default BGP instance is not configured yet), it returns early without doing anything and without using the decoded message information. This commit fixes the order of the operations executed by `bgp_zebra_process_srv6_locator_add()`. We first ensure that the default BGP instance is ready and we return early if it is not. Then, we decode the message and do something with the information contained in it. Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com> (cherry picked from commit bdc2c7bc5473b5582419702211c22e5d29bf0631)
-rw-r--r--bgpd/bgp_zebra.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 77b7a0c9ec..bc51d14b39 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -3197,12 +3197,12 @@ static int bgp_zebra_process_srv6_locator_add(ZAPI_CALLBACK_ARGS)
struct bgp *bgp = bgp_get_default();
const char *loc_name = bgp->srv6_locator_name;
- if (zapi_srv6_locator_decode(zclient->ibuf, &loc) < 0)
- return -1;
-
if (!bgp || !bgp->srv6_enabled)
return 0;
+ if (zapi_srv6_locator_decode(zclient->ibuf, &loc) < 0)
+ return -1;
+
if (bgp_zebra_srv6_manager_get_locator_chunk(loc_name) < 0)
return -1;