All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexey Kodanev <alexey.kodanev@oracle.com>
To: ltp@lists.linux.it
Subject: [LTP] [RFC PATCH v8 07/11] lib/test_net.sh: Add function reset_ltp_netspace()
Date: Wed, 23 Aug 2017 12:39:33 +0300	[thread overview]
Message-ID: <1075a919-2403-4025-8817-e42a3f5c2113@oracle.com> (raw)
In-Reply-To: <20170822201300.h6lpprx6rcezzlmp@dell5510>

On 22.08.2017 23:13, Petr Vorel wrote:
> Hi Alexey,
>
>>> +# Force to reset netns.
>>> +reset_ltp_netspace()
>>> +{
>>> +	[ -n "$TST_USE_NETNS" ] || return
>>> +
>>> +	tst_resm TINFO "reset netns"
>>> +	ip link delete ltp_ns_veth2 2> /dev/null
>>> +	rm -f /var/run/netns/ltp_ns
>>> +	pkill ns_create
>> Hmm, if there was custom netns you would break it anyway with this
>> function and change to LTP one.
>> I guess we should leave it unsupported for route rmmod test unless we
>> figure out the right solution.
>> Also, what if we reset only ltp veth pair, i.e.:
>> reset_ltp_netspace()
>> {
>>     ...
>>     [ "$(tst_iface)" != "ltp_ns_veth2" ] || return
> Why this? I suppose it detects whether custom netns is used, but then I'd swap the
> condition to:
> 	[ "$(tst_iface)" = "ltp_ns_veth2" ] || return

Right

>
>>     ip li del ltp_ns_veth2 2>/dev/null
>> }
>> init_ltp_netspace()
>> {
>>     ...
>>     pid="$(echo $(readlink /var/run/netns/ltp_ns) | cut -f3 -d'/')"
>>     export LTP_NETNS="${LTP_NETNS:-ns_exec $pid net,mnt}"
>>     if ! ip li sh $LHOST_IFACES > /dev/null 2>&1; then
>>         ROD ip li add name ltp_ns_veth1 type veth peer name ltp_ns_veth2
> Code duplicity :-(.

Why? it is moved here from the upper if block.

>>         ROD ns_ifmove ltp_ns_veth1 $pid
>>     fi
>>     ...
>> }
> It's working for me with this patch (turn over the condition in reset_ltp_netspace(), assuming
> that custom netns would have different LHOST_IFACES, is that correct?):

I'm not sure how to handle it correctly for rmmod test right now,
may be we should TCONF on the check inside the test:

$TST_USE_NETNS -a "$(tst_iface)" != "ltp_ns_veth2"


Thanks,
Alexey

>
> +++ b/testcases/lib/test_net.sh
> @@ -44,12 +44,26 @@ init_ltp_netspace()
>  	pid="$(echo $(readlink /var/run/netns/ltp_ns) | cut -f3 -d'/')"
>  	export LTP_NETNS="${LTP_NETNS:-ns_exec $pid net,mnt}"
>  
> +	if ! ip li show $LHOST_IFACES > /dev/null 2>&1; then
> +		ROD ip li add name ltp_ns_veth1 type veth peer name ltp_ns_veth2
> +		ROD ns_ifmove ltp_ns_veth1 $pid
> +	fi
> +
>  	tst_restore_ipaddr
>  	tst_restore_ipaddr rhost
>  
>  	tst_wait_ipv6_dad
>  }
>  
> +# Force to reset netns.
> +reset_ltp_netspace()
> +{
> +	[ "$(tst_iface)" = "ltp_ns_veth2" ] || return
> +	tst_resm TINFO "reset netns"
> +	ip link delete ltp_ns_veth2 2> /dev/null
> +	init_ltp_netspace
> +}
> +



  reply	other threads:[~2017-08-23  9:39 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-18 16:44 [LTP] [RFC PATCH v8 00/11] Simplify network setup + fix some network stress tests Petr Vorel
2017-08-18 16:44 ` [LTP] [RFC PATCH v8 01/11] lib/test_net.sh: Add unused IP address helper functions Petr Vorel
2017-08-21 13:31   ` Alexey Kodanev
2017-08-22 17:18     ` Petr Vorel
2017-08-23  9:12       ` Alexey Kodanev
2017-08-18 16:44 ` [LTP] [RFC PATCH v8 02/11] network/stress: Add library helper for stress testing Petr Vorel
2017-08-18 16:44 ` [LTP] [RFC PATCH v8 03/11] network/stress: Simplify make_background_tcp_traffic usage Petr Vorel
2017-08-18 16:44 ` [LTP] [RFC PATCH v8 04/11] network/stress: Reduce the default number of cycles for various tests Petr Vorel
2017-08-18 16:44 ` [LTP] [RFC PATCH v8 05/11] lib/test_net.sh: tst_rhost_run: Add testcases/bin into PATH for SSH/RSH Petr Vorel
2017-08-21 13:42   ` Alexey Kodanev
2017-08-22 17:21     ` Petr Vorel
2017-08-18 16:44 ` [LTP] [RFC PATCH v8 06/11] network/stress: Fix and cleanup part of multicast IPv4 tests Petr Vorel
2017-08-21 13:52   ` Alexey Kodanev
2017-08-18 16:44 ` [LTP] [RFC PATCH v8 07/11] lib/test_net.sh: Add function reset_ltp_netspace() Petr Vorel
2017-08-21 15:31   ` Alexey Kodanev
2017-08-22 20:13     ` Petr Vorel
2017-08-23  9:39       ` Alexey Kodanev [this message]
2017-08-23 10:21         ` Petr Vorel
2017-08-18 16:44 ` [LTP] [RFC PATCH v8 08/11] network/stress: Fix and cleanup route IPv4 tests Petr Vorel
2017-08-22 11:46   ` Alexey Kodanev
2017-08-22 21:22     ` Petr Vorel
2017-08-23 13:17       ` Alexey Kodanev
2017-08-23 13:49         ` Petr Vorel
2017-08-23 13:34       ` Petr Vorel
2017-08-23 13:38         ` Alexey Kodanev
2017-08-23 13:57       ` Petr Vorel
2017-08-18 16:44 ` [LTP] [RFC PATCH v8 09/11] network/stress: Further enhancements for route4-rmmod Petr Vorel
2017-08-18 16:44 ` [LTP] [RFC PATCH v8 10/11] network: Add tools for setup IP related environment variables Petr Vorel
2017-08-21  6:10   ` Petr Vorel
2017-08-22 12:23   ` Alexey Kodanev
2017-08-23 10:46     ` Petr Vorel
2017-08-18 16:44 ` [LTP] [RFC PATCH v8 11/11] network: Use tools to set up IPv4 and IPv6 related variables Petr Vorel
2017-08-22 12:49   ` Alexey Kodanev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1075a919-2403-4025-8817-e42a3f5c2113@oracle.com \
    --to=alexey.kodanev@oracle.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.