Unverified Commit 94da7394 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files
parents f4144fbf 56a57d47
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -57,6 +57,8 @@ int mlxsw_sp_acl_tcam_init(struct mlxsw_sp *mlxsw_sp,
	tcam->max_groups = max_groups;
	tcam->max_group_size = MLXSW_CORE_RES_GET(mlxsw_sp->core,
						 ACL_MAX_GROUP_SIZE);
	tcam->max_group_size = min_t(unsigned int, tcam->max_group_size,
				     MLXSW_REG_PAGT_ACL_MAX_NUM);

	err = ops->init(mlxsw_sp, tcam->priv, tcam);
	if (err)
+55 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@
lib_dir=$(dirname $0)/../../../../net/forwarding

ALL_TESTS="single_mask_test identical_filters_test two_masks_test \
	multiple_masks_test ctcam_edge_cases_test"
	multiple_masks_test ctcam_edge_cases_test max_group_size_test"
NUM_NETIFS=2
source $lib_dir/tc_common.sh
source $lib_dir/lib.sh
@@ -324,6 +324,60 @@ ctcam_edge_cases_test()
	ctcam_no_atcam_masks_test
}

max_group_size_test()
{
	# The number of ACLs in an ACL group is limited. Once the maximum
	# number of ACLs has been reached, filters cannot be added. This test
	# verifies that when this limit is reached, insertion fails without
	# crashing.

	RET=0

	local num_acls=32
	local max_size
	local ret

	if [[ "$tcflags" != "skip_sw" ]]; then
		return 0;
	fi

	for ((i=1; i < $num_acls; i++)); do
		if [[ $(( i % 2 )) == 1 ]]; then
			tc filter add dev $h2 ingress pref $i proto ipv4 \
				flower $tcflags dst_ip 198.51.100.1/32 \
				ip_proto tcp tcp_flags 0x01/0x01 \
				action drop &> /dev/null
		else
			tc filter add dev $h2 ingress pref $i proto ipv6 \
				flower $tcflags dst_ip 2001:db8:1::1/128 \
				action drop &> /dev/null
		fi

		ret=$?
		[[ $ret -ne 0 ]] && max_size=$((i - 1)) && break
	done

	# We expect to exceed the maximum number of ACLs in a group, so that
	# insertion eventually fails. Otherwise, the test should be adjusted to
	# add more filters.
	check_fail $ret "expected to exceed number of ACLs in a group"

	for ((; i >= 1; i--)); do
		if [[ $(( i % 2 )) == 1 ]]; then
			tc filter del dev $h2 ingress pref $i proto ipv4 \
				flower $tcflags dst_ip 198.51.100.1/32 \
				ip_proto tcp tcp_flags 0x01/0x01 \
				action drop &> /dev/null
		else
			tc filter del dev $h2 ingress pref $i proto ipv6 \
				flower $tcflags dst_ip 2001:db8:1::1/128 \
				action drop &> /dev/null
		fi
	done

	log_test "max ACL group size test ($tcflags). max size $max_size"
}

setup_prepare()
{
	h1=${NETIFS[p1]}