diff mbox series

[net] selftests: net: rps_default_mask.sh: delete veth link specifically

Message ID 20230404072411.879476-1-liuhangbin@gmail.com (mailing list archive)
State Accepted
Commit 38e058cc7d245dc8034426415bee8fec16ace1bd
Delegated to: Netdev Maintainers
Headers show
Series [net] selftests: net: rps_default_mask.sh: delete veth link specifically | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 18 this patch: 18
netdev/cc_maintainers warning 4 maintainers not CCed: kuba@kernel.org shuah@kernel.org edumazet@google.com linux-kselftest@vger.kernel.org
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success net selftest script(s) already in Makefile
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 18 this patch: 18
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Hangbin Liu April 4, 2023, 7:24 a.m. UTC
When deleting the netns and recreating a new one while re-adding the
veth interface, there is a small window of time during which the old
veth interface has not yet been removed. This can cause the new addition
to fail. To resolve this issue, we can either wait for a short while to
ensure that the old veth interface is deleted, or we can specifically
remove the veth interface.

Before this patch:
  # ./rps_default_mask.sh
  empty rps_default_mask                                      [ ok ]
  changing rps_default_mask dont affect existing devices      [ ok ]
  changing rps_default_mask dont affect existing netns        [ ok ]
  changing rps_default_mask affect newly created devices      [ ok ]
  changing rps_default_mask don't affect newly child netns[II][ ok ]
  rps_default_mask is 0 by default in child netns             [ ok ]
  RTNETLINK answers: File exists
  changing rps_default_mask in child ns don't affect the main one[ ok ]
  cat: /sys/class/net/vethC11an1/queues/rx-0/rps_cpus: No such file or directory
  changing rps_default_mask in child ns affects new childns devices./rps_default_mask.sh: line 36: [: -eq: unary operator expected
  [fail] expected 1 found
  changing rps_default_mask in child ns don't affect existing devices[ ok ]

After this patch:
  # ./rps_default_mask.sh
  empty rps_default_mask                                      [ ok ]
  changing rps_default_mask dont affect existing devices      [ ok ]
  changing rps_default_mask dont affect existing netns        [ ok ]
  changing rps_default_mask affect newly created devices      [ ok ]
  changing rps_default_mask don't affect newly child netns[II][ ok ]
  rps_default_mask is 0 by default in child netns             [ ok ]
  changing rps_default_mask in child ns don't affect the main one[ ok ]
  changing rps_default_mask in child ns affects new childns devices[ ok ]
  changing rps_default_mask in child ns don't affect existing devices[ ok ]

Fixes: 3a7d84eae03b ("self-tests: more rps self tests")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 tools/testing/selftests/net/rps_default_mask.sh | 1 +
 1 file changed, 1 insertion(+)

Comments

Paolo Abeni April 4, 2023, 10:40 a.m. UTC | #1
On Tue, 2023-04-04 at 15:24 +0800, Hangbin Liu wrote:
> When deleting the netns and recreating a new one while re-adding the
> veth interface, there is a small window of time during which the old
> veth interface has not yet been removed. This can cause the new addition
> to fail. To resolve this issue, we can either wait for a short while to
> ensure that the old veth interface is deleted, or we can specifically
> remove the veth interface.
> 
> Before this patch:
>   # ./rps_default_mask.sh
>   empty rps_default_mask                                      [ ok ]
>   changing rps_default_mask dont affect existing devices      [ ok ]
>   changing rps_default_mask dont affect existing netns        [ ok ]
>   changing rps_default_mask affect newly created devices      [ ok ]
>   changing rps_default_mask don't affect newly child netns[II][ ok ]
>   rps_default_mask is 0 by default in child netns             [ ok ]
>   RTNETLINK answers: File exists
>   changing rps_default_mask in child ns don't affect the main one[ ok ]
>   cat: /sys/class/net/vethC11an1/queues/rx-0/rps_cpus: No such file or directory
>   changing rps_default_mask in child ns affects new childns devices./rps_default_mask.sh: line 36: [: -eq: unary operator expected
>   [fail] expected 1 found
>   changing rps_default_mask in child ns don't affect existing devices[ ok ]
> 
> After this patch:
>   # ./rps_default_mask.sh
>   empty rps_default_mask                                      [ ok ]
>   changing rps_default_mask dont affect existing devices      [ ok ]
>   changing rps_default_mask dont affect existing netns        [ ok ]
>   changing rps_default_mask affect newly created devices      [ ok ]
>   changing rps_default_mask don't affect newly child netns[II][ ok ]
>   rps_default_mask is 0 by default in child netns             [ ok ]
>   changing rps_default_mask in child ns don't affect the main one[ ok ]
>   changing rps_default_mask in child ns affects new childns devices[ ok ]
>   changing rps_default_mask in child ns don't affect existing devices[ ok ]
> 
> Fixes: 3a7d84eae03b ("self-tests: more rps self tests")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> ---
>  tools/testing/selftests/net/rps_default_mask.sh | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/testing/selftests/net/rps_default_mask.sh b/tools/testing/selftests/net/rps_default_mask.sh
> index 0fd0d2db3abc..a26c5624429f 100755
> --- a/tools/testing/selftests/net/rps_default_mask.sh
> +++ b/tools/testing/selftests/net/rps_default_mask.sh
> @@ -60,6 +60,7 @@ ip link set dev $VETH up
>  ip -n $NETNS link set dev $VETH up
>  chk_rps "changing rps_default_mask affect newly created devices" "" $VETH 3
>  chk_rps "changing rps_default_mask don't affect newly child netns[II]" $NETNS $VETH 0
> +ip link del dev $VETH
>  ip netns del $NETNS
>  
>  setup

LGTM, thanks!

Acked-by: Paolo Abeni <pabeni@redhat.com>
patchwork-bot+netdevbpf@kernel.org April 6, 2023, 2:10 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue,  4 Apr 2023 15:24:11 +0800 you wrote:
> When deleting the netns and recreating a new one while re-adding the
> veth interface, there is a small window of time during which the old
> veth interface has not yet been removed. This can cause the new addition
> to fail. To resolve this issue, we can either wait for a short while to
> ensure that the old veth interface is deleted, or we can specifically
> remove the veth interface.
> 
> [...]

Here is the summary with links:
  - [net] selftests: net: rps_default_mask.sh: delete veth link specifically
    https://git.kernel.org/netdev/net/c/38e058cc7d24

You are awesome, thank you!
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/rps_default_mask.sh b/tools/testing/selftests/net/rps_default_mask.sh
index 0fd0d2db3abc..a26c5624429f 100755
--- a/tools/testing/selftests/net/rps_default_mask.sh
+++ b/tools/testing/selftests/net/rps_default_mask.sh
@@ -60,6 +60,7 @@  ip link set dev $VETH up
 ip -n $NETNS link set dev $VETH up
 chk_rps "changing rps_default_mask affect newly created devices" "" $VETH 3
 chk_rps "changing rps_default_mask don't affect newly child netns[II]" $NETNS $VETH 0
+ip link del dev $VETH
 ip netns del $NETNS
 
 setup