public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
blob b2aafc2c55bc24b389d95067db16713a4dbbb41d 2041 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
 
#! /usr/bin/env avocado-runner-avocado-classless

# SPDX-License-Identifier: GPL-2.0-or-later
#
# Copyright Red Hat
# Author: David Gibson <david@gibson.dropbear.id.au>

"""
Test A Simple Socket Transport

meta/veth.py - Test various veth configurations
"""

import contextlib
import ipaddress

from avocado_classless.test import assert_eq, assert_eq_unordered, test

from tasst.nstool import unshare_site
from tasst.transfer import test_transfers
from tasst.address import IpiAllocator


@contextlib.contextmanager
def unconfigured_veth():
    with unshare_site('ns1', '-Un') as ns1:
        with unshare_site('ns2', '-n', parent=ns1, sudo=True) as ns2:
            ns1.veth('veth1', 'veth2', ns2)
            yield (ns1, ns2)


@test
def test_ifs():
    with unconfigured_veth() as (ns1, ns2):
        assert_eq_unordered(ns1.ifs(), ['lo', 'veth1'])
        assert_eq_unordered(ns2.ifs(), ['lo', 'veth2'])


@test
def test_mtu():
    with unconfigured_veth() as (ns1, ns2):
        assert_eq(ns1.mtu('veth1'), 1500)
        assert_eq(ns2.mtu('veth2'), 1500)


@test
def test_slaac(dad=None):
    TESTMAC = '02:aa:bb:cc:dd:ee'
    TESTIP = ipaddress.ip_interface('fe80::aa:bbff:fecc:ddee/64')

    with unconfigured_veth() as (ns1, ns2):
        ns1.fg(f'ip link set dev veth1 address {TESTMAC}', sudo=True)

        ns1.ifup('veth1', dad=dad)
        ns2.ifup('veth2')

        addrs = ns1.addr_wait('veth1', family='inet6', scope='link')
        assert_eq(addrs, [TESTIP])


@test
def test_optimistic_dad():
    test_slaac(dad='optimistic')


@test
def test_no_dad():
    test_slaac(dad='disable')


ipa = IpiAllocator()
NS1_IP4, NS1_IP6 = ipa.next_ipis()
NS2_IP4, NS2_IP6 = ipa.next_ipis()


@test_transfers(ip4=NS2_IP4.ip, ip6=NS2_IP6.ip, port=10000)
@contextlib.contextmanager
def configured_veth():
    with unconfigured_veth() as (ns1, ns2):
        ns1.ifup('lo')
        ns1.ifup('veth1', NS1_IP4, NS1_IP6, dad='disable')

        ns2.ifup('lo')
        ns2.ifup('veth2', NS2_IP4, NS2_IP6, dad='disable')

        yield (ns1, ns2)

debug log:

solving b2aafc2c ...
found b2aafc2c in https://archives.passt.top/passt-dev/20230627025429.2209702-23-david@gibson.dropbear.id.au/
found cedcf059 in https://archives.passt.top/passt-dev/20230627025429.2209702-20-david@gibson.dropbear.id.au/
found 053bd9c8 in https://archives.passt.top/passt-dev/20230627025429.2209702-19-david@gibson.dropbear.id.au/
found 9cef6271 in https://archives.passt.top/passt-dev/20230627025429.2209702-18-david@gibson.dropbear.id.au/

applying [1/4] https://archives.passt.top/passt-dev/20230627025429.2209702-18-david@gibson.dropbear.id.au/
diff --git a/test/tasst/meta/veth.py b/test/tasst/meta/veth.py
new file mode 100644
index 00000000..9cef6271


applying [2/4] https://archives.passt.top/passt-dev/20230627025429.2209702-19-david@gibson.dropbear.id.au/
diff --git a/test/tasst/meta/veth.py b/test/tasst/meta/veth.py
index 9cef6271..053bd9c8 100644


applying [3/4] https://archives.passt.top/passt-dev/20230627025429.2209702-20-david@gibson.dropbear.id.au/
diff --git a/test/tasst/meta/veth.py b/test/tasst/meta/veth.py
index 053bd9c8..cedcf059 100644


applying [4/4] https://archives.passt.top/passt-dev/20230627025429.2209702-23-david@gibson.dropbear.id.au/
diff --git a/test/tasst/meta/veth.py b/test/tasst/meta/veth.py
index cedcf059..b2aafc2c 100644

Checking patch test/tasst/meta/veth.py...
Applied patch test/tasst/meta/veth.py cleanly.
Checking patch test/tasst/meta/veth.py...
Applied patch test/tasst/meta/veth.py cleanly.
Checking patch test/tasst/meta/veth.py...
Applied patch test/tasst/meta/veth.py cleanly.
Checking patch test/tasst/meta/veth.py...
Applied patch test/tasst/meta/veth.py cleanly.

index at:
100644 b2aafc2c55bc24b389d95067db16713a4dbbb41d	test/tasst/meta/veth.py

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).