summaryrefslogtreecommitdiff
path: root/bpf
diff options
context:
space:
mode:
authorluwenpeng <[email protected]>2024-11-13 15:08:03 +0800
committerluwenpeng <[email protected]>2024-11-15 18:40:04 +0800
commit2e69e0edd8d2574952fd5fe779f9604cb7ed6ead (patch)
tree94b91e279ee807a6950ef98d6b527b2c850d3d59 /bpf
parent595167dcf811fdb0c61f9d80df7fa0cd5cbe25e8 (diff)
TSG-23335 TFE适配AArch64架构v4.11.1-20241115
Diffstat (limited to 'bpf')
-rw-r--r--bpf/bpf_obj.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/bpf/bpf_obj.cpp b/bpf/bpf_obj.cpp
index dde48cd..3aeff20 100644
--- a/bpf/bpf_obj.cpp
+++ b/bpf/bpf_obj.cpp
@@ -55,11 +55,42 @@ struct bpf_obj_ctx *bpf_obj_load(const char *obj_file, uint32_t queue_num, uint3
bpf_config_set_hash_mode(&ctx->config, hash_mode);
bpf_config_set_debug_log(&ctx->config, debug_log);
+#if (LIBBPF_MAJOR_VERSION > 0 || (LIBBPF_MAJOR_VERSION == 0 && LIBBPF_MINOR_VERSION >= 7))
+ struct bpf_program *prog;
+ ctx->prog_obj = bpf_object__open_file(ctx->obj_file, NULL);
+ if (ctx->prog_obj == NULL)
+ {
+ printf("ERROR: Unable to open bpf object %s, %s.\n", ctx->obj_file, strerror(errno));
+ goto error;
+ }
+
+ prog = bpf_object__find_program_by_name(ctx->prog_obj, "bpf_tun_rss_steering");
+ if (!prog)
+ {
+ printf("ERROR: Unable to get bpf program from object %s, %s.\n", ctx->obj_file, strerror(errno));
+ goto error;
+ }
+
+ bpf_program__set_type(prog, BPF_PROG_TYPE_SOCKET_FILTER);
+ if (bpf_object__load(ctx->prog_obj))
+ {
+ printf("ERROR: Unable to load bpf object %s, %s.\n", ctx->obj_file, strerror(errno));
+ goto error;
+ }
+
+ ctx->prog_fd = bpf_program__fd(prog);
+ if (ctx->prog_fd < 0)
+ {
+ printf("ERROR: Unable to get bpf program fd from object %s, %s.\n", ctx->obj_file, strerror(errno));
+ goto error;
+ }
+#else
if (bpf_prog_load(ctx->obj_file, BPF_PROG_TYPE_SOCKET_FILTER, &ctx->prog_obj, &ctx->prog_fd) < 0)
{
printf("ERROR: Unable to load bpf object %s, %s.\n", ctx->obj_file, strerror(errno));
goto error;
}
+#endif
if (bpf_config_update_map(&ctx->config, ctx->prog_obj) == -1)
{