ubus: add support for dynamically adding dns based rules
authorFelix Fietkau <nbd@nbd.name>
Wed, 3 Nov 2021 14:26:40 +0000 (15:26 +0100)
committerFelix Fietkau <nbd@nbd.name>
Wed, 3 Nov 2021 14:26:40 +0000 (15:26 +0100)
Signed-off-by: Felix Fietkau <nbd@nbd.name>
ubus.c

diff --git a/ubus.c b/ubus.c
index 79ad9572a608fd76badaf90714cc3966305e30d1..1be17b4cbaaead31ee6575c5889879d8a18a8700 100644 (file)
--- a/ubus.c
+++ b/ubus.c
@@ -50,6 +50,7 @@ enum {
        CL_ADD_IPV6,
        CL_ADD_TCP_PORT,
        CL_ADD_UDP_PORT,
+       CL_ADD_DNS,
        __CL_ADD_MAX
 };
 
@@ -60,6 +61,7 @@ static const struct blobmsg_policy qosify_add_policy[__CL_ADD_MAX] = {
        [CL_ADD_IPV6] = { "ipv6", BLOBMSG_TYPE_ARRAY },
        [CL_ADD_TCP_PORT] = { "tcp_port", BLOBMSG_TYPE_ARRAY },
        [CL_ADD_UDP_PORT] = { "udp_port", BLOBMSG_TYPE_ARRAY },
+       [CL_ADD_DNS] = { "dns", BLOBMSG_TYPE_ARRAY },
 };
 
 
@@ -117,6 +119,10 @@ qosify_ubus_add(struct ubus_context *ctx, struct ubus_object *obj,
            (ret = qosify_ubus_add_array(cur, dscp, CL_MAP_UDP_PORTS) != 0))
                return ret;
 
+       if ((cur = tb[CL_ADD_DNS]) != NULL &&
+           (ret = qosify_ubus_add_array(cur, dscp, CL_MAP_DNS) != 0))
+               return ret;
+
        qosify_map_timeout = prev_timemout;
 
        return 0;