From cef433f9d73f315915f0529ed7b203d33128ab87 Mon Sep 17 00:00:00 2001 From: malmert Date: Sat, 7 Mar 2026 16:50:42 +0100 Subject: [PATCH] tc test 6 --- backend/src/utilities/ebpf_bridge_events.py | 25 +++------------------ 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/backend/src/utilities/ebpf_bridge_events.py b/backend/src/utilities/ebpf_bridge_events.py index 5eed1d5..15b6942 100644 --- a/backend/src/utilities/ebpf_bridge_events.py +++ b/backend/src/utilities/ebpf_bridge_events.py @@ -112,37 +112,18 @@ struct event_t { BPF_PERF_OUTPUT(ingress_events); BPF_PERF_OUTPUT(meta_events); -struct counter_state { - struct bpf_spin_lock lock; - __u32 value; -}; - -struct { - __uint(type, BPF_MAP_TYPE_ARRAY); - __uint(max_entries, 1); - __type(key, __u32); - __type(value, struct counter_state); -} packet_counter SEC(".maps"); - static __always_inline __u32 ensure_packet_mark(struct __sk_buff *skb) { - __u32 key = 0; __u32 next = skb->mark; - struct counter_state *state; if (next) { return next; } - state = bpf_map_lookup_elem(&packet_counter, &key); - if (!state) { - return 0; + next = (__u32)(bpf_ktime_get_ns() & 0x0FFFFFFF); + if (!next) { + next = 1; } - bpf_spin_lock(&state->lock); - state->value += 1; - next = state->value; - bpf_spin_unlock(&state->lock); - skb->mark = next; return next; }