mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
easy-qos: update ebtables to add repeated addresses preemptively
This commit is contained in:
parent
89c54abec6
commit
87e70ef5d2
1 changed files with 36 additions and 19 deletions
|
|
@ -1,5 +1,7 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
. /lib/functions/iopsys-repeated-macs.sh
|
||||
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
|
||||
|
|
@ -89,6 +91,31 @@ create_rule() {
|
|||
exec_log ebtables -t broute -A BROUTING ${cmd}
|
||||
}
|
||||
|
||||
create_rules() {
|
||||
protocol=$1; shift
|
||||
macaddr=$1; shift
|
||||
prio_num=$1; shift
|
||||
port=$1
|
||||
|
||||
for p in $port; do
|
||||
if [ "$protocol" == "none" ]; then
|
||||
create_rule tcp $macaddr $prio_num $p
|
||||
create_rule udp $macaddr $prio_num $p
|
||||
else
|
||||
create_rule $protocol $macaddr $prio_num $p
|
||||
fi
|
||||
done
|
||||
# Create rule for all ports if port is not mentioned in uci
|
||||
if [ -z "$port" ]; then
|
||||
if [ "$protocol" == "none" ]; then
|
||||
create_rule tcp $macaddr $prio_num
|
||||
create_rule udp $macaddr $prio_num
|
||||
else
|
||||
create_rule $protocol $macaddr $prio_num
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
manage_rule() {
|
||||
local cfg="$1"
|
||||
local priority macaddr proto port comment prio_num protocol
|
||||
|
|
@ -100,25 +127,15 @@ manage_rule() {
|
|||
|
||||
protocol=$(echo ${proto}|tr [A-Z] [a-z])
|
||||
prio_num=$(get_priority ${priority})
|
||||
if [ -n "${macaddr}" -a -n "${prio_num}" ]; then
|
||||
for p in ${port}; do
|
||||
if [ "${protocol}" == "none" ]; then
|
||||
create_rule tcp ${macaddr} ${prio_num} ${p}
|
||||
create_rule udp ${macaddr} ${prio_num} ${p}
|
||||
else
|
||||
create_rule ${protocol} ${macaddr} ${prio_num} ${p}
|
||||
fi
|
||||
done
|
||||
# Create rule for all ports if port is not mentioned in uci
|
||||
if [ -z "${port}" ]; then
|
||||
if [ "${protocol}" == "none" ]; then
|
||||
create_rule tcp ${macaddr} ${prio_num}
|
||||
create_rule udp ${macaddr} ${prio_num}
|
||||
else
|
||||
create_rule ${protocol} ${macaddr} ${prio_num}
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
[ -n "${macaddr}" -a -n "${prio_num}" ] || return
|
||||
|
||||
create_rules ${protocol} ${macaddr} ${prio_num} ${port}
|
||||
repeated_macs=$(mac_to_repeated ${macaddr})
|
||||
for mac in $repeated_macs; do
|
||||
[ "$mac" = "${macaddr}" ] && continue
|
||||
create_rules ${protocol} $mac ${prio_num} ${port}
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue