From e594cf286a0ed1c7a207b120a4761a5fb9695c68 Mon Sep 17 00:00:00 2001 From: Alan Jowett Date: Wed, 13 Nov 2024 13:16:10 -0800 Subject: [PATCH] Set stack as function of max call depth Signed-off-by: Alan Jowett --- vm/inc/ubpf.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/vm/inc/ubpf.h b/vm/inc/ubpf.h index ff3379ab8..7e75c72eb 100644 --- a/vm/inc/ubpf.h +++ b/vm/inc/ubpf.h @@ -39,11 +39,18 @@ extern "C" #define UBPF_MAX_INSTS 65536 #endif +/** + * @brief Default maximum number of nested calls in the VM. + */ +#if !defined(UBPF_MAX_CALL_DEPTH) +#define UBPF_MAX_CALL_DEPTH 8 +#endif + /** * @brief Default stack size for the eBPF program. Must be divisible by 16. */ #if !defined(UBPF_EBPF_STACK_SIZE) -#define UBPF_EBPF_STACK_SIZE (8 * 1024) +#define UBPF_EBPF_STACK_SIZE (UBPF_MAX_CALL_DEPTH * 512) #endif /** @@ -60,12 +67,6 @@ extern "C" #define UBPF_EBPF_NONVOLATILE_SIZE (sizeof(uint64_t) * 5) -/** - * @brief Default maximum number of nested calls in the VM. - */ -#if !defined(UBPF_MAX_CALL_DEPTH) -#define UBPF_MAX_CALL_DEPTH 10 -#endif /** * @brief Opaque type for a the uBPF VM.