tc test 6
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 10s

This commit is contained in:
2026-03-07 16:50:42 +01:00
parent 29986d5073
commit cef433f9d7

View File

@@ -112,37 +112,18 @@ struct event_t {
BPF_PERF_OUTPUT(ingress_events); BPF_PERF_OUTPUT(ingress_events);
BPF_PERF_OUTPUT(meta_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) { static __always_inline __u32 ensure_packet_mark(struct __sk_buff *skb) {
__u32 key = 0;
__u32 next = skb->mark; __u32 next = skb->mark;
struct counter_state *state;
if (next) { if (next) {
return next; return next;
} }
state = bpf_map_lookup_elem(&packet_counter, &key); next = (__u32)(bpf_ktime_get_ns() & 0x0FFFFFFF);
if (!state) { if (!next) {
return 0; next = 1;
} }
bpf_spin_lock(&state->lock);
state->value += 1;
next = state->value;
bpf_spin_unlock(&state->lock);
skb->mark = next; skb->mark = next;
return next; return next;
} }