2006-10-06 17:38:48 +00:00
|
|
|
#!/bin/sh
|
2011-01-20 17:33:41 +00:00
|
|
|
# Copyright (C) 2011 OpenWrt.org
|
|
|
|
|
2012-06-05 16:04:23 +00:00
|
|
|
. /lib/functions.sh
|
2011-01-20 17:33:41 +00:00
|
|
|
|
|
|
|
include /lib/network
|
|
|
|
|
|
|
|
get_ifname() {
|
|
|
|
local interface="$1"
|
|
|
|
local cfgt
|
|
|
|
|
|
|
|
scan_interfaces
|
|
|
|
config_get cfgt "$interface" TYPE
|
2014-10-14 12:21:11 +00:00
|
|
|
[ "$cfgt" = "interface" ] && config_get "$interface" ifname
|
2011-01-20 17:33:41 +00:00
|
|
|
}
|
|
|
|
|
2018-06-08 11:34:00 +00:00
|
|
|
qos_set_device() {
|
|
|
|
config_get TYPE "$1" TYPE
|
2014-10-14 12:21:11 +00:00
|
|
|
[ "interface" = "$TYPE" ] && {
|
2018-06-08 11:34:00 +00:00
|
|
|
config_get device "$1" ifname
|
|
|
|
[ -z "$device" ] && device="$(get_ifname $1)"
|
|
|
|
config_set "$1" device "$device"
|
2011-01-20 17:33:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
config_load qos
|
2018-06-08 11:34:00 +00:00
|
|
|
config_foreach qos_set_device
|
2011-01-20 17:33:41 +00:00
|
|
|
|
|
|
|
print_comments() {
|
|
|
|
echo ''
|
|
|
|
echo '# Interface: '"$1"
|
|
|
|
echo '# Direction: '"$2"
|
|
|
|
echo '# Stats: '"$3"
|
|
|
|
echo ''
|
|
|
|
}
|
|
|
|
|
2011-02-21 01:33:27 +00:00
|
|
|
get_device() {
|
|
|
|
( config_load network; scan_interfaces; config_get "$1" ifname )
|
|
|
|
}
|
|
|
|
|
2011-01-20 17:33:41 +00:00
|
|
|
interface_stats() {
|
|
|
|
local interface="$1"
|
|
|
|
local device
|
|
|
|
|
2011-02-21 01:33:27 +00:00
|
|
|
device="$(get_device "$interface")"
|
|
|
|
[ -z "$device" ] && config_get device "$interface" device
|
2011-01-20 17:33:41 +00:00
|
|
|
config_get_bool enabled "$interface" enabled 1
|
|
|
|
[ -z "$device" -o 1 -ne "$enabled" ] && {
|
|
|
|
return 1
|
|
|
|
}
|
2011-02-21 01:33:27 +00:00
|
|
|
config_get_bool halfduplex "$interface" halfduplex 0
|
2011-01-20 17:33:41 +00:00
|
|
|
|
2011-02-21 01:33:27 +00:00
|
|
|
if [ 1 -ne "$halfduplex" ]; then
|
2011-01-20 17:33:41 +00:00
|
|
|
unset halfduplex
|
|
|
|
print_comments "$interface" "Egress" "Start"
|
|
|
|
tc -s class show dev "$device"
|
|
|
|
print_comments "$interface" "Egress" "End"
|
2011-02-21 01:33:27 +00:00
|
|
|
id="root"
|
|
|
|
else
|
|
|
|
id=""
|
|
|
|
fi
|
2011-01-20 17:33:41 +00:00
|
|
|
|
|
|
|
print_comments "$interface" "Ingress${halfduplex:+/Egress}" "Start"
|
2011-02-21 01:33:27 +00:00
|
|
|
tc -s class show dev "$(tc filter show dev $device $id | grep mirred | sed -e 's,.*\(ifb.*\)).*,\1,')"
|
2011-01-20 17:33:41 +00:00
|
|
|
print_comments "$interface" "Ingress${halfduplex:+/Egress}" "End"
|
|
|
|
}
|
|
|
|
|
|
|
|
[ -z "$1" ] && config_foreach interface_stats interface || interface_stats "$1"
|