diff mbox series

[net] selftests: hsr: Fix "File exists" errors for hsr_ping

Message ID db256340b909f8b6f8bb7f9e42dbe71c228993b6.1716280848.git.tanggeliang@kylinos.cn (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net] selftests: hsr: Fix "File exists" errors for hsr_ping | 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/ynl success Generated files up to date; no warnings/errors; no diff in generated;
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: 8 this patch: 8
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers fail 1 blamed authors not CCed: lukma@denx.de; 2 maintainers not CCed: bigeasy@linutronix.de lukma@denx.de
netdev/build_clang success Errors and warnings before: 8 this patch: 8
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: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 22 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-05-21--21-00 (tests: 1039)

Commit Message

Geliang Tang May 21, 2024, 8:49 a.m. UTC
From: Geliang Tang <tanggeliang@kylinos.cn>

The hsr_ping test reports the following errors:

 INFO: preparing interfaces for HSRv0.
 INFO: Initial validation ping.
 INFO: Longer ping test.
 INFO: Cutting one link.
 INFO: Delay the link and drop a few packages.
 INFO: All good.
 INFO: preparing interfaces for HSRv1.
 RTNETLINK answers: File exists
 RTNETLINK answers: File exists
 RTNETLINK answers: File exists
 RTNETLINK answers: File exists
 RTNETLINK answers: File exists
 RTNETLINK answers: File exists
 Error: ipv4: Address already assigned.
 Error: ipv6: address already assigned.
 Error: ipv4: Address already assigned.
 Error: ipv6: address already assigned.
 Error: ipv4: Address already assigned.
 Error: ipv6: address already assigned.
 INFO: Initial validation ping.

That is because the cleanup code for the 2nd round test before
"setup_hsr_interfaces 1" is removed incorrectly in commit 680fda4f6714
("test: hsr: Remove script code already implemented in lib.sh").

This patch fixes it by adding a new helper delete_hsr_interfaces() to
delete all interfaces before "setup_hsr_interfaces 1".

Fixes: 680fda4f6714 ("test: hsr: Remove script code already implemented in lib.sh")
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 tools/testing/selftests/net/hsr/hsr_ping.sh | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Hangbin Liu May 22, 2024, 3:05 a.m. UTC | #1
On Tue, May 21, 2024 at 04:49:44PM +0800, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> The hsr_ping test reports the following errors:
> 
>  INFO: preparing interfaces for HSRv0.
>  INFO: Initial validation ping.
>  INFO: Longer ping test.
>  INFO: Cutting one link.
>  INFO: Delay the link and drop a few packages.
>  INFO: All good.
>  INFO: preparing interfaces for HSRv1.
>  RTNETLINK answers: File exists
>  RTNETLINK answers: File exists
>  RTNETLINK answers: File exists
>  RTNETLINK answers: File exists
>  RTNETLINK answers: File exists
>  RTNETLINK answers: File exists
>  Error: ipv4: Address already assigned.
>  Error: ipv6: address already assigned.
>  Error: ipv4: Address already assigned.
>  Error: ipv6: address already assigned.
>  Error: ipv4: Address already assigned.
>  Error: ipv6: address already assigned.
>  INFO: Initial validation ping.
> 
> That is because the cleanup code for the 2nd round test before
> "setup_hsr_interfaces 1" is removed incorrectly in commit 680fda4f6714
> ("test: hsr: Remove script code already implemented in lib.sh").
> 
> This patch fixes it by adding a new helper delete_hsr_interfaces() to
> delete all interfaces before "setup_hsr_interfaces 1".
> 
> Fixes: 680fda4f6714 ("test: hsr: Remove script code already implemented in lib.sh")
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
>  tools/testing/selftests/net/hsr/hsr_ping.sh | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/tools/testing/selftests/net/hsr/hsr_ping.sh b/tools/testing/selftests/net/hsr/hsr_ping.sh
> index 790294c8af83..0be1d5f78dab 100755
> --- a/tools/testing/selftests/net/hsr/hsr_ping.sh
> +++ b/tools/testing/selftests/net/hsr/hsr_ping.sh
> @@ -166,6 +166,14 @@ setup_hsr_interfaces()
>  	ip -net "$ns3" link set hsr3 up
>  }
>  
> +delete_hsr_interfaces()
> +{
> +	echo "INFO: delete interfaces."
> +	ip -net "$ns1" link del ns1eth1
> +	ip -net "$ns1" link del ns1eth2
> +	ip -net "$ns3" link del ns3eth2
> +}
> +
>  check_prerequisites
>  setup_ns ns1 ns2 ns3
>  
> @@ -174,6 +182,8 @@ trap cleanup_all_ns EXIT
>  setup_hsr_interfaces 0
>  do_complete_ping_test
>  
> +delete_hsr_interfaces
> +

