qosmngr : Incorporating all interfaces option in classify

This commit is contained in:
Padmalochan Mohapatra 2023-10-12 09:41:20 +05:30 committed by Rahul Thakur
parent e72b600326
commit 063314c91d
3 changed files with 24 additions and 13 deletions

View file

@ -8,6 +8,7 @@ generate_dns_rule(){
uci add qos classify
uci rename qos.@classify[-1]="c${classify_no}"
uci set qos.@classify[-1].ifname="lo"
uci set qos.@classify[-1].all_interfaces="0"
uci set qos.@classify[-1].proto="udp"
uci set qos.@classify[-1].ethertype="IPv4"
uci set qos.@classify[-1].dest_port="53"
@ -20,6 +21,7 @@ generate_dhcp_rule(){
uci add qos classify
uci rename qos.@classify[-1]="c${classify_no}"
uci set qos.@classify[-1].ifname="lo"
uci set qos.@classify[-1].all_interfaces="0"
uci set qos.@classify[-1].proto="udp"
uci set qos.@classify[-1].ethertype="IPv4"
uci set qos.@classify[-1].dest_port="67"
@ -33,6 +35,7 @@ generate_igmp_rule(){
uci add qos classify
uci rename qos.@classify[-1]="c${classify_no}"
uci set qos.@classify[-1].ifname="lo"
uci set qos.@classify[-1].all_interfaces="0"
uci set qos.@classify[-1].proto="IGMP"
uci set qos.@classify[-1].ethertype="IPv4"
uci set qos.@classify[-1].traffic_class="$1"
@ -44,6 +47,7 @@ generate_icmp_rule(){
uci add qos classify
uci rename qos.@classify[-1]="c${classify_no}"
uci set qos.@classify[-1].ifname="lo"
uci set qos.@classify[-1].all_interfaces="0"
uci set qos.@classify[-1].proto="icmp"
uci set qos.@classify[-1].ethertype="IPv4"
uci set qos.@classify[-1].traffic_class="$1"
@ -96,6 +100,7 @@ generate_classify(){
uci add qos classify
uci rename qos.@classify[-1]="c${classify_no}"
uci set qos.@classify[-1].pcp_check="$i"
uci set qos.@classify[-1].all_interfaces="0"
uci set qos.@classify[-1].traffic_class="$i"
uci set qos.@classify[-1].order="$classify_no"
done

View file

@ -237,15 +237,18 @@ handle_ebtables_rules() {
config_get dst_ucid "$sid" "dst_user_class_id" # dhcp option 77
config_get traffic_class "$sid" "traffic_class"
config_get protocol "$sid" "proto"
config_get all_interfaces "$sid" "all_interfaces"
if [ -n "$src_if" ]; then
for interf in $(db -q get hw.board.ethernetPortOrder); do
if [ "$src_if" == "$interf" ]; then
src_if="$src_if+"
broute_filter_on_src_if "$src_if"
is_l2_rule=1
fi
done
if [ "$all_interfaces" == "1" ]; then
is_l2_rule=1
elif [ -n "$src_if" ]; then
for interf in $(db -q get hw.board.ethernetPortOrder); do
if [ "$src_if" == "$interf" ]; then
src_if="$src_if+"
broute_filter_on_src_if "$src_if"
is_l2_rule=1
fi
done
fi
if [ -n "$src_mac" ]; then

View file

@ -93,6 +93,7 @@ handle_iptables_rules() {
config_get ip_len_min "$cid" "ip_len_min"
config_get ip_len_max "$cid" "ip_len_max"
config_get ifname "$cid" "ifname"
config_get all_interfaces "$cid" "all_interfaces"
#check version of ip
case $src_ip$dest_ip in
@ -107,10 +108,10 @@ handle_iptables_rules() {
esac
#filter interface
if [ -n "$ifname" ]; then
if [ "$ifname" != "lo" ]; then
iptables_filter_intf "$ifname"
fi
if ! [ "$all_interfaces" == "1" ]; then
if [ -n "$ifname" -a "$ifname" != "lo" ]; then
iptables_filter_intf "$ifname"
fi
fi
# filter proto
@ -197,7 +198,9 @@ handle_iptables_rules() {
[ -n "$IP_RULE" ] && [ -n "$dscp_mark" ] && append_rule_to_mangle_table "qos_forward" $ip_version
if [ -n "$IP_RULE" ] && [ -n "$traffic_class" ]; then
if [ "$ifname" == "lo" ]; then
if [ "all_interfaces" == "1" ]; then
append_rule_to_mangle_table "qos_output" $ip_version
elif [ "$ifname" == "lo" ]; then
#write iptables rule for putting WAN directed internal packets in different queue
append_rule_to_mangle_table "qos_output" $ip_version
else