qosmngr: fix qos reload

* applicable only for linux target
* fix reload to setup qos properly and not overwrite queue on
  reload
* fixed l2 classification broken in reload
This commit is contained in:
Rahul Thakur 2024-05-23 09:04:28 +05:30
parent c23c0248e1
commit e28f1a653c

View file

@ -534,14 +534,160 @@ reload_qos() {
elif [ "$service_name" == "queue" ]; then
pre_configure_queue
configure_queue
elif [ "$service_name" == "classify" ]; then
configure_classify
elif [ "$service_name" == "classify" ]; then
configure_classify
if [ -f "/tmp/qos/classify.ebtables" ]; then
sh /tmp/qos/classify.ebtables
fi
elif [ "$service_name" == "policer" ]; then
configure_policer
fi
}
reload_qos_service() {
reload_qos
get_cfg_added_deleted()
{
# return true if there is difference in number of queue configuration
# in /etc/config/qos and /tmp/qos/qos, false is returned if both file
# has same count of queue configuration.
local queue=0
local classify=0
local shaper=0
local policer=0
local old_cfg="false"
config_cb() {
# invoked on the just previous config_load, get the count of
# queue configuration in /etc/config/qos and /tmp/qos/qos.
cfg_type="$1"
cfg_name="$2"
if [ -z $cfg_name ] || [ -z $cfg_type ]; then
return
fi
if [ "$old_cfg" == "false" ]; then
eval $cfg_type=$(($cfg_type + 1))
else
eval $cfg_type=$(($cfg_type - 1))
fi
option_cb() {
local option="$1"
local value="$2"
if [ -z "$option" ] || [ -z "$value" ]; then
return
fi
if [ "$old_cfg" == "false" ]; then
eval $cfg_type=$(($cfg_type + 1))
else
eval $cfg_type=$(($cfg_type - 1))
fi
}
}
# config_load will trigger call for config_cb that is getting count
# of qos configuration, respective config counts will come.
config_load qos
# config_load will trigger call for config_cb that is decreasing count
# of qos configuration.
old_cfg="true"
UCI_CONFIG_DIR="/tmp/qos"
config_load qos
UCI_CONFIG_DIR="/etc/config"
reset_cb
if [ $classify -ne 0 ]; then
modified_config="classify"
fi
if [ $shaper -ne 0 ]; then
modified_config="$modified_config shaper"
fi
if [ $policer -ne 0 ]; then
modified_config="$modified_config policer"
fi
if [ $queue -eq 0 ]; then
echo "$modified_config"
return
else
echo "queue"
return
fi
}
# reload_qos_service is invoked on qos service reload.
reload_qos_service() {
q_cfg_restart="false"
policer="false"
classify="false"
shaper="false"
setup_qos
if ! [[ -f "/etc/config/qos" && -f "/tmp/qos/qos" ]]; then
configure_qos
cp /etc/config/qos /tmp/qos/qos
fi
config_cb() {
# this is invoked when config_load is called.
cfg_type="$1"
cfg_name="$2"
if [ -z $cfg_name ] || [ -z $cfg_type ]; then
return
fi
option_cb() {
# checking for if any parameters value is modified in queue cfg
# comparsion is done between /etc/config/qos and /tmp/qos/qos
local option="$1"
local value="$2"
local old_value=""
if [ -z "$option" ] || [ -z "$value" ]; then
return
fi
old_value=$(uci -q -c "/tmp/qos" get qos.$cfg_name.$option)
if ! [ "$old_value" == "$value" ]; then
if [ "$cfg_type" == "queue" ]; then
q_cfg_restart="true"
else
eval $cfg_type="true"
fi
fi
}
}
# if there is new addition/deletion of queue configuration
# then return is queue to trigger restart of qos.
# Otehrwise shaper policer classify
# respective operation config is invoked that does not change queue statistics
cfg_added_deleted=$(get_cfg_added_deleted)
if [ "$cfg_added_deleted" == "queue" ]; then
configure_qos
else
q_cfg_restart="false"
# config_load will trigger call for config_cb that is checking
# for modification in config value of queue config.
# if change of value of queue config is there then q_cfg_restart
# is set as true, else other qos config flag is set as true.
config_load qos
reset_cb
if [ "$q_cfg_restart" == "true" ]; then
configure_qos
else
for config in $cfg_added_deleted
do
eval $config="true"
done
if [ "$shaper" == "true" ]; then
# for tc, shaper is implemented as part of q setup
# hence, if shaper is modified, reload queue
reload_qos "queue"
fi
if [ "$policer" == "true" ]; then
reload_qos "policer"
# change in policer config may need reconfiguration
# of classifier
reload_qos "classify"
fi
if [ "$classify" == "true" ]; then
reload_qos "classify"
fi
fi
fi
cp /etc/config/qos /tmp/qos/qos
}