project/qosify.git
18 months agobpf: switch to using bpf_skb_utils.h testing
Felix Fietkau [Wed, 21 Sep 2022 17:10:16 +0000 (19:10 +0200)]
bpf: switch to using bpf_skb_utils.h

This makes the code more reliable, especially on older kernels

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoubus: add active devices to bridger blacklist
Felix Fietkau [Fri, 8 Apr 2022 11:02:42 +0000 (13:02 +0200)]
ubus: add active devices to bridger blacklist

Ensures that bridge offload won't interfere with QoS

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agointerface: fix ifname present check in interface status
Felix Fietkau [Fri, 8 Apr 2022 10:54:49 +0000 (12:54 +0200)]
interface: fix ifname present check in interface status

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoloader/interface: attach bpf program directly using netlink
Felix Fietkau [Tue, 5 Apr 2022 19:25:29 +0000 (21:25 +0200)]
loader/interface: attach bpf program directly using netlink

This makes it possible to replace the tc-full/tc-bpf dependency with a
simple tc dependency.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoqosify: fix dscp values of ubus-added dns host entries
Felix Fietkau [Tue, 22 Mar 2022 09:27:33 +0000 (10:27 +0100)]
qosify: fix dscp values of ubus-added dns host entries

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoloader: fix use of deprecated functions
Felix Fietkau [Mon, 21 Mar 2022 19:14:16 +0000 (20:14 +0100)]
loader: fix use of deprecated functions

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agointerface: replace open-coded ifb-dns string with QOSIFY_DNS_IFNAME
Felix Fietkau [Fri, 18 Mar 2022 11:38:36 +0000 (12:38 +0100)]
interface: replace open-coded ifb-dns string with QOSIFY_DNS_IFNAME

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agointerface: rework adding/removing filters, do not delete clsact
Felix Fietkau [Fri, 18 Mar 2022 11:24:42 +0000 (12:24 +0100)]
interface: rework adding/removing filters, do not delete clsact

This allows qosify to coexist with other services that need to add filters on
clsact

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoRevert "ubus: remove dnsmasq subscriber"
Felix Fietkau [Thu, 17 Mar 2022 18:20:12 +0000 (19:20 +0100)]
Revert "ubus: remove dnsmasq subscriber"

This reverts commit a78bd43c4a542c18842ef981641d4e8948cbdc28.
Under some conditions it might still be useful to have this as a backup

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agointerface: fix duplicated dns filter line
Felix Fietkau [Wed, 9 Mar 2022 08:42:38 +0000 (09:42 +0100)]
interface: fix duplicated dns filter line

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agointerface: run ingress bpf filter on main device ingress instead of ifb egress
Felix Fietkau [Tue, 8 Mar 2022 21:53:34 +0000 (22:53 +0100)]
interface: run ingress bpf filter on main device ingress instead of ifb egress

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agointerface: switch to using clsact for filters
Felix Fietkau [Tue, 8 Mar 2022 13:27:49 +0000 (14:27 +0100)]
interface: switch to using clsact for filters

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agobpf: return TC_ACT_UNSPEC to allow other filters to proceed
Felix Fietkau [Thu, 17 Mar 2022 08:00:48 +0000 (09:00 +0100)]
bpf: return TC_ACT_UNSPEC to allow other filters to proceed

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agointerface: extend dns filters to cover vlan tagged traffic as well
Felix Fietkau [Mon, 7 Mar 2022 13:43:07 +0000 (14:43 +0100)]
interface: extend dns filters to cover vlan tagged traffic as well

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agodns: fix parsing vlan encapsulated protocol
Felix Fietkau [Mon, 7 Mar 2022 12:59:26 +0000 (13:59 +0100)]
dns: fix parsing vlan encapsulated protocol

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agodns: allow limiting dns entry matching to cname name
Felix Fietkau [Sun, 6 Mar 2022 21:49:59 +0000 (22:49 +0100)]
dns: allow limiting dns entry matching to cname name

Allows more precise control on how to match CNAME redirected subdomains

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomap: process dns patterns in the order in which they were defined
Felix Fietkau [Sun, 6 Mar 2022 21:32:59 +0000 (22:32 +0100)]
map: process dns patterns in the order in which they were defined

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoubus: remove dnsmasq subscriber
Felix Fietkau [Fri, 4 Mar 2022 14:03:20 +0000 (15:03 +0100)]
ubus: remove dnsmasq subscriber

with dns snooping, this is no longer needed

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agodns: add code for snooping dns packets
Felix Fietkau [Fri, 4 Mar 2022 14:01:53 +0000 (15:01 +0100)]
dns: add code for snooping dns packets

This makes dns entries work in bridged mode or when not using dnsmasq

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomap: move dns host based lookup code to a separate function
Felix Fietkau [Fri, 4 Mar 2022 13:15:44 +0000 (14:15 +0100)]
map: move dns host based lookup code to a separate function

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomove run_cmd() to main.c
Felix Fietkau [Thu, 3 Mar 2022 19:36:02 +0000 (20:36 +0100)]
move run_cmd() to main.c

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agointerface: disable autorate-ingress by default
Stijn Tintel [Fri, 4 Mar 2022 15:43:51 +0000 (17:43 +0200)]
interface: disable autorate-ingress by default

Enabling autorate-ingress on a mostly idle host seems to result in the
ingress rate being lowered until traffic is barely possible at all.
Disable autorate-ingress by default to avoid people running into this
problem without explicitly enabling it.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
Acked-by: Felix Fietkau <nbd@nbd.name>
2 years agointerface: add missing autorate-ingress options
Felix Fietkau [Sun, 20 Feb 2022 12:58:18 +0000 (13:58 +0100)]
interface: add missing autorate-ingress options

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoubus: fix a use-after-free bug
Felix Fietkau [Thu, 10 Feb 2022 19:55:02 +0000 (20:55 +0100)]
ubus: fix a use-after-free bug

Initialize blob_buf before issuing a network interface status call

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agobpf: declare tcp_ports/udp_ports without typedef
Felix Fietkau [Wed, 26 Jan 2022 14:02:17 +0000 (15:02 +0100)]
bpf: declare tcp_ports/udp_ports without typedef

Improve compatibility with different versions of LLVM

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomap: fix copy-paste error in codepoints map
Stijn Tintel [Thu, 27 Jan 2022 13:04:38 +0000 (15:04 +0200)]
map: fix copy-paste error in codepoints map

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
Acked-by: Felix Fietkau <nbd@nbd.name>
2 years agomap: allow referring to a class index directly in tcp/udp default entries
Felix Fietkau [Mon, 22 Nov 2021 09:24:39 +0000 (10:24 +0100)]
map: allow referring to a class index directly in tcp/udp default entries

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agobpf: work around a verifier issue
Felix Fietkau [Sun, 21 Nov 2021 12:43:41 +0000 (13:43 +0100)]
bpf: work around a verifier issue

Force access to both src/dest fields, otherwise the llvm optimizer can turn
this into pointer arithmetic that older kernels will reject

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agointerface: unify status, always include ifname, ingress, egress
Felix Fietkau [Fri, 19 Nov 2021 22:40:41 +0000 (23:40 +0100)]
interface: unify status, always include ifname, ingress, egress

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agobpf: remove access to skb->gso_size
Felix Fietkau [Fri, 19 Nov 2021 22:39:19 +0000 (23:39 +0100)]
bpf: remove access to skb->gso_size

Fixes load on older kernels

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agobpf: fix priority flow detection
Felix Fietkau [Fri, 19 Nov 2021 16:10:54 +0000 (17:10 +0100)]
bpf: fix priority flow detection

Take number of GSO segments into account

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agobpf: fix bulk flow detaction
Felix Fietkau [Thu, 18 Nov 2021 22:28:35 +0000 (23:28 +0100)]
bpf: fix bulk flow detaction

Take number of GSO segments into account

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomap, bpf: create a separate map for configured dscp classes
Felix Fietkau [Thu, 18 Nov 2021 16:14:42 +0000 (17:14 +0100)]
map, bpf: create a separate map for configured dscp classes

Include separate configuration for dynamic priority/bulk flow detection

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agobpf: move flow prio/bulk detection config into a separate data structure
Felix Fietkau [Tue, 16 Nov 2021 16:23:22 +0000 (17:23 +0100)]
bpf: move flow prio/bulk detection config into a separate data structure

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agobpf: refactor code to support explicit opt-in for bulk+prio detection
Felix Fietkau [Tue, 16 Nov 2021 07:51:14 +0000 (08:51 +0100)]
bpf: refactor code to support explicit opt-in for bulk+prio detection

Significantly reduces compiled BPF code size by reducing inlining duplication

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoubus: drop dnsmasq check for dns_result method
Felix Fietkau [Mon, 15 Nov 2021 20:10:12 +0000 (21:10 +0100)]
ubus: drop dnsmasq check for dns_result method

Preparation for switching dnsmasq to reporting cache entries

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomap: add support for defining aliases
Felix Fietkau [Fri, 12 Nov 2021 21:54:51 +0000 (22:54 +0100)]
map: add support for defining aliases

Aliases can be used to make a distinction between ingress and egress tags,
and they make it easier to reconfigure tags without having to update the rule
config files

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agobpf: add initial support for splitting map dscp value into ingress and egress
Felix Fietkau [Fri, 12 Nov 2021 14:51:35 +0000 (15:51 +0100)]
bpf: add initial support for splitting map dscp value into ingress and egress

This will be used for supporting different tags on the LAN side and the WAN side.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoREADME: dnsmasq integration is complete
Felix Fietkau [Tue, 9 Nov 2021 21:08:51 +0000 (22:08 +0100)]
README: dnsmasq integration is complete

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoqosify: support wildcards in classifier filenames
Felix Fietkau [Mon, 8 Nov 2021 21:21:34 +0000 (22:21 +0100)]
qosify: support wildcards in classifier filenames

This makes it easier to support having a directory with extra installable files
without having to update the configuration

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoubus: fix crash caused by missing static keyword
Felix Fietkau [Mon, 8 Nov 2021 21:12:05 +0000 (22:12 +0100)]
ubus: fix crash caused by missing static keyword

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomap: default to fnmatch matching for dns patterns. support regex via leading /
Felix Fietkau [Mon, 8 Nov 2021 20:59:22 +0000 (21:59 +0100)]
map: default to fnmatch matching for dns patterns. support regex via leading /

Simplifies writing DNS matching rules

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoubus: subscribe to dnsmasq.dns for dns lookup results
Felix Fietkau [Mon, 8 Nov 2021 13:45:08 +0000 (14:45 +0100)]
ubus: subscribe to dnsmasq.dns for dns lookup results

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoqosify-bpf: inline check_flow() to ensure that it is jited
Felix Fietkau [Thu, 4 Nov 2021 19:35:07 +0000 (20:35 +0100)]
qosify-bpf: inline check_flow() to ensure that it is jited

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomap: increase active timeout to 300
Felix Fietkau [Thu, 4 Nov 2021 14:04:30 +0000 (15:04 +0100)]
map: increase active timeout to 300

Matches a typical maximum HTTP keepalive timeout

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomap: add DF codepoint
Felix Fietkau [Thu, 4 Nov 2021 13:58:02 +0000 (14:58 +0100)]
map: add DF codepoint

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomap: improve timeout handling of IP entries
Felix Fietkau [Thu, 4 Nov 2021 13:55:12 +0000 (14:55 +0100)]
map: improve timeout handling of IP entries

Instead of expiring them at TTL, introduce an active timeout (default 60)
Whenever an IP entry expires, timeout gets reset to the active timeout
value. If during that time, a packet was seen matching the IP entry, the
timeout is automatically extended.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoloader: always reinitialize programs
Felix Fietkau [Thu, 4 Nov 2021 13:01:55 +0000 (14:01 +0100)]
loader: always reinitialize programs

Improves reliability of upgrading the package

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoREADME: fix another typo
Felix Fietkau [Wed, 3 Nov 2021 18:29:29 +0000 (19:29 +0100)]
README: fix another typo

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoREADME: fix typo
Felix Fietkau [Wed, 3 Nov 2021 18:28:50 +0000 (19:28 +0100)]
README: fix typo

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agointerface: enable NAT on interfaces by default
Felix Fietkau [Wed, 3 Nov 2021 18:25:32 +0000 (19:25 +0100)]
interface: enable NAT on interfaces by default

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomap: introduce low effort codepoint from RFC8622
Felix Fietkau [Wed, 3 Nov 2021 16:58:42 +0000 (17:58 +0100)]
map: introduce low effort codepoint from RFC8622

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoREADME: document mapping file syntax
Felix Fietkau [Wed, 3 Nov 2021 14:36:37 +0000 (15:36 +0100)]
README: document mapping file syntax

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoREADME: mention dns regex entries
Felix Fietkau [Wed, 3 Nov 2021 14:30:52 +0000 (15:30 +0100)]
README: mention dns regex entries

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

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoubus: add api for providing dns lookup results for dns regex rules
Felix Fietkau [Wed, 3 Nov 2021 14:24:58 +0000 (15:24 +0100)]
ubus: add api for providing dns lookup results for dns regex rules

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoubus: remove unused enum
Felix Fietkau [Wed, 3 Nov 2021 11:29:05 +0000 (12:29 +0100)]
ubus: remove unused enum

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomap: add support for adding dns regex patterns
Felix Fietkau [Wed, 3 Nov 2021 11:27:11 +0000 (12:27 +0100)]
map: add support for adding dns regex patterns

This will be used for hostname based dscp mark rules

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomap: make a helper function for freeing entries
Felix Fietkau [Wed, 3 Nov 2021 10:13:53 +0000 (11:13 +0100)]
map: make a helper function for freeing entries

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoInitial import
Felix Fietkau [Tue, 12 Oct 2021 12:41:21 +0000 (14:41 +0200)]
Initial import

Signed-off-by: Felix Fietkau <nbd@nbd.name>