mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
qos: Apply qos classify config in the order of order param value
This commit is contained in:
parent
1d1c621821
commit
cc7d076dc8
1 changed files with 56 additions and 4 deletions
|
|
@ -10,6 +10,9 @@ POLICER_COUNT=0
|
||||||
Q_COUNT=0
|
Q_COUNT=0
|
||||||
SP_Q_PRIO=7
|
SP_Q_PRIO=7
|
||||||
|
|
||||||
|
#counter variable to assign classify order value if not added in config
|
||||||
|
temp_order=1
|
||||||
|
|
||||||
# Function to handle a queue order and
|
# Function to handle a queue order and
|
||||||
# update total number of queues
|
# update total number of queues
|
||||||
handle_q_order() {
|
handle_q_order() {
|
||||||
|
|
@ -976,6 +979,43 @@ config_ingress_rate_limit() {
|
||||||
ethswctl -c rxratectrl -n $unit -p $port -x $ingress_rate -y $in_burst_size
|
ethswctl -c rxratectrl -n $unit -p $port -x $ingress_rate -y $in_burst_size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to handle a classify order
|
||||||
|
handle_classify_order() {
|
||||||
|
local cid="$1" #classify section ID
|
||||||
|
|
||||||
|
config_get is_enable "$cid" "enable" 1
|
||||||
|
|
||||||
|
# No need to configure disabled classify
|
||||||
|
if [ $is_enable == '0' ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create classify file containing classify order
|
||||||
|
local corder_file="/tmp/qos/classify.order"
|
||||||
|
|
||||||
|
config_get c_order "$cid" "order"
|
||||||
|
|
||||||
|
if [ -z "$c_order" ]; then
|
||||||
|
c_order=$temp_order;
|
||||||
|
temp_order=$((temp_order + 1))
|
||||||
|
fi
|
||||||
|
|
||||||
|
value=${c_order}_${cid}
|
||||||
|
echo $value >> $corder_file
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# Sort classify, lower value in uci means higher precedence, so this
|
||||||
|
# function sorts the classify order in assending order
|
||||||
|
sort_classify_by_order() {
|
||||||
|
local corder_file="/tmp/qos/classify.order"
|
||||||
|
local tmp_corder_file="/tmp/qos/tmp_classify.order"
|
||||||
|
|
||||||
|
sort -n -k1 $corder_file > $tmp_corder_file
|
||||||
|
cp $tmp_corder_file $corder_file
|
||||||
|
rm -f $tmp_corder_file
|
||||||
|
}
|
||||||
|
|
||||||
#function to handle a classify section
|
#function to handle a classify section
|
||||||
handle_classify() {
|
handle_classify() {
|
||||||
cid="$1" #classify section ID
|
cid="$1" #classify section ID
|
||||||
|
|
@ -986,9 +1026,15 @@ handle_classify() {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
handle_ebtables_rules $cid
|
local corder_file="/tmp/qos/classify.order"
|
||||||
handle_iptables_rules $cid
|
|
||||||
handle_policer_rules $cid
|
while read -r line; do
|
||||||
|
line_cid=${line: 2}
|
||||||
|
|
||||||
|
handle_ebtables_rules $line_cid
|
||||||
|
handle_iptables_rules $line_cid
|
||||||
|
handle_policer_rules $line_cid
|
||||||
|
done < "$corder_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
configure_shaper() {
|
configure_shaper() {
|
||||||
|
|
@ -1008,19 +1054,25 @@ configure_classify() {
|
||||||
rm -f /tmp/qos/classify.ebtables
|
rm -f /tmp/qos/classify.ebtables
|
||||||
rm -f /tmp/qos/classify.iptables
|
rm -f /tmp/qos/classify.iptables
|
||||||
rm -f /tmp/qos/classify.ip6tables
|
rm -f /tmp/qos/classify.ip6tables
|
||||||
|
rm -f /tmp/qos/classify.order
|
||||||
|
rm -f /tmp/qos/tmp_classify.order
|
||||||
|
|
||||||
#create files that will contain the rules if not present already
|
#create files that will contain the rules if not present already
|
||||||
mkdir -p /tmp/qos/
|
mkdir -p /tmp/qos/
|
||||||
touch /tmp/qos/classify.iptables
|
touch /tmp/qos/classify.iptables
|
||||||
touch /tmp/qos/classify.ip6tables
|
touch /tmp/qos/classify.ip6tables
|
||||||
touch /tmp/qos/classify.ebtables
|
touch /tmp/qos/classify.ebtables
|
||||||
|
touch /tmp/qos/classify.order
|
||||||
|
touch /tmp/qos/tmp_classify.order
|
||||||
|
|
||||||
#add flush chain rules
|
#add flush chain rules
|
||||||
flush_chains
|
flush_chains
|
||||||
|
|
||||||
# Load UCI file
|
# Load UCI file
|
||||||
config_load qos
|
config_load qos
|
||||||
config_foreach handle_classify classify
|
config_foreach handle_classify_order classify
|
||||||
|
sort_classify_by_order
|
||||||
|
handle_classify classify
|
||||||
|
|
||||||
sh /tmp/qos/classify.ebtables
|
sh /tmp/qos/classify.ebtables
|
||||||
sh /tmp/qos/classify.iptables
|
sh /tmp/qos/classify.iptables
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue