diff options
| author | Denys Fedoryshchenko <denys.f@collabora.com> | 2026-09-11 13:35:38 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-11 13:35:38 +0300 |
| commit | 1ecdecbf7f31b2bfdd6f0c55a777e71cd3dcf37b (patch) | |
| tree | 7c23acdd32420b98254a59592ad066eefa09d3f9 /tests/common/veth.py | |
| parent | a4f1102782889367d51c8b298269b232caac1db3 (diff) | |
| parent | 1c7856294d9eeb138a8e4b2d80fc2f48033a6de1 (diff) | |
| download | accel-ppp-1ecdecbf7f31b2bfdd6f0c55a777e71cd3dcf37b.tar.gz accel-ppp-1ecdecbf7f31b2bfdd6f0c55a777e71cd3dcf37b.zip | |
Merge pull request #364 from nuclearcat/tests/veth-fixed-mac
tests: give the veth pair fixed MAC addresses
Diffstat (limited to 'tests/common/veth.py')
| -rw-r--r-- | tests/common/veth.py | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/tests/common/veth.py b/tests/common/veth.py index c9d3006c..9d51ab7a 100644 --- a/tests/common/veth.py +++ b/tests/common/veth.py @@ -2,11 +2,16 @@ from common import process, netns, vlan, iface import time import math -# creates veth pair. if ok returns 0 -def create_pair(name_a, name_b): - veth, out, err = process.run( - ["ip", "link", "add", name_a, "type", "veth", "peer", "name", name_b] - ) +# creates veth pair, optionally with fixed hardware addresses. if ok returns 0 +def create_pair(name_a, name_b, mac_a=None, mac_b=None): + command = ["ip", "link", "add", name_a] + if mac_a: + command += ["address", mac_a] + command += ["type", "veth", "peer", "name", name_b] + if mac_b: + command += ["address", mac_b] + + veth, out, err = process.run(command) print("veth.create: exit=%d out=%s err=%s" % (veth, out, err)) return veth @@ -32,7 +37,16 @@ def create_veth_pair_netns(veth_pair_vlans_config): veth_a = "A" + name veth_b = "B" + name - pair_status = create_pair(veth_a, veth_b) + + # fixed addresses: a veth pair created without them gets random ones, which + # systemd-udevd may replace right after creation (MACAddressPolicy in its + # .link rules). accel-pppd reads the address of the interface it serves once + # at startup, so when udev wins that race the daemon advertises an address + # the interface no longer has and the session never passes a frame. + # See https://github.com/accel-ppp/accel-ppp/issues/363 + num = int(name) + mac = "02:00:%02x:%02x:%02x:" % ((num >> 16) & 0xFF, (num >> 8) & 0xFF, num & 0xFF) + pair_status = create_pair(veth_a, veth_b, mac + "0a", mac + "0b") print("create_veth_pair_netns: pair_status=%d" % pair_status) iface.up(veth_a, None) |
