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; }