nit: you can also just re-setup the namespaces, which will delete previous ns
and create new one. e.g.

setup_ns ns1 ns2 ns3

>  setup_hsr_interfaces 1
>  do_complete_ping_test


Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
Geliang Tang May 22, 2024, 10:37 a.m. UTC | #2
On Wed, 2024-05-22 at 11:05 +0800, Hangbin Liu wrote:
> On Tue, May 21, 2024 at 04:49:44PM +0800, Geliang Tang wrote:
> > From: Geliang Tang <tanggeliang@kylinos.cn>
> > 
> > The hsr_ping test reports the following errors:
> > 
> >  INFO: preparing interfaces for HSRv0.
> >  INFO: Initial validation ping.
> >  INFO: Longer ping test.
> >  INFO: Cutting one link.
> >  INFO: Delay the link and drop a few packages.
> >  INFO: All good.
> >  INFO: preparing interfaces for HSRv1.
> >  RTNETLINK answers: File exists
> >  RTNETLINK answers: File exists
> >  RTNETLINK answers: File exists
> >  RTNETLINK answers: File exists
> >  RTNETLINK answers: File exists
> >  RTNETLINK answers: File exists
> >  Error: ipv4: Address already assigned.
> >  Error: ipv6: address already assigned.
> >  Error: ipv4: Address already assigned.
> >  Error: ipv6: address already assigned.
> >  Error: ipv4: Address already assigned.
> >  Error: ipv6: address already assigned.
> >  INFO: Initial validation ping.
> > 
> > That is because the cleanup code for the 2nd round test before
> > "setup_hsr_interfaces 1" is removed incorrectly in commit
> > 680fda4f6714
> > ("test: hsr: Remove script code already implemented in lib.sh").
> > 
> > This patch fixes it by adding a new helper delete_hsr_interfaces()
> > to
> > delete all interfaces before "setup_hsr_interfaces 1".
> > 
> > Fixes: 680fda4f6714 ("test: hsr: Remove script code already
> > implemented in lib.sh")
> > Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> > ---
> >  tools/testing/selftests/net/hsr/hsr_ping.sh | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/tools/testing/selftests/net/hsr/hsr_ping.sh
> > b/tools/testing/selftests/net/hsr/hsr_ping.sh
> > index 790294c8af83..0be1d5f78dab 100755
> > --- a/tools/testing/selftests/net/hsr/hsr_ping.sh
> > +++ b/tools/testing/selftests/net/hsr/hsr_ping.sh
> > @@ -166,6 +166,14 @@ setup_hsr_interfaces()
> >  	ip -net "$ns3" link set hsr3 up
> >  }
> >  
> > +delete_hsr_interfaces()
> > +{
> > +	echo "INFO: delete interfaces."
> > +	ip -net "$ns1" link del ns1eth1
> > +	ip -net "$ns1" link del ns1eth2
> > +	ip -net "$ns3" link del ns3eth2
> > +}
> > +
> >  check_prerequisites
> >  setup_ns ns1 ns2 ns3
> >  
> > @@ -174,6 +182,8 @@ trap cleanup_all_ns EXIT
> >  setup_hsr_interfaces 0
> >  do_complete_ping_test
> >  
> > +delete_hsr_interfaces
> > +
> 
> nit: you can also just re-setup the namespaces, which will delete
> previous ns
> and create new one. e.g.
> 
> setup_ns ns1 ns2 ns3

Thanks Hangbin, "re-setup" is much better.

> 
> >  setup_hsr_interfaces 1
> >  do_complete_ping_test
> 
> 
> Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>

I'll send a v2, with your Reviewed-by tag.

-Geliang
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/hsr/hsr_ping.sh b/tools/testing/selftests/net/hsr/hsr_ping.sh
index 790294c8af83..0be1d5f78dab 100755
--- a/tools/testing/selftests/net/hsr/hsr_ping.sh
+++ b/tools/testing/selftests/net/hsr/hsr_ping.sh
@@ -166,6 +166,14 @@  setup_hsr_interfaces()
 	ip -net "$ns3" link set hsr3 up
 }
 
+delete_hsr_interfaces()
+{
+	echo "INFO: delete interfaces."
+	ip -net "$ns1" link del ns1eth1
+	ip -net "$ns1" link del ns1eth2
+	ip -net "$ns3" link del ns3eth2
+}
+
 check_prerequisites
 setup_ns ns1 ns2 ns3
 
@@ -174,6 +182,8 @@  trap cleanup_all_ns EXIT
 setup_hsr_interfaces 0
 do_complete_ping_test
 
+delete_hsr_interfaces
+
 setup_hsr_interfaces 1
 do_complete_ping_test