map: allow referring to a class index directly in tcp/udp default entries
authorFelix Fietkau <nbd@nbd.name>
Mon, 22 Nov 2021 09:24:39 +0000 (10:24 +0100)
committerFelix Fietkau <nbd@nbd.name>
Mon, 22 Nov 2021 09:24:42 +0000 (10:24 +0100)
Signed-off-by: Felix Fietkau <nbd@nbd.name>
map.c

diff --git a/map.c b/map.c
index f3b7e30b7c9927d43895b7c0e3d7b0b8b463d21b..078dc457a3970d07d65e0d1197d7adbe0c50885b 100644 (file)
--- 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);