From 58bf68ffaa3023879de479dde996acd447bc9c11 Mon Sep 17 00:00:00 2001 From: Eric Long Date: Wed, 15 Jan 2025 14:50:41 +0800 Subject: [PATCH] libxdp: add run config --- bpf/ingress.c | 8 ++++++++ src/main.h | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/bpf/ingress.c b/bpf/ingress.c index 4d96266..ad6e3a7 100644 --- a/bpf/ingress.c +++ b/bpf/ingress.c @@ -8,6 +8,14 @@ #include "common/try.h" #include "main.h" +#ifdef MIMIC_USE_LIBXDP +#include +struct { + __uint(priority, 5); + __uint(XDP_PASS, 1); +} XDP_RUN_CONFIG(my_xdp_func); +#endif + // Move back n bytes, shrink socket buffer and restore data. // // XXX: Not handling TCP options appended by middleboxes diff --git a/src/main.h b/src/main.h index a3bcad3..4497745 100644 --- a/src/main.h +++ b/src/main.h @@ -26,7 +26,9 @@ struct args { struct filter_settings gsettings; unsigned int filter_count; int xdp_mode; +#ifdef MIMIC_USE_LIBXDP bool use_libxdp; +#endif } run; struct show_args { const char* ifname; @@ -41,7 +43,8 @@ extern const struct argp show_argp; int subcmd_run(struct run_args* args); -int show_overview(int ifindex, int whitelist_fd, struct filter_settings* gsettings, int log_verbosity); +int show_overview(int ifindex, int whitelist_fd, struct filter_settings* gsettings, + int log_verbosity); int subcmd_show(struct show_args* args); struct lock_content {