Initial commit
Some checks failed
Build Kernel / Build all affected Kernels (push) Has been cancelled
Build all core packages / Build all core packages for selected target (push) Has been cancelled
Build and Push prebuilt tools container / Build and Push all prebuilt containers (push) Has been cancelled
Build Toolchains / Build Toolchains for each target (push) Has been cancelled
Build host tools / Build host tools for linux and macos based systems (push) Has been cancelled
Coverity scan build / Coverity x86/64 build (push) Has been cancelled
Some checks failed
Build Kernel / Build all affected Kernels (push) Has been cancelled
Build all core packages / Build all core packages for selected target (push) Has been cancelled
Build and Push prebuilt tools container / Build and Push all prebuilt containers (push) Has been cancelled
Build Toolchains / Build Toolchains for each target (push) Has been cancelled
Build host tools / Build host tools for linux and macos based systems (push) Has been cancelled
Coverity scan build / Coverity x86/64 build (push) Has been cancelled
This commit is contained in:
76
package/network/config/qosify/Makefile
Normal file
76
package/network/config/qosify/Makefile
Normal file
@@ -0,0 +1,76 @@
|
||||
#
|
||||
# Copyright (C) 2021 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=qosify
|
||||
PKG_SOURCE_URL=$(PROJECT_GIT)/project/qosify.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_DATE:=2023-03-07
|
||||
PKG_SOURCE_VERSION:=9a47ea4b683dd845ec94534fcd82d3117c9ab313
|
||||
PKG_MIRROR_HASH:=3d97456dcd13f481beff9a87d939e4bd671577865ed7cfc11b00d6e40f3e5621
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
|
||||
|
||||
PKG_BUILD_DEPENDS:=bpf-headers
|
||||
PKG_FLAGS:=nonshared
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/cmake.mk
|
||||
include $(INCLUDE_DIR)/bpf.mk
|
||||
include $(INCLUDE_DIR)/nls.mk
|
||||
|
||||
define Package/qosify
|
||||
SECTION:=utils
|
||||
CATEGORY:=Base system
|
||||
TITLE:=A simple QoS solution based eBPF + CAKE
|
||||
DEPENDS:=+libbpf +libubox +libubus +libnl-tiny +kmod-sched-cake +kmod-sched-bpf +kmod-ifb +tc $(BPF_DEPENDS)
|
||||
endef
|
||||
|
||||
TARGET_CFLAGS += \
|
||||
-Wno-error=deprecated-declarations \
|
||||
-I$(STAGING_DIR)/usr/include/libnl-tiny \
|
||||
-I$(STAGING_DIR)/usr/include
|
||||
|
||||
CMAKE_OPTIONS += \
|
||||
-DLIBNL_LIBS=-lnl-tiny
|
||||
|
||||
define Build/Compile
|
||||
$(call CompileBPF,$(PKG_BUILD_DIR)/qosify-bpf.c)
|
||||
$(Build/Compile/Default)
|
||||
endef
|
||||
|
||||
define Package/qosify/conffiles
|
||||
/etc/config/qosify
|
||||
/etc/qosify/00-defaults.conf
|
||||
endef
|
||||
|
||||
define Package/qosify/install
|
||||
$(INSTALL_DIR) \
|
||||
$(1)/lib/bpf \
|
||||
$(1)/usr/sbin \
|
||||
$(1)/etc/init.d \
|
||||
$(1)/etc/config \
|
||||
$(1)/etc/qosify \
|
||||
$(1)/etc/hotplug.d/net \
|
||||
$(1)/etc/hotplug.d/iface
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/qosify-bpf.o $(1)/lib/bpf
|
||||
$(INSTALL_BIN) \
|
||||
$(PKG_INSTALL_DIR)/usr/bin/qosify \
|
||||
./files/qosify-status \
|
||||
$(1)/usr/sbin/
|
||||
$(INSTALL_BIN) ./files/qosify.init $(1)/etc/init.d/qosify
|
||||
$(INSTALL_DATA) ./files/qosify-defaults.conf $(1)/etc/qosify/00-defaults.conf
|
||||
$(INSTALL_DATA) ./files/qosify.conf $(1)/etc/config/qosify
|
||||
$(INSTALL_DATA) ./files/qosify.hotplug $(1)/etc/hotplug.d/net/10-qosify
|
||||
$(INSTALL_DATA) ./files/qosify.hotplug $(1)/etc/hotplug.d/iface/10-qosify
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,qosify))
|
||||
17
package/network/config/qosify/files/qosify-defaults.conf
Normal file
17
package/network/config/qosify/files/qosify-defaults.conf
Normal file
@@ -0,0 +1,17 @@
|
||||
# DNS
|
||||
tcp:53 voice
|
||||
tcp:5353 voice
|
||||
udp:53 voice
|
||||
udp:5353 voice
|
||||
|
||||
# NTP
|
||||
udp:123 voice
|
||||
|
||||
# SSH
|
||||
tcp:22 +video
|
||||
|
||||
# HTTP/QUIC
|
||||
tcp:80 +besteffort
|
||||
tcp:443 +besteffort
|
||||
udp:80 +besteffort
|
||||
udp:443 +besteffort
|
||||
70
package/network/config/qosify/files/qosify-status
Normal file
70
package/network/config/qosify/files/qosify-status
Normal file
@@ -0,0 +1,70 @@
|
||||
#!/bin/sh
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
dev_status() {
|
||||
tc -s qdisc sh dev "$1" root
|
||||
echo
|
||||
}
|
||||
|
||||
common_status() {
|
||||
json_get_vars ifname ingress egress
|
||||
|
||||
[ -n "$ifname" ] || return
|
||||
|
||||
[ "$egress" -gt 0 ] && {
|
||||
echo "egress status:"
|
||||
dev_status "$ifname"
|
||||
}
|
||||
[ "$ingress" -gt 0 ] && {
|
||||
echo "ingress status:"
|
||||
dev_status "$(printf %.16s "ifb-$ifname")"
|
||||
}
|
||||
}
|
||||
|
||||
is_active() {
|
||||
json_get_vars active
|
||||
|
||||
[ "${active:-0}" -gt 0 ]
|
||||
}
|
||||
|
||||
device_status() {
|
||||
local name="$2"
|
||||
|
||||
json_select "$name"
|
||||
|
||||
if is_active; then
|
||||
status="active"
|
||||
else
|
||||
status="not found"
|
||||
fi
|
||||
|
||||
echo "===== device $name: $status ====="
|
||||
|
||||
is_active && common_status
|
||||
|
||||
json_select ..
|
||||
}
|
||||
|
||||
interface_status() {
|
||||
local name="$2"
|
||||
|
||||
json_select "$name"
|
||||
|
||||
if is_active; then
|
||||
status="active"
|
||||
elif ubus -S -t 0 wait_for "network.interface.$name"; then
|
||||
status="down"
|
||||
else
|
||||
status="not found"
|
||||
fi
|
||||
|
||||
echo "===== interface $name: $status ====="
|
||||
|
||||
is_active && common_status
|
||||
|
||||
json_select ..
|
||||
}
|
||||
|
||||
json_load "$(ubus call qosify status)"
|
||||
json_for_each_item device_status devices
|
||||
json_for_each_item interface_status interfaces
|
||||
48
package/network/config/qosify/files/qosify.conf
Normal file
48
package/network/config/qosify/files/qosify.conf
Normal file
@@ -0,0 +1,48 @@
|
||||
config defaults
|
||||
list defaults /etc/qosify/*.conf
|
||||
option dscp_prio video
|
||||
option dscp_icmp +besteffort
|
||||
option dscp_default_udp besteffort
|
||||
option prio_max_avg_pkt_len 500
|
||||
|
||||
config class besteffort
|
||||
option ingress CS0
|
||||
option egress CS0
|
||||
|
||||
config class bulk
|
||||
option ingress LE
|
||||
option egress LE
|
||||
|
||||
config class video
|
||||
option ingress AF41
|
||||
option egress AF41
|
||||
|
||||
config class voice
|
||||
option ingress CS6
|
||||
option egress CS6
|
||||
option bulk_trigger_pps 100
|
||||
option bulk_trigger_timeout 5
|
||||
option dscp_bulk CS0
|
||||
|
||||
config interface wan
|
||||
option name wan
|
||||
option disabled 1
|
||||
option bandwidth_up 100mbit
|
||||
option bandwidth_down 100mbit
|
||||
option overhead_type none
|
||||
# defaults:
|
||||
option ingress 1
|
||||
option egress 1
|
||||
option mode diffserv4
|
||||
option nat 1
|
||||
option host_isolate 1
|
||||
option autorate_ingress 0
|
||||
option ingress_options ""
|
||||
option egress_options ""
|
||||
option options ""
|
||||
|
||||
config device wandev
|
||||
option disabled 1
|
||||
option name wan
|
||||
option bandwidth 100mbit
|
||||
|
||||
2
package/network/config/qosify/files/qosify.hotplug
Normal file
2
package/network/config/qosify/files/qosify.hotplug
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
ubus call qosify check_devices
|
||||
171
package/network/config/qosify/files/qosify.init
Normal file
171
package/network/config/qosify/files/qosify.init
Normal file
@@ -0,0 +1,171 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (c) 2021 OpenWrt.org
|
||||
|
||||
START=19
|
||||
|
||||
USE_PROCD=1
|
||||
PROG=/usr/sbin/qosify
|
||||
|
||||
add_option() {
|
||||
local type="$1"
|
||||
local name="$2"
|
||||
|
||||
config_get val "$cfg" "$name"
|
||||
|
||||
[ -n "$val" ] && json_add_$type "$name" "$val"
|
||||
}
|
||||
|
||||
add_flow_config() {
|
||||
local cfg="$1"
|
||||
|
||||
add_option string dscp_prio
|
||||
add_option string dscp_bulk
|
||||
add_option int bulk_trigger_timeout
|
||||
add_option int bulk_trigger_pps
|
||||
add_option int prio_max_avg_pkt_len
|
||||
}
|
||||
|
||||
add_defaults() {
|
||||
cfg="$1"
|
||||
|
||||
json_add_boolean reset 1
|
||||
|
||||
config_get files "$cfg" defaults
|
||||
json_add_array files
|
||||
for i in $files; do
|
||||
json_add_string "" "$i"
|
||||
done
|
||||
json_close_array
|
||||
|
||||
add_flow_config "$cfg"
|
||||
add_option int timeout
|
||||
add_option string dscp_icmp
|
||||
add_option string dscp_default_udp
|
||||
add_option string dscp_default_tcp
|
||||
}
|
||||
|
||||
add_interface() {
|
||||
local cfg="$1"
|
||||
|
||||
config_get_bool disabled "$cfg" disabled 0
|
||||
[ "$disabled" -gt 0 ] && return
|
||||
|
||||
config_get name "$cfg" name
|
||||
json_add_object "$name"
|
||||
|
||||
config_get bw "$cfg" bandwidth
|
||||
|
||||
config_get bw_up "$cfg" bandwidth_up
|
||||
bw_up="${bw_up:-$bw}"
|
||||
[ -n "$bw_up" ] && json_add_string bandwidth_up "$bw_up"
|
||||
|
||||
config_get bw_down "$cfg" bandwidth_down
|
||||
bw_down="${bw_down:-$bw}"
|
||||
[ -n "$bw_down" ] && json_add_string bandwidth_down "$bw_down"
|
||||
|
||||
add_option string bandwidth
|
||||
add_option boolean ingress
|
||||
add_option boolean egress
|
||||
add_option string mode
|
||||
add_option boolean nat
|
||||
add_option boolean host_isolate
|
||||
add_option boolean autorate_ingress
|
||||
add_option string ingress_options
|
||||
add_option string egress_options
|
||||
|
||||
config_get user_options "$cfg" options
|
||||
|
||||
config_get otype "$cfg" overhead_type
|
||||
options=
|
||||
case "$otype" in
|
||||
none);;
|
||||
manual)
|
||||
config_get overhead "$cfg" overhead
|
||||
[ -n "$overhead" ] && append options "overhead $overhead"
|
||||
|
||||
config_get encap "$cfg" overhead_encap
|
||||
[ -n "$encap" ] && append options "$encap"
|
||||
;;
|
||||
conservative|\
|
||||
pppoa-vcmux|\
|
||||
pppoa-llc|\
|
||||
pppoe-vcmux|\
|
||||
pppoe-llcsnap|\
|
||||
bridged-vcmux|\
|
||||
bridged-llcsnap|\
|
||||
ipoa-vcmux|\
|
||||
ipoa-llcsnap|\
|
||||
pppoe-ptm|\
|
||||
bridged-ptm|\
|
||||
docsis|\
|
||||
ethernet)
|
||||
append options "$otype"
|
||||
;;
|
||||
esac
|
||||
|
||||
config_get mpu "$cfg" overhead_mpu
|
||||
[ -n "$mpu" ] && append options "mpu $mpu"
|
||||
|
||||
config_get ovlan "$cfg" overhead_vlan
|
||||
[ "${ovlan:-0}" -ge 2 ] && append options "ether-vlan"
|
||||
[ "${ovlan:-0}" -ge 1 ] && append options "ether-vlan"
|
||||
|
||||
[ -n "$user_options" ] && append options "$user_options"
|
||||
[ -n "$options" ] && json_add_string options "$options"
|
||||
|
||||
json_close_object
|
||||
}
|
||||
|
||||
add_class() {
|
||||
local cfg="$1"
|
||||
|
||||
config_get value "$cfg" value
|
||||
config_get ingress "$cfg" ingress
|
||||
config_get egress "$cfg" egress
|
||||
|
||||
json_add_object "$cfg"
|
||||
json_add_string ingress "${ingress:-$value}"
|
||||
json_add_string egress "${egress:-$value}"
|
||||
add_flow_config "$cfg"
|
||||
json_close_object
|
||||
}
|
||||
|
||||
|
||||
reload_service() {
|
||||
json_init
|
||||
|
||||
config_load qosify
|
||||
|
||||
config_foreach add_defaults defaults
|
||||
|
||||
json_add_object interfaces
|
||||
config_foreach add_interface interface
|
||||
json_close_object
|
||||
|
||||
json_add_object classes
|
||||
config_foreach add_class class
|
||||
config_foreach add_class alias
|
||||
json_close_object
|
||||
|
||||
json_add_object devices
|
||||
config_foreach add_interface device
|
||||
json_close_object
|
||||
|
||||
ubus call qosify config "$(json_dump)"
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger qosify
|
||||
}
|
||||
|
||||
start_service() {
|
||||
procd_open_instance
|
||||
procd_set_param command "$PROG"
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
service_started() {
|
||||
ubus -t 10 wait_for qosify
|
||||
[ $? = 0 ] && reload_service
|
||||
}
|
||||
Reference in New Issue
Block a user