bpf: work around a verifier issue
authorFelix Fietkau <nbd@nbd.name>
Sun, 21 Nov 2021 12:43:41 +0000 (13:43 +0100)
committerFelix Fietkau <nbd@nbd.name>
Sun, 21 Nov 2021 12:43:45 +0000 (13:43 +0100)
Force access to both src/dest fields, otherwise the llvm optimizer can turn
this into pointer arithmetic that older kernels will reject

Signed-off-by: Felix Fietkau <nbd@nbd.name>
qosify-bpf.c

index eb13e9bd42c956eac7765c5c27b1e95a28183c99..a0635ecd59e7a9bb94338ca9cb2f403cbc1d32e7 100644 (file)
@@ -258,10 +258,12 @@ parse_l4proto(struct qosify_config *config, struct __sk_buff *skb,
                return;
        }
 
+       src = READ_ONCE(udp->source);
+       dest = READ_ONCE(udp->dest);
        if (ingress)
-               key = udp->source;
+               key = src;
        else
-               key = udp->dest;
+               key = dest;
 
        if (proto == IPPROTO_TCP) {
                value = bpf_map_lookup_elem(&tcp_ports, &key);