[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <16d46687-999c-4e46-9a76-9895779018c6@davidwei.uk>
Date: Mon, 12 Feb 2024 09:20:03 -0800
From: David Wei <dw@...idwei.uk>
To: Maciek Machnikowski <maciek@...hnikowski.net>,
Jakub Kicinski <kuba@...nel.org>, Jiri Pirko <jiri@...nulli.us>,
Sabrina Dubroca <sd@...asysnail.net>, netdev@...r.kernel.org
Cc: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>
Subject: Re: [PATCH net-next v9 3/3] netdevsim: add selftest for forwarding
skb between connected ports
On 2024-02-10 10:53, Maciek Machnikowski wrote:
>
>
> On 10/02/2024 09:48, Maciek Machnikowski wrote:
>>
>> On 10/02/2024 01:32, David Wei wrote:
>>> +###
>>> +### Code start
>>> +###
>>> +
>>> +modprobe netdevsim
>>> +
>>> +# linking
>>> +
>>> +echo $NSIM_DEV_1_ID > $NSIM_DEV_SYS_NEW
>>> +echo $NSIM_DEV_2_ID > $NSIM_DEV_SYS_NEW
>>> +
>>> +setup_ns
>>> +
>>> +NSIM_DEV_1_FD=$((RANDOM % 1024))
>>> +exec {NSIM_DEV_1_FD}</var/run/netns/nssv
>>> +NSIM_DEV_1_IFIDX=$(ip netns exec nssv cat /sys/class/net/$NSIM_DEV_1_NAME/ifindex)
>>> +
>>> +NSIM_DEV_2_FD=$((RANDOM % 1024))
>>> +exec {NSIM_DEV_2_FD}</var/run/netns/nscl
>>> +NSIM_DEV_2_IFIDX=$(ip netns exec nscl cat /sys/class/net/$NSIM_DEV_2_NAME/ifindex)
> Can we change these to:
> NSIM_DEV_1_FD=$((256+(RANDOM % 256)))
> NSIM_DEV_2_FD=$((512+(RANDOM % 256)))
>
> to prevent a 1/1024 chance of drawing the same indexes?
Yes, that is a good idea, thank you.
>
>>> +
>>> +echo "$NSIM_DEV_1_FD:$NSIM_DEV_1_IFIDX $NSIM_DEV_2_FD:2000" > $NSIM_DEV_SYS_LINK 2>/dev/null
>>> +if [ $? -eq 0 ]; then
>>> + echo "linking with non-existent netdevsim should fail"
>>> + exit 1
>>> +fi
>>> +
>>> +echo "$NSIM_DEV_1_FD:$NSIM_DEV_1_IFIDX 2000:$NSIM_DEV_2_IFIDX" > $NSIM_DEV_SYS_LINK 2>/dev/null
>>> +if [ $? -eq 0 ]; then
>>> + echo "linking with non-existent netnsid should fail"
>>> + exit 1
>>> +fi
>>> +
>>> +echo "$NSIM_DEV_1_FD:$NSIM_DEV_1_IFIDX $NSIM_DEV_1_FD:$NSIM_DEV_1_IFIDX" > $NSIM_DEV_SYS_LINK 2>/dev/null
>>> +if [ $? -eq 0 ]; then
>>> + echo "linking with self should fail"
>>> + exit 1
>>> +fi
>>> +
>>> +echo "$NSIM_DEV_1_FD:$NSIM_DEV_1_IFIDX $NSIM_DEV_2_FD:$NSIM_DEV_2_IFIDX" > $NSIM_DEV_SYS_LINK
>>> +if [ $? -ne 0 ]; then
>>> + echo "linking netdevsim1 with netdevsim2 should succeed"
>>> + exit 1
>>> +fi
>>> +
>>> +# argument error checking
>>> +
>>> +echo "$NSIM_DEV_1_FD:$NSIM_DEV_1_IFIDX $NSIM_DEV_2_FD:a" > $NSIM_DEV_SYS_LINK 2>/dev/null
>>> +if [ $? -eq 0 ]; then
>>> + echo "invalid arg should fail"
>>> + exit 1
>>> +fi
>>> +
>>> +# send/recv packets
>>> +
>>> +socat_check || exit 4
>>
>> This check will cause the script to exit without cleaning up the devices
>> and namespaces. Move it to the top, or cleanup on error
>>
>> Thanks,
>> Maciek
>>
Powered by blists - more mailing lists