From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f196.google.com ([209.85.192.196]:40089 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932346AbeCEBWX (ORCPT ); Sun, 4 Mar 2018 20:22:23 -0500 Received: by mail-pf0-f196.google.com with SMTP id x1so4650883pfh.7 for ; Sun, 04 Mar 2018 17:22:23 -0800 (PST) Subject: Re: [PATCH net-next] selftests: forwarding: Add suppport to create veth interfaces To: Ido Schimmel Cc: netdev@vger.kernel.org References: <20180302164553.27319-1-dsahern@gmail.com> <20180304081453.GA2430@splinter> From: David Ahern Message-ID: <6dff999e-b642-1a91-a513-6f88d7886ccf@gmail.com> Date: Sun, 4 Mar 2018 18:22:43 -0700 MIME-Version: 1.0 In-Reply-To: <20180304081453.GA2430@splinter> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org List-ID: On 3/4/18 1:14 AM, Ido Schimmel wrote: > On Fri, Mar 02, 2018 at 08:45:53AM -0800, David Ahern wrote: >> For tests using veth interfaces, the test infrastructure can create >> the netdevs if they do not exist. Arguably this is a preferred approach >> since the tests require p$N and p$(N+1) to be pairs. >> >> Signed-off-by: David Ahern > > [...] > >> diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh >> index d0af52109360..2ce98c6a8c25 100644 >> --- a/tools/testing/selftests/net/forwarding/lib.sh >> +++ b/tools/testing/selftests/net/forwarding/lib.sh >> @@ -76,6 +76,39 @@ done >> ############################################################################## >> # Network interfaces configuration >> >> +create_netif_veth() >> +{ >> + local i >> + >> + for i in $(eval echo {1..$NUM_NETIFS}); do >> + j=$((i+1)) > > local j=$((i+1)) and drop a line. not sure how it drops a line but added the 'local' for j since it was missing. > >> + ip link show dev ${NETIFS[p$i]} &> /dev/null >> + if [[ $? -ne 0 ]]; then >> + ip link add ${NETIFS[p$i]} type veth peer name ${NETIFS[p$j]} > > Need to break this one. FWIW, I have this in my config: going for readability over strict line lengths. Wrapped in v2. > > $ cat ~/.vim/after/ftplugin/sh.vim > ... > highlight OverLength ctermbg=red ctermfg=white > match OverLength /\%81v.\+/ > > Cool patch! Tested on my machine. > >> + if [[ $? -ne 0 ]]; then >> + echo "Failed to create netif" >> + exit 1 >> + fi >> + fi >> + i=$j >> + done >> +} >> + >> +create_netif() >> +{ >> + case "$NETIF_TYPE" in >> + veth) create_netif_veth >> + ;; >> + *) echo "Can not create interfaces of type \'$NETIF_TYPE\'" >> + exit 1 >> + ;; >> + esac >> +} >> + >> +if [[ "$NETIF_CREATE" = "yes" ]]; then >> + create_netif >> +fi >> + >> for i in $(eval echo {1..$NUM_NETIFS}); do >> ip link show dev ${NETIFS[p$i]} &> /dev/null >> if [[ $? -ne 0 ]]; then >> -- >> 2.11.0 >>