From 06872673c10fdf0eec7da1b2fe335e750d768f1e Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 22 Nov 2021 10:24:39 +0100 Subject: [PATCH] map: allow referring to a class index directly in tcp/udp default entries Signed-off-by: Felix Fietkau --- map.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/map.c b/map.c index f3b7e30..078dc45 100644 --- a/map.c +++ b/map.c @@ -158,29 +158,22 @@ static void __qosify_map_set_dscp_default(enum qosify_map_id id, uint8_t val) int fd; int i; - if (id == CL_MAP_TCP_PORTS) - key = QOSIFY_MAX_CLASS_ENTRIES; - else if (id == CL_MAP_UDP_PORTS) - key = QOSIFY_MAX_CLASS_ENTRIES + 1; - else - return; + if (!(val & QOSIFY_DSCP_CLASS_FLAG)) { + if (id == CL_MAP_TCP_PORTS) + key = QOSIFY_MAX_CLASS_ENTRIES; + else if (id == CL_MAP_UDP_PORTS) + key = QOSIFY_MAX_CLASS_ENTRIES + 1; + else + return; - fd = qosify_map_fds[CL_MAP_CLASS]; - if (val & QOSIFY_DSCP_CLASS_FLAG) { - uint8_t fallback = val & QOSIFY_DSCP_FALLBACK_FLAG; + fd = qosify_map_fds[CL_MAP_CLASS]; - val &= QOSIFY_DSCP_VALUE_MASK; - if (val > ARRAY_SIZE(map_class) || !map_class[val]) - return; + memcpy(&class.config, &flow_config, sizeof(class.config)); + bpf_map_update_elem(fd, &key, &class, BPF_ANY); - class.val.ingress = map_class[val]->data.val.ingress | fallback; - class.val.egress = map_class[val]->data.val.egress | fallback; + val = key | QOSIFY_DSCP_CLASS_FLAG; } - memcpy(&class.config, &flow_config, sizeof(class.config)); - bpf_map_update_elem(fd, &key, &class, BPF_ANY); - - val = key | QOSIFY_DSCP_CLASS_FLAG; fd = qosify_map_fds[id]; for (i = 0; i < (1 << 16); i++) { data.addr.port = htons(i); -- 2.30.2