bpf: refactor code to support explicit opt-in for bulk+prio detection
[project/qosify.git] / ubus.c
diff --git a/ubus.c b/ubus.c
index d1c03032b8a2376dbf91b79325478bd3edf4133e..39a775ce54ebce57e6247f108423e0517350891d 100644 (file)
--- a/ubus.c
+++ b/ubus.c
@@ -138,6 +138,7 @@ enum {
        CL_CONFIG_PRIO_PKT_LEN,
        CL_CONFIG_INTERFACES,
        CL_CONFIG_DEVICES,
+       CL_CONFIG_ALIASES,
        __CL_CONFIG_MAX
 };
 
@@ -155,6 +156,7 @@ static const struct blobmsg_policy qosify_config_policy[__CL_CONFIG_MAX] = {
        [CL_CONFIG_PRIO_PKT_LEN] = { "prio_max_avg_pkt_len", BLOBMSG_TYPE_INT32 },
        [CL_CONFIG_INTERFACES] = { "interfaces", BLOBMSG_TYPE_TABLE },
        [CL_CONFIG_DEVICES] = { "devices", BLOBMSG_TYPE_TABLE },
+       [CL_CONFIG_ALIASES] = { "aliases", BLOBMSG_TYPE_TABLE },
 };
 
 static int __set_dscp(struct qosify_dscp_val *dest, struct blob_attr *attr, bool reset)
@@ -193,6 +195,9 @@ qosify_ubus_config(struct ubus_context *ctx, struct ubus_object *obj,
        if (reset)
                qosify_map_reset_config();
 
+       if ((cur = tb[CL_CONFIG_ALIASES]) != NULL || reset)
+               qosify_map_set_aliases(cur);
+
        if ((cur = tb[CL_CONFIG_TIMEOUT]) != NULL)
                qosify_map_timeout = blobmsg_get_u32(cur);
 
@@ -339,22 +344,11 @@ static struct ubus_object qosify_object = {
        .n_methods = ARRAY_SIZE(qosify_methods),
 };
 
-static int
-qosify_dnsmasq_cb(struct ubus_context *ctx, struct ubus_object *obj,
-                 struct ubus_request_data *req, const char *method,
-                 struct blob_attr *msg)
-{
-       if (!strcmp(method, "dns_result"))
-               __qosify_ubus_add_dns_host(msg);
-
-       return 0;
-}
-
 static void
 qosify_subscribe_dnsmasq(struct ubus_context *ctx)
 {
        static struct ubus_subscriber sub = {
-               .cb = qosify_dnsmasq_cb,
+               .cb = qosify_ubus_add_dns_host,
        };
        uint32_t id;