Commit Graph

72 Commits

Author SHA1 Message Date
Asbjørn Sloth Tønnesen
3064a44c69 testsuite: refactor kernel config search
Signed-off-by: Asbjørn Sloth Tønnesen <asbjorn@asbjorn.st>
2017-02-17 15:26:30 -08:00
Phil Sutter
3cef95926b testsuite: Search kernel config in modules dir also
At least in Fedora there is no /proc/config.gz but instead
/lib/modules/`uname -r`/config, so use that as a fallback.

Signed-off-by: Phil Sutter <phil@nwl.cc>
2017-02-09 17:28:48 -08:00
Phil Sutter
886f2c43b5 testsuite: Generate nlmsg blob at runtime
Since netlink messages are in host byte order, shipping a pre-generated
nlmsg blob won't suffice on systems with different endianness. Therefore
generate the blob at runtime, so it's content fits the hosts endianness.

Note that the generated message will contain only a single interface
featuring two VFs instead of the full list before. Yet this is
sufficient, as it triggers the crash with iproute versions prior to
commit 8c29ae7cc2 ("ip link: Fix crash on older kernels when show VF
dev").

Signed-off-by: Phil Sutter <phil@nwl.cc>
2017-02-09 17:28:48 -08:00
Anton Aksola
e29a8e0537 iproute2: build nsid-name cache only for commands that need it
The calling of netns_map_init() before command parsing introduced
a performance issue with large number of namespaces.

As commands such as add, del and exec do not need to iterate through
/var/run/netns it would be good not no build the cache before executing
these commands.

Example:
unpatched:
time seq 1 1000 | xargs -n 1 ip netns add

real    0m16.832s
user    0m1.350s
sys    0m15.029s

patched:
time seq 1 1000 | xargs -n 1 ip netns add

real    0m3.859s
user    0m0.132s
sys    0m3.205s

Signed-off-by: Anton Aksola <aakso@iki.fi>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
2016-10-09 18:56:47 -07:00
Phil Sutter
3c48c714a3 testsuite: add a test for tc pedit action
This is not a full test, since kernel functionality is not actually
tested. It only compares that the kernel returned values when listing
the action are what one expects them to be.

Since this test succeeded on both a little-endian and a big-endian
system, it shows that any endianness issues have been resolved in
tc/p_ip.c at least.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2016-03-27 10:34:38 -07:00
Konstantin Shemyak
cc9c1dfaee ip_tunnel: determine tunnel address family from the tunnel type
On 24.11.2015 02:26, Stephen Hemminger wrote:
> On Thu, 12 Nov 2015 21:10:08 +0000
> Konstantin Shemyak <konstantin@shemyak.com> wrote:
>
>> When creating an IP tunnel over IPv6, the address family must be passed in
>> the option, e.g.
>>
>> ip -6 tunnel add mode ip6gre local 1::1 remote 2::2
>>
>> This makes it impossible to create both IPv4 and IPv6 tunnels in one batch.
>>
>> In fact the address family option is redundant here, as each tunnel mode is
>> relevant for only one address family.
>> The patch determines whether the applicable address family is AF_INET6
>> instead of the default AF_INET and makes the "-6" option unnecessary for
>> "ip tunnel add".
>>
>> Signed-off-by: Konstantin Shemyak <konstantin@shemyak.com>
>> ---
>>   ip/iptunnel.c                          | 26 ++++++++++++++++++++++++++
>>   testsuite/tests/ip/tunnel/add_tunnel.t | 14 ++++++++++++++
>>   2 files changed, 40 insertions(+)
>>   create mode 100755 testsuite/tests/ip/tunnel/add_tunnel.t
>>
>> diff --git a/ip/iptunnel.c b/ip/iptunnel.c
>> index 78fa988..7826a37 100644
>> --- a/ip/iptunnel.c
>> +++ b/ip/iptunnel.c
>> @@ -629,8 +629,34 @@ static int do_6rd(int argc, char **argv)
>>          return tnl_6rd_ioctl(cmd, medium, &ip6rd);
>>   }
>>
>> +static int tunnel_mode_is_ipv6(char *tunnel_mode) {
>> +       char *ipv6_modes[] = {
>> +               "ipv6/ipv6", "ip6ip6",
>> +               "vti6",
>> +               "ip/ipv6", "ipv4/ipv6", "ipip6", "ip4ip6",
>> +               "ip6gre", "gre/ipv6",
>> +               "any/ipv6", "any"
>> +       };
>> +       int i;
>> +
>> +       for (i = 0; i < sizeof(ipv6_modes) / sizeof(char *); i++) {
>> +               if (strcmp(ipv6_modes[i], tunnel_mode) == 0)
>> +                       return 1;
>> +       }
>> +       return 0;
>> +}
>> +
>
> The ipv6_modes table should be static const.

Thank you for the note! attached the corrected patch.

> Also is it possible to use strstr for ipv6 and ip6 or even strchr(tunnel_mode, '6')
> to simplify this?

There is IPv6 tunnel mode 'any', and IPv4 tunnel mode 'ipv6/ip' (aka
'sit'). It looks to me that attempts to find some substring match
would not make the code much shorter, but definitely less readable.

Konstantin Shemyak.

>From 42d27db0055c3a114fe6eb86d680bef9ec098ad4 Mon Sep 17 00:00:00 2001
From: Konstantin Shemyak <konstantin@shemyak.com>
Date: Thu, 12 Nov 2015 20:52:02 +0200
Subject: [PATCH] Tunnel address family is determined from the tunnel mode

When the tunnel mode already tells the IP address family, "ip tunnel"
command determines it and does not require option "-4"/"-6" to be passed.

This makes possible creating both IPv4 and IPv6 tunnels in one batch.

Signed-off-by: Konstantin Shemyak <konstantin@shemyak.com>
2015-11-29 11:57:21 -08:00
Vadim Kochan
30383b074d tests: Add output testing
Added possibility to check command output by grep from the testing
script.

Now TMP_OUT & TMP_ERR are passed from Makefile and changed to
STD_ERR & STD_OUT.

Also changed some existing tests to make output testing.

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2015-06-24 23:37:26 -04:00
Vadim Kochan
fede6dd9b3 tests: Add test for 'ip route add default'
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2015-05-21 14:45:21 -07:00
Vadim Kochan
64dedc4739 tests: Run each test in network namespace
Changed to forcely running each test in network
namespace to do not affect on current network setup.

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2015-05-21 14:45:17 -07:00
Vadim Kochan
4cec9db0b4 tests: Add few 'ip link' related tests
Added two tests which checks the following fixed issues:

    1) Bug when not possible add new virtual interface via:

        $ ip link add dev XXX type

       It was fixed a few releases ago.

    2) Crash on older kernels when VF rate info does not exist:

        $ ip link show

       Used dump file from William Dauchy <william@gandi.net>:
           testsuite/tests/ip/link/dev_wo_vf_rate.nl

       So 'ip link show' replaced by 'ip -d monitor file ...' which does
       the same thing.

Also added new func in testsuite/lib/generic.sh to gen new random dev name.

Added 'clean' dependency on running all tests.

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2015-02-05 10:16:25 -08:00
vadimk
18f39a3a02 tests: Move tc related tests to testsuite/tests/tc folder
With this change the results of tc tests will be recorded under:

    testsuite/results/tc/

The ip related tests can be added under:

    testsuite/tests/ip

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2014-11-29 11:17:11 -08:00
vadimk
14f8854fa3 tests: Allow to run tests recursively
Such approach allows to run *.t scripts from any
tests/ subdirectories.

One point is that tests from tests/cls/*.t (which are needed
by tests/cls-testbed.t but does not exist yet) will also
be ran aside with tests/cls-testbed.t which is not good
because in such case they will be ran twice, so renamed these
tests path to tests/cls/*.c in tests/cls-testbed.t

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2014-10-29 22:26:59 -07:00
vadimk
8d391512b7 tests: Skip cls-testbed.t if tests/cls dir does not exist
Curently tests/cls-testbed.t tries to run any *.t in
tests/cls/ folder but such folder does not exist.

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2014-10-29 22:26:57 -07:00
vadimk
f29543125f tests: Check existing of /proc/config.gz before use it
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2014-10-09 08:29:39 -07:00
vadimk
ae0d90737c tests: Allow policer test to be ran
Renamed testsuite/tests/policer to testsuite/tests/policer.t

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2014-10-09 08:24:01 -07:00
vadimk
9ecff68d11 tests: Fix problem with test running
Tests were not allowed to be ran, the following
issues were fixed:
    - creating the results folder before test running
    - sudo $PREFIX moved before variables definition which
        allow to pass them through the sudo to test script.

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2014-09-29 08:51:51 -07:00
Stephen Hemminger
03b26ef4e8 Fix modes of test files
Signed-off-by: Jesper Dangaard Brouer <hawk@comx.dk>
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-09-05 12:00:01 +01:00
shemminger
c515871c8a More missing files. 2005-06-23 20:37:43 +00:00
shemminger
8a5b1a8c04 New files in testsuite update (damn CVS) 2005-06-23 20:31:37 +00:00
shemminger
150a5bc3a9 Test suite update from Thomas Graf 2005-06-23 20:18:38 +00:00
net[shemminger]!shemminger
82af531582 Import patch iproute2.112
(Logical change 1.114)
2005-01-17 23:27:05 +00:00
net[shemminger]!shemminger
3e1d2ea6ab Initial revision 2005-01-17 23:26:23 +00:00