Compare commits

...

7 Commits

Author SHA1 Message Date
Arun Muthusamy
e6b1697529 Qos: Code explanation 2022-06-16 08:27:33 +02:00
Arun Muthusamy
0a52233bfe Find and Aggregate the last section record of the first file 2022-06-14 08:25:36 +02:00
Arun Muthusamy
d20e81bc9f Remove ENDFILE file option to find the last record of the file 2022-06-14 04:35:58 +02:00
Arun Muthusamy
42cac79399 qos: ignore leading empty spaces 2022-06-13 12:21:18 +02:00
Arun Muthusamy
399dfc30fc qos: comparator implementation 2022-06-13 11:19:46 +02:00
Arun Muthusamy
46d1602379 qos: Find dissimilarity between config file and call appropriate qos
mechanism
2022-06-10 16:27:48 +02:00
Arun Muthusamy
4050e15755 qos: Avoid stats to be reseted on qos reload 2022-06-10 16:27:48 +02:00

View File

@@ -13,7 +13,88 @@ PROG=/usr/sbin/qosmngr
. /lib/functions.sh
include /lib/qos
comparator() {
awk '
function find_duplicate_config() {
#Eradicate leading zeros
c = substr(c, 2)
if(c) {
#Process first file
if(FNR == NR) {
qoscs[++count] = c
}
#Process second file and find the difference
else {
for(count in qoscs) {
if(qoscs[count] == c) {
qosds[count] = 1
break
}
}
}
}
c = ""
}
#Find the last config of the first file
!fls && NR != FNR {
#Eradicate leading zeros
c = substr(c, 2)
qoscs[++count] = c
fls = 1
}
#Match config section and find duplicate config
/^config/ && c { find_duplicate_config() }
#Match the line starts with letters and aggregate the config section
/^\s*[a-z]/ {
sub("^\\s*", "")
c = c "\n" $0
}
#Identify the difference between the two files at the end
END {
find_duplicate_config()
#Loop through the config section in the first file and find the difference
for(count in qoscs) {
if(!(count in qosds)) {
print qoscs[count] "\n"
}
}
}' $1 $2 > $3
}
#function to handle a policer section
qos_reload_handler() {
qos_mechanism_handler() {
config_get cfgtype "$1" TYPE
if [ "$cfgtype" == "shaper" ]; then
reload_qos $cfgtype
elif [ "$cfgtype" == "classify" ]; then
reload_qos $cfgtype
elif [ "$cfgtype" == "policer" ]; then
reload_qos $cfgtype
elif [ "$cfgtype" == "queue" ]; then
restart
fi
}
config_load "/tmp/qos_config_diff"
config_foreach qos_mechanism_handler
}
start_service() {
if [ ! -f "/tmp/qos_config" ]; then
touch /tmp/qos_config
cp /etc/config/qos /tmp/qos_config
fi
if [ -f "/etc/config/qos" ]; then
reload_qos
procd_open_instance qosmngr
@@ -37,3 +118,15 @@ restart() {
setup_qos
start
}
reload_service()
{
if [[ -f "/etc/config/qos" && -f "/tmp/qos_config" ]]; then
comparator /etc/config/qos /tmp/qos_config /tmp/qos_config_diff
cp /etc/config/qos /tmp/qos_config
if [[ ! -z "/tmp/qos_config_diff" ]]; then
qos_reload_handler
fi
fi
}