aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2024-11-29 14:14:16 +0100
committerBenoît Ganne <bganne@cisco.com>2024-11-29 14:14:16 +0100
commit709f40c29d5c8d8b8974823aae537d52a91afa30 (patch)
tree23e9e972267c0fa50889a7ac520814422f759e88
parent978d48b7656a0b2dd53a032c37681c5e7d66ba90 (diff)
vapi: fix vapi_ctx_alloc
clib_time_init() may use clib main heap when it needs to parse /proc or /sys. Make sure the main heap is initialized early. Type: fix Change-Id: I891504f3455b97c06da25e4833a8fb6941eb428a Signed-off-by: Benoît Ganne <bganne@cisco.com>
-rw-r--r--src/vpp-api/vapi/vapi.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/vpp-api/vapi/vapi.c b/src/vpp-api/vapi/vapi.c
index c818ab0bbec..9e5101bd9f9 100644
--- a/src/vpp-api/vapi/vapi.c
+++ b/src/vpp-api/vapi/vapi.c
@@ -300,6 +300,10 @@ vapi_lookup_vapi_msg_id_t (vapi_ctx_t ctx, u16 vl_msg_id)
vapi_error_e
vapi_ctx_alloc (vapi_ctx_t * result)
{
+ if (!clib_mem_get_per_cpu_heap () && !clib_mem_init (0, 1024L * 1024 * 32))
+ {
+ return VAPI_ENOMEM;
+ }
vapi_ctx_t ctx = calloc (1, sizeof (struct vapi_ctx_s));
if (!ctx)
{
@@ -968,11 +972,6 @@ vapi_connect_ex (vapi_ctx_t ctx, const char *name, const char *path,
return VAPI_EINVAL;
}
- if (!clib_mem_get_per_cpu_heap () && !clib_mem_init (0, 1024L * 1024 * 32))
- {
- return VAPI_ENOMEM;
- }
-
ctx->requests_size = max_outstanding_requests;
const size_t size = ctx->requests_size * sizeof (*ctx->requests);
void *tmp = realloc (ctx->requests, size);