tree-wide: use OpenWrt way to define LAN/WAN ports

This commit is contained in:
Markus Gothe 2024-03-10 13:32:06 +01:00 committed by Rahul Thakur
parent cb2ce4a8a3
commit 5b702e1991
9 changed files with 21 additions and 21 deletions

View file

@ -45,7 +45,7 @@ fi
######################################################## ########################################################
################ Dedicated ETH WAN Port ################ ################ Dedicated ETH WAN Port ################
wanport="$(db -q get hw.board.ethernetWanPort)" wanport="$(jsonfilter -i /etc/board.json -e @.network.wan.device)"
if [ -n "$wanport" ]; then if [ -n "$wanport" ]; then
[ "$wanport" = "$PORT" ] || exit 0 [ "$wanport" = "$PORT" ] || exit 0
######################################################## ########################################################

View file

@ -11,7 +11,7 @@ CONFFILE=/var/mcpd.conf
PROG_EXE=/usr/sbin/mcpd PROG_EXE=/usr/sbin/mcpd
proxdevs="" proxdevs=""
ethwan="$(db -q get hw.board.ethernetWanPort)" ethwan="$(jsonfilter -i /etc/board.json -e @.network.wan.device)"
config_snooping_common_params() { config_snooping_common_params() {

View file

@ -42,7 +42,7 @@ hw_queue_set() {
local rate="$7" local rate="$7"
local burstsize="$8" local burstsize="$8"
local index="$((order - 1))" local index="$((order - 1))"
local ethwan="$(db -q get hw.board.ethernetWanPort)" local ethwan="$(jsonfilter -i /etc/board.json -e @.network.wan.device)"
#if [ "${ifname}" != "${ethwan}" ] ; then #if [ "${ifname}" != "${ethwan}" ] ; then
# return 2 # return 2

View file

@ -101,7 +101,7 @@ handle_policer() {
# Configure policer based on UCI subtree 'qos.policer' # Configure policer based on UCI subtree 'qos.policer'
configure_policer() { configure_policer() {
for intf in $(db get hw.board.ethernetPortOrder); do for intf in $(jsonfilter -i /etc/board.json -e @.network.lan.ports[*] -e @.network.wan.device | xargs); do
if [ -n "${intf}" ] ; then if [ -n "${intf}" ] ; then
hw_policer_set_ingress_rate "$intf" 0 0 hw_policer_set_ingress_rate "$intf" 0 0
fi fi
@ -129,4 +129,4 @@ configure_policer() {
config_load qos config_load qos
config_foreach handle_policer policer config_foreach handle_policer policer
echo $POLICER_COUNT > /tmp/qos/max_policer_inst echo $POLICER_COUNT > /tmp/qos/max_policer_inst
} }

View file

@ -8,7 +8,7 @@ pre_configure_queue() {
# Delete queues # Delete queues
hw_queue_init_all hw_queue_init_all
for intf in $(db get hw.board.ethernetPortOrder); do for intf in $(jsonfilter -i /etc/board.json -e @.network.lan.ports[*] -e @.network.wan.device | xargs); do
hw_intf_init "${intf}" hw_intf_init "${intf}"
done done
} }

View file

@ -35,7 +35,7 @@ handle_shaper() {
# Configure shaper based on options saved to UCI tree 'qos.shaper' # Configure shaper based on options saved to UCI tree 'qos.shaper'
configure_shaper() { configure_shaper() {
# Delete existing shaper # Delete existing shaper
for intf in $(db get hw.board.ethernetPortOrder); do for intf in $(jsonfilter -i /etc/board.json -e @.network.lan.ports[*] -e @.network.wan.device | xargs); do
hw_shaper_set "$intf" del hw_shaper_set "$intf" del
done done

View file

@ -80,7 +80,7 @@ sort_q_by_precedence() {
} }
sort_by_precedence() { sort_by_precedence() {
for interf in $(db -q get hw.board.ethernetPortOrder); do for interf in $(jsonfilter -i /etc/board.json -e @.network.lan.ports[*] -e @.network.wan.device | xargs); do
sort_q_by_precedence $interf sort_q_by_precedence $interf
done done
} }
@ -335,7 +335,7 @@ handle_shaper() {
assign_policer_to_port() { assign_policer_to_port() {
local ifname="$1" local ifname="$1"
local pindex="$2" local pindex="$2"
local portorder="$(db -q get hw.board.ethernetPortOrder)" local portorder="$(jsonfilter -i /etc/board.json -e @.network.lan.ports[*] -e @.network.wan.device | xargs)"
for port in $portorder; do for port in $portorder; do
if [ "$ifname" == "$port" ]; then if [ "$ifname" == "$port" ]; then
@ -398,7 +398,7 @@ config_ingress_rate_limit() {
local ifname="$1" local ifname="$1"
local ingress_rate=$2 local ingress_rate=$2
local in_burst_size=$3 local in_burst_size=$3
local wanport="$(db -q get hw.board.ethernetWanPort)" local wanport="$(jsonfilter -i /etc/board.json -e @.network.wan.device)"
# Unit in uci file is in bps while that accepted by ethswctl is kbits # Unit in uci file is in bps while that accepted by ethswctl is kbits
if [ $ingress_rate -lt 1000 ]; then if [ $ingress_rate -lt 1000 ]; then
@ -421,7 +421,7 @@ config_ingress_rate_limit() {
configure_shaper() { configure_shaper() {
# Delete existing shaper # Delete existing shaper
for intf in $(db get hw.board.ethernetPortOrder); do for intf in $(jsonfilter -i /etc/board.json -e @.network.lan.ports[*] -e @.network.wan.device | xargs); do
tmctl setportshaper --devtype 0 --if $intf --shapingrate 0 --burstsize -1 tmctl setportshaper --devtype 0 --if $intf --shapingrate 0 --burstsize -1
done done
# Load UCI file # Load UCI file
@ -432,7 +432,7 @@ configure_shaper() {
pre_configure_queue() { pre_configure_queue() {
# Delete queues # Delete queues
for intf in $(db get hw.board.ethernetPortOrder); do for intf in $(jsonfilter -i /etc/board.json -e @.network.lan.ports[*] -e @.network.wan.device | xargs); do
rm -rf /tmp/qos/$intf rm -rf /tmp/qos/$intf
mkdir -p /tmp/qos/$intf mkdir -p /tmp/qos/$intf
@ -452,7 +452,7 @@ pre_configure_queue() {
configure_queue_shaping_rate() { configure_queue_shaping_rate() {
# Load UCI file # Load UCI file
config_load qos config_load qos
for interf in $(db -q get hw.board.ethernetPortOrder); do for interf in $(jsonfilter -i /etc/board.json -e @.network.lan.ports[*] -e @.network.wan.device | xargs); do
Q_COUNT=0 Q_COUNT=0
config_foreach handle_queue_shapingrate queue $interf config_foreach handle_queue_shapingrate queue $interf
done done
@ -463,7 +463,7 @@ configure_queue() {
config_load qos config_load qos
config_foreach handle_q_order queue config_foreach handle_q_order queue
sort_by_precedence sort_by_precedence
for interf in $(db -q get hw.board.ethernetPortOrder); do for interf in $(jsonfilter -i /etc/board.json -e @.network.lan.ports[*] -e @.network.wan.device | xargs); do
Q_COUNT=0 Q_COUNT=0
# sp queue have max priority value = no. of queue configured on the port # sp queue have max priority value = no. of queue configured on the port
# hence read and update SP_Q_PRIO here # hence read and update SP_Q_PRIO here
@ -476,7 +476,7 @@ configure_queue() {
configure_policer() { configure_policer() {
# The policer object is not available on non BCM968* chips, just clean up # The policer object is not available on non BCM968* chips, just clean up
# the old config if any and return # the old config if any and return
for intf in $(db get hw.board.ethernetPortOrder); do for intf in $(jsonfilter -i /etc/board.json -e @.network.lan.ports[*] -e @.network.wan.device | xargs); do
local unitport="$(get_port_number $intf)" local unitport="$(get_port_number $intf)"
local unit=$(echo $unitport | cut -d ' ' -f 1) local unit=$(echo $unitport | cut -d ' ' -f 1)
local port=$(echo $unitport | cut -d ' ' -f 2) local port=$(echo $unitport | cut -d ' ' -f 2)

View file

@ -242,7 +242,7 @@ handle_ebtables_rules() {
if [ "$all_interfaces" == "1" ]; then if [ "$all_interfaces" == "1" ]; then
is_l2_rule=1 is_l2_rule=1
elif [ -n "$src_if" ]; then elif [ -n "$src_if" ]; then
for interf in $(db -q get hw.board.ethernetPortOrder); do for interf in $(jsonfilter -i /etc/board.json -e @.network.lan.ports[*] -e @.network.wan.device | xargs); do
if [ "$src_if" == "$interf" ]; then if [ "$src_if" == "$interf" ]; then
src_if="$src_if+" src_if="$src_if+"
broute_filter_on_src_if "$src_if" broute_filter_on_src_if "$src_if"

View file

@ -82,7 +82,7 @@ sort_q_by_precedence() {
} }
sort_by_precedence() { sort_by_precedence() {
for interf in $(db -q get hw.board.ethernetPortOrder); do for interf in $(jsonfilter -i /etc/board.json -e @.network.lan.ports[*] -e @.network.wan.device | xargs); do
sort_q_by_precedence $interf sort_q_by_precedence $interf
done done
} }
@ -356,7 +356,7 @@ config_ingress_rate_limit() {
local ingress_rate=$2 local ingress_rate=$2
local in_burst_size=$3 local in_burst_size=$3
local pindex="$4" local pindex="$4"
local wanport="$(db -q get hw.board.ethernetWanPort)" local wanport="$(jsonfilter -i /etc/board.json -e @.network.wan.device)"
# Unit in uci file is in bps while that accepted by ethswctl is kbits # Unit in uci file is in bps while that accepted by ethswctl is kbits
if [ $ingress_rate -lt 1000 ]; then if [ $ingress_rate -lt 1000 ]; then
@ -384,7 +384,7 @@ config_ingress_rate_limit() {
pre_configure_queue() { pre_configure_queue() {
# Delete queues # Delete queues
for intf in $(db get hw.board.ethernetPortOrder); do for intf in $(jsonfilter -i /etc/board.json -e @.network.lan.ports[*] -e @.network.wan.device | xargs); do
rm -rf /tmp/qos/$intf rm -rf /tmp/qos/$intf
mkdir -p /tmp/qos/$intf mkdir -p /tmp/qos/$intf
@ -462,8 +462,8 @@ configure_queue() {
fi fi
bs=$(( bs / 1000 )) bs=$(( bs / 1000 ))
} }
local wanport="$(db -q get hw.board.ethernetWanPort)" local wanport="$(jsonfilter -i /etc/board.json -e @.network.wan.device)"
for interf in $(db -q get hw.board.ethernetPortOrder); do for interf in $(jsonfilter -i /etc/board.json -e @.network.lan.ports[*] -e @.network.wan.device | xargs); do
Q_COUNT=0 Q_COUNT=0
rate=0 rate=0
# sp queue have max priority value = no. of queue configured on the port # sp queue have max priority value = no. of queue configured on the port