From e08ccdeb4ff6cac31c0e06d208be5bb489ca179a Mon Sep 17 00:00:00 2001
From: Eric Long <i@hack3r.moe>
Date: Sat, 8 Mar 2025 16:28:02 +0800
Forwarded: not-needed
Subject: [PATCH] cli/run: allow unaligned memory access in BPF

The verifier will panic when checking Mimic in kernels without
CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y. This is mostly due to reading of TCP
options, which in most cases should align and not causing major performance
problems.
---
 src/run.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/run.c b/src/run.c
index 57cd5a7..7835a1c 100644
--- a/src/run.c
+++ b/src/run.c
@@ -557,6 +557,9 @@ static inline int run_bpf(struct run_args* args, int lock_fd, const char* ifname
   skel->bss->log_verbosity = log_verbosity;
   skel->bss->link_type = args->link_type;
 
+  bpf_program__set_flags(skel->progs.ingress_handler, BPF_F_ANY_ALIGNMENT);
+  bpf_program__set_flags(skel->progs.egress_handler, BPF_F_ANY_ALIGNMENT);
+
   // XDP
 #ifdef MIMIC_USE_LIBXDP
   if (args->use_libxdp) {
-- 
2.48.1

