Re: [PATCH net 7/7] selftests: net: test for lwtunnel dst ref loops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/11/25 3:12 PM, Justin Iurman wrote:
> diff --git a/tools/testing/selftests/net/config b/tools/testing/selftests/net/config
> index 5b9baf708950..61e5116987f3 100644
> --- a/tools/testing/selftests/net/config
> +++ b/tools/testing/selftests/net/config
> @@ -107,3 +107,5 @@ CONFIG_XFRM_INTERFACE=m
>  CONFIG_XFRM_USER=m
>  CONFIG_IP_NF_MATCH_RPFILTER=m
>  CONFIG_IP6_NF_MATCH_RPFILTER=m
> +CONFIG_IPV6_ILA=m
> +CONFIG_IPV6_RPL_LWTUNNEL=y
> diff --git a/tools/testing/selftests/net/lwt_dst_cache_ref_loop.sh b/tools/testing/selftests/net/lwt_dst_cache_ref_loop.sh
> new file mode 100755
> index 000000000000..9161f16154a5
> --- /dev/null
> +++ b/tools/testing/selftests/net/lwt_dst_cache_ref_loop.sh
> @@ -0,0 +1,250 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0+
> +#
> +# Author: Justin Iurman <justin.iurman@xxxxxxxxx>
> +#
> +# WARNING
> +# -------
> +# This is just a dummy script that triggers encap cases with possible dst cache
> +# reference loops in affected lwt users (see list below). Some cases are
> +# pathological configurations for simplicity, others are valid. Overall, we
> +# don't want this issue to happen, no matter what. In order to catch any
> +# reference loops, kmemleak MUST be used. The results alone are always blindly
> +# successful, don't rely on them. Note that the following tests may crash the
> +# kernel if the fix to prevent lwtunnel_{input|output|xmit}() reentry loops is
> +# not present.
> +#
> +# Affected lwt users so far (please update accordingly if needed):
> +#  - ila_lwt (output only)
> +#  - ioam6_iptunnel (output only)
> +#  - rpl_iptunnel (both input and output)
> +#  - seg6_iptunnel (both input and output)
> +
> +source lib.sh
> +
> +check_compatibility()
> +{
> +  setup_ns tmp_node &>/dev/null
> +  if [ $? != 0 ]
> +  then

We don't have formal codying stile written for shell files, but please
use tabs for indenting, and keep the 'then' keyword on the same line
with 'if'

> +    echo "SKIP: Cannot create netns."
> +    exit $ksft_skip
> +  fi
> +
> +  ip link add name veth0 netns $tmp_node type veth \
> +    peer name veth1 netns $tmp_node &>/dev/null
> +  local ret=$?
> +
> +  ip -netns $tmp_node link set veth0 up &>/dev/null
> +  ret=$((ret + $?))
> +
> +  ip -netns $tmp_node link set veth1 up &>/dev/null
> +  ret=$((ret + $?))
> +
> +  if [ $ret != 0 ]
> +  then
> +    echo "SKIP: Cannot configure links."
> +    cleanup_ns $tmp_node

If you add a:

trap cleanup EXIT

after setup, you can drop the explicit call in the various exit paths.

/P





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux