qosmngr: Solve issue with L3 HW NAT for DSCP.

When doing classification on DSCP values we need
to ensure that the values are correctly hashed
for the L3 HW NAT, otherwise identical flows
with different DSCP values will end up with
the same QoS priority and queue.
This commit is contained in:
Markus Gothe 2024-08-14 23:41:08 +02:00
parent 32203771f6
commit bcdb31c830
2 changed files with 40 additions and 4 deletions

View file

@ -26,10 +26,17 @@ hw_intf_init() {
# Initialize the hardware setup library
hw_init_all() {
local tc=0
export TMP_HW_QUEUE_LIST=""
echo clear > /proc/ifc_debug
echo reinit > /proc/ifc_debug
for tc in $(seq 0 7); do
rm -rf "/tmp/qos/dscp_values_${tc}_4"
rm -rf "/tmp/qos/dscp_values_${tc}_6"
done
return 0
}
@ -154,6 +161,7 @@ hw_commit_all() {
local q_count="0"
local mac_qos_flag=""
local pbit=0
local tc=0
# Reorder queues
for q in ${sorted_list} ; do
@ -210,8 +218,32 @@ hw_commit_all() {
/userfs/bin/qosrule discpline Enable 0
fi
echo 1 > /proc/ifc_send_to_ppe
for pbit in $(seq 0 7); do
/userfs/bin/ifc add vip pbit $pbit
done
if [ -x /userfs/bin/blapi_cmd ]; then
echo 1 > /proc/ifc_send_to_ppe
for tc in $(seq 0 7); do
if [ -s "/tmp/qos/dscp_values_${tc}_4" ]; then
sort -un "/tmp/qos/dscp_values_${tc}_4" | awk 'NR==1{first=$1;last=$1;next}
$1 == last+1 {last=$1;next}
{system("/userfs/bin/blapi_cmd traffic set_traffic_class DSCP " first*4 " " or(last*4, 0x3) " 1");first=$1;last=first}
END{system("/userfs/bin/blapi_cmd traffic set_traffic_class DSCP " first*4 " " or(last*4, 0x3) " 1")}'
fi
if [ -s "/tmp/qos/dscp_values_${tc}_6" ]; then
[ -s "/tmp/qos/dscp_values_${tc}_4" ] && sort -un "/tmp/qos/dscp_values_${tc}_6" | awk 'NR==1{first=$1;last=$1;next}
$1 == last+1 {last=$1;next}
{system("/userfs/bin/blapi_cmd traffic set_traffic_class DSCP " first*4 " " or(last*4, 0x3) " 0");first=$1;last=first}
END{system("/userfs/bin/blapi_cmd traffic set_traffic_class DSCP " first*4 " " or(last*4, 0x3) " 0")}'
sort -un "/tmp/qos/dscp_values_${tc}_6" | awk 'NR==1{first=$1;last=$1;next}
$1 == last+1 {last=$1;next}
{system("/userfs/bin/blapi_cmd traffic set_traffic_class DSCP " first*4 " " or(last*4, 0x3) " 1");first=$1;last=first}
END{system("/userfs/bin/blapi_cmd traffic set_traffic_class DSCP " first*4 " " or(last*4, 0x3) " 1")}'
fi
done
fi
if [ -x /userfs/bin/ifc ]; then
echo 1 > /proc/ifc_send_to_ppe
for pbit in $(seq 0 7); do
/userfs/bin/ifc add vip pbit $pbit
done
fi
}

View file

@ -26,6 +26,7 @@ broute_ipv4_rule_options()
config_get protocol "$cid" "proto"
config_get dscp_filter "$cid" "dscp_filter"
config_get icmp_type "$cid" "icmp_type"
config_get traffic_class "$cid" "traffic_class"
set_ip_addr "$cid" ebt_match_src_ip ebt_match_dst_ip
@ -36,6 +37,7 @@ broute_ipv4_rule_options()
tos_val=$((dscp_filter<<2))
tos_hex=$(printf "%x" $tos_val)
broute_filter_on_dscp "$tos_hex"
[ -n "$traffic_class" -a "$dscp_filter" != "0" ] && echo "$((dscp_filter))" >> "/tmp/qos/dscp_values_${traffic_class}_4"
fi
if [ -n "$protocol" ]; then
@ -57,6 +59,7 @@ broute_ipv6_rule_options()
config_get protocol "$cid" "proto"
config_get dscp_filter "$cid" "dscp_filter"
config_get icmp_type "$cid" "icmp_type"
config_get traffic_class "$cid" "traffic_class"
set_ip_addr "$cid" ebt_match_ipv6_src_ip ebt_match_ipv6_dst_ip
@ -67,6 +70,7 @@ broute_ipv6_rule_options()
tos_val=$((dscp_filter<<2))
tos_hex=$(printf "%x" $tos_val)
ebt_match_ipv6_dscp "$tos_hex"
[ -n "$traffic_class" -a "$dscp_filter" != "0" ] && echo "$((dscp_filter))" >> "/tmp/qos/dscp_values_${traffic_class}_6"
fi
if [ -n "$protocol" ]; then