bpf: fix priority flow detection
authorFelix Fietkau <nbd@nbd.name>
Fri, 19 Nov 2021 16:10:54 +0000 (17:10 +0100)
committerFelix Fietkau <nbd@nbd.name>
Fri, 19 Nov 2021 16:14:55 +0000 (17:14 +0100)
Take number of GSO segments into account

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

index d59415f3911dca2a74db6a668ea3e83fbd77ad0d..d0772e5ba9eddc4c972200e0386603fe2f2a60c0 100644 (file)
@@ -327,11 +327,18 @@ static __always_inline void
 check_flow_prio(struct qosify_flow_config *config, struct __sk_buff *skb,
                struct flow_bucket *flow, __u8 *out_val)
 {
+       int cur_len = skb->len;
+
        if (flow->bulk_timeout)
                return;
 
-       if (config->prio_max_avg_pkt_len &&
-           ewma(&flow->pkt_len_avg, skb->len) <= config->prio_max_avg_pkt_len)
+       if (!config->prio_max_avg_pkt_len)
+               return;
+
+       if (skb->gso_size && skb->gso_segs > 1)
+               cur_len /= skb->gso_segs;
+
+       if (ewma(&flow->pkt_len_avg, cur_len) <= config->prio_max_avg_pkt_len)
                *out_val = config->dscp_prio;
 }