From 02a0c79f6afc32e35aee21b6a99e0c1a24939cc3 Mon Sep 17 00:00:00 2001 From: lec-bit Date: Sat, 26 Apr 2025 10:58:20 +0800 Subject: [PATCH] fix bpf helper num Signed-off-by: lec-bit --- bpf/include/bpf_helper_defs_ext.h | 13 +++++++++---- kmesh_bpf_env.sh | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/bpf/include/bpf_helper_defs_ext.h b/bpf/include/bpf_helper_defs_ext.h index a7c908d52..7b071400c 100644 --- a/bpf/include/bpf_helper_defs_ext.h +++ b/bpf/include/bpf_helper_defs_ext.h @@ -10,6 +10,10 @@ * By default, these IDs are in the 5.10 kernel with kmesh kernel patches. */ +#define bpf_km_header_strnstr_num 175 +#define bpf_km_header_strncmp_num 176 +#define bpf_parse_header_msg_num 177 + /* * Description * Look for the string corresponding to the key in the results of the @@ -19,7 +23,8 @@ * If found, return 1; otherwise, return 0. */ static long (*bpf_km_header_strnstr)( - struct bpf_sock_addr *ctx, const char *key, int key_sz, const char *subptr, int subptr_sz) = (void *)175; + struct bpf_sock_addr *ctx, const char *key, int key_sz, const char *subptr, int subptr_sz) = (void *) + bpf_km_header_strnstr_num; /* * Description @@ -30,8 +35,8 @@ static long (*bpf_km_header_strnstr)( * Return * If the strings are same, return 0. */ -static long (*bpf_km_header_strncmp)(const char *key, int key_sz, const char *target, int target_sz, int opt) = - (void *)176; +static long (*bpf_km_header_strncmp)(const char *key, int key_sz, const char *target, int target_sz, int opt) = (void *) + bpf_km_header_strncmp_num; /* * Description @@ -43,4 +48,4 @@ static long (*bpf_km_header_strncmp)(const char *key, int key_sz, const char *ta * A HTTP PROTO TYPE is returned on success. * **PROTO_UNKNOW** is returned if failure. */ -static long (*bpf_parse_header_msg)(struct bpf_sock_addr *ctx) = (void *)177; +static long (*bpf_parse_header_msg)(struct bpf_sock_addr *ctx) = (void *)bpf_parse_header_msg_num; diff --git a/kmesh_bpf_env.sh b/kmesh_bpf_env.sh index 7cfa4f807..248b4fcf4 100644 --- a/kmesh_bpf_env.sh +++ b/kmesh_bpf_env.sh @@ -17,6 +17,6 @@ for name in ${helper_name[@]}; do current_line=`grep -nr "FN($name)" $KERNEL_HEADER_LINUX_BPF | awk -F ":" {'print $1'}` if [ -n "$current_line" ]; then helper_id=`expr $current_line - $base_line` - sed -Ei "/$name/s/([0-9]+)[^0-9]*$/$helper_id;/" $ROOT_DIR/bpf/include/bpf_helper_defs_ext.h + sed -Ei "/${name}_num/s/([0-9]+)[^0-9]*$/$helper_id/" $ROOT_DIR/bpf/include/bpf_helper_defs_ext.h fi done