- dns:/<regex>
POSIX.2 extended regular expression for matching hostnames
Only works, if dns lookups are passed to qosify via the add_dns_host ubus call.
+- dns_c:...
+ Like dns:... but only matches cname entries
dscp can be a raw value, or a codepoint like CS0
Adding a + in front of the value tells qosify to only override the DSCP value if it is zero
+DNS entries are compared in the order in which they are specified in the config, using the
+first matching entry.
Planned features:
return -1;
cname_cache_get(qname, dscp, seq);
- qosify_map_lookup_dns_entry(qname, dscp, seq);
+ qosify_map_lookup_dns_entry(qname, false, dscp, seq);
return 0;
}
cname, sizeof(cname)) < 0)
return -1;
- qosify_map_lookup_dns_entry(cname, dscp, seq);
+ qosify_map_lookup_dns_entry(cname, true, dscp, seq);
cname_cache_set(cname, *dscp, *seq);
return 0;
switch (id) {
case CL_MAP_DNS:
data.addr.dns.pattern = str;
+ if (str[-2] == 'c')
+ data.addr.dns.only_cname = 1;
break;
case CL_MAP_TCP_PORTS:
case CL_MAP_UDP_PORTS:
if (!strncmp(key, "dns:", 4))
qosify_map_set_entry(CL_MAP_DNS, true, key + 4, dscp);
+ if (!strncmp(key, "dns_q:", 6) || !strncmp(key, "dns_c:", 6))
+ qosify_map_set_entry(CL_MAP_DNS, true, key + 6, dscp);
if (!strncmp(key, "tcp:", 4))
qosify_map_set_entry(CL_MAP_TCP_PORTS, true, key + 4, dscp);
else if (!strncmp(key, "udp:", 4))
uloop_timeout_set(&qosify_map_timer, timeout * 1000);
}
-int qosify_map_lookup_dns_entry(char *host, uint8_t *dscp, uint32_t *seq)
+int qosify_map_lookup_dns_entry(char *host, bool cname, uint8_t *dscp, uint32_t *seq)
{
struct qosify_map_data data = {
.id = CL_MAP_DNS,
if (e->data.id != CL_MAP_DNS)
break;
+ if (!cname && e->data.addr.dns.only_cname)
+ continue;
+
if (e->data.addr.dns.pattern[0] == '/') {
if (regexec(regex, host, 0, NULL, 0) != 0)
continue;
int prev_timeout = qosify_map_timeout;
uint32_t lookup_seq = 0;
- if (qosify_map_lookup_dns_entry(host, &data.dscp, &lookup_seq))
+ if (qosify_map_lookup_dns_entry(host, false, &data.dscp, &lookup_seq))
return 0;
data.user = true;
struct in_addr ip;
struct in6_addr ip6;
struct {
- uint32_t seq;
+ uint32_t seq : 30;
+ uint32_t only_cname : 1;
const char *pattern;
regex_t regex;
} dns;
void qosify_map_reset_config(void);
void qosify_map_update_config(void);
void qosify_map_set_classes(struct blob_attr *val);
-int qosify_map_lookup_dns_entry(char *host, uint8_t *dscp, uint32_t *seq);
+int qosify_map_lookup_dns_entry(char *host, bool cname, uint8_t *dscp, uint32_t *seq);
int qosify_map_add_dns_host(char *host, const char *addr, const char *type, int ttl);
int map_parse_flow_config(struct qosify_flow_config *cfg, struct blob_attr *attr,
bool reset);