1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 16:21:26 +03:00

Merge pull request #12805 from yuwata/test-network-cleanups

test: further test-network cleanups
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-06-18 08:57:26 +02:00 committed by GitHub
commit 0ef67b7376
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 109 additions and 152 deletions

View File

@ -842,8 +842,9 @@ static int link_request_set_routing_policy_rule(Link *link) {
r = routing_policy_rule_get(link->manager, rule->family, &rule->from, rule->from_prefixlen, &rule->to,
rule->to_prefixlen, rule->tos, rule->fwmark, rule->table, rule->iif, rule->oif,
rule->protocol, &rule->sport, &rule->dport, &rrule);
if (r == 0) {
(void) routing_policy_rule_make_local(link->manager, rrule);
if (r >= 0) {
if (r == 0)
(void) routing_policy_rule_make_local(link->manager, rrule);
continue;
}

View File

@ -176,7 +176,7 @@ int routing_policy_rule_get(Manager *m,
RoutingPolicyRule rule, *existing;
assert_return(m, -1);
assert(m);
rule = (RoutingPolicyRule) {
.family = family,

View File

@ -1,6 +0,0 @@
[Match]
Name=test1
[Network]
Bond=bond199
PrimarySlave=true

View File

@ -6,6 +6,7 @@ Address=192.168.0.15/24
Gateway=192.168.0.1
IPv6AcceptRA=no
IgnoreCarrierLoss=true
ConfigureWithoutCarrier=true
[RoutingPolicyRule]
To=8.8.8.8

View File

@ -188,13 +188,15 @@ def remove_fou_ports(ports):
def remove_routing_policy_rule_tables(tables):
for table in tables:
call('ip rule del table', table, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
rc = 0
while rc == 0:
rc = call('ip rule del table', table, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
def remove_routes(routes):
for route_type, addr in routes:
call('ip route del', route_type, addr, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
def l2tp_tunnel_remove(tunnel_ids):
def remove_l2tp_tunnels(tunnel_ids):
output = check_output('ip l2tp show tunnel')
for tid in tunnel_ids:
words='Tunnel ' + tid + ', encap'
@ -263,7 +265,7 @@ def remove_log_file():
if os.path.exists(dnsmasq_log_file):
os.remove(dnsmasq_log_file)
def start_networkd(sleep_sec=5, remove_state_files=True):
def start_networkd(sleep_sec=0, remove_state_files=True):
if (remove_state_files and
os.path.exists(os.path.join(networkd_runtime_directory, 'state'))):
check_output('systemctl stop systemd-networkd')
@ -336,7 +338,7 @@ class NetworkctlTests(unittest.TestCase, Utilities):
def test_glob(self):
copy_unit_to_networkd_unit_path('11-dummy.netdev', '11-dummy.network')
start_networkd(0)
start_networkd()
wait_online(['test1:degraded'])
@ -362,7 +364,7 @@ class NetworkctlTests(unittest.TestCase, Utilities):
def test_mtu(self):
copy_unit_to_networkd_unit_path('11-dummy-mtu.netdev', '11-dummy.network')
start_networkd(0)
start_networkd()
wait_online(['test1:degraded'])
@ -373,7 +375,7 @@ class NetworkctlTests(unittest.TestCase, Utilities):
def test_udev_driver(self):
copy_unit_to_networkd_unit_path('11-dummy.netdev', '11-dummy.network',
'25-veth.netdev', 'netdev-link-local-addressing-yes.network')
start_networkd(0)
start_networkd()
wait_online(['test1:degraded', 'veth99:degraded', 'veth-peer:degraded'])
@ -389,7 +391,7 @@ class NetworkctlTests(unittest.TestCase, Utilities):
def test_delete_links(self):
copy_unit_to_networkd_unit_path('11-dummy.netdev', '11-dummy.network',
'25-veth.netdev', 'netdev-link-local-addressing-yes.network')
start_networkd(0)
start_networkd()
wait_online(['test1:degraded', 'veth99:degraded', 'veth-peer:degraded'])
@ -568,7 +570,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
def test_dropin_and_name_conflict(self):
copy_unit_to_networkd_unit_path('10-dropin-test.netdev', '15-name-conflict-test.netdev')
start_networkd(0)
start_networkd()
wait_online(['dropin-test:off'])
@ -578,7 +580,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
def test_wait_online_any(self):
copy_unit_to_networkd_unit_path('25-bridge.netdev', '25-bridge.network', '11-dummy.netdev', '11-dummy.network')
start_networkd(0)
start_networkd()
wait_online(['bridge99', 'test1:degraded'], bool_any=True)
@ -587,7 +589,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
def test_bridge(self):
copy_unit_to_networkd_unit_path('25-bridge.netdev', '25-bridge-configure-without-carrier.network')
start_networkd(0)
start_networkd()
wait_online(['bridge99:no-carrier'])
@ -603,7 +605,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
def test_bond(self):
copy_unit_to_networkd_unit_path('25-bond.netdev', '25-bond-balanced-tlb.netdev')
start_networkd(0)
start_networkd()
wait_online(['bond99:off', 'bond98:off'])
@ -625,7 +627,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
def test_vlan(self):
copy_unit_to_networkd_unit_path('21-vlan.netdev', '11-dummy.netdev',
'21-vlan.network', '21-vlan-test1.network')
start_networkd(0)
start_networkd()
wait_online(['test1:degraded', 'vlan99:routable'])
@ -660,7 +662,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
'11-dummy.netdev', 'macvtap.network')
with open(os.path.join(network_unit_file_path, '21-macvtap.netdev'), mode='a') as f:
f.write('[MACVTAP]\nMode=' + mode)
start_networkd(0)
start_networkd()
wait_online(['macvtap99:degraded', 'test1:degraded'])
@ -677,7 +679,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
'11-dummy.netdev', 'macvlan.network')
with open(os.path.join(network_unit_file_path, '21-macvlan.netdev'), mode='a') as f:
f.write('[MACVLAN]\nMode=' + mode)
start_networkd(0)
start_networkd()
wait_online(['macvlan99:degraded', 'test1:degraded'])
@ -701,7 +703,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
with open(os.path.join(network_unit_file_path, '25-ipvlan.netdev'), mode='a') as f:
f.write('[IPVLAN]\nMode=' + mode + '\nFlags=' + flag)
start_networkd(0)
start_networkd()
wait_online(['ipvlan99:degraded', 'test1:degraded'])
output = check_output('ip -d link show ipvlan99')
@ -719,7 +721,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
with open(os.path.join(network_unit_file_path, '25-ipvtap.netdev'), mode='a') as f:
f.write('[IPVTAP]\nMode=' + mode + '\nFlags=' + flag)
start_networkd(0)
start_networkd()
wait_online(['ipvtap99:degraded', 'test1:degraded'])
output = check_output('ip -d link show ipvtap99')
@ -728,7 +730,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
def test_veth(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'netdev-link-local-addressing-yes.network')
start_networkd(0)
start_networkd()
wait_online(['veth99:degraded', 'veth-peer:degraded'])
@ -741,7 +743,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
def test_tun(self):
copy_unit_to_networkd_unit_path('25-tun.netdev')
start_networkd(0)
start_networkd()
wait_online(['tun99:off'])
@ -752,7 +754,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
def test_tap(self):
copy_unit_to_networkd_unit_path('25-tap.netdev')
start_networkd(0)
start_networkd()
wait_online(['tap99:off'])
@ -764,21 +766,21 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
@expectedFailureIfModuleIsNotAvailable('vrf')
def test_vrf(self):
copy_unit_to_networkd_unit_path('25-vrf.netdev', 'netdev-link-local-addressing-yes.network')
start_networkd(0)
start_networkd()
wait_online(['vrf99:carrier'])
@expectedFailureIfModuleIsNotAvailable('vcan')
def test_vcan(self):
copy_unit_to_networkd_unit_path('25-vcan.netdev', 'netdev-link-local-addressing-yes.network')
start_networkd(0)
start_networkd()
wait_online(['vcan99:carrier'])
@expectedFailureIfModuleIsNotAvailable('vxcan')
def test_vxcan(self):
copy_unit_to_networkd_unit_path('25-vxcan.netdev', 'netdev-link-local-addressing-yes.network')
start_networkd(0)
start_networkd()
wait_online(['vxcan99:carrier', 'vxcan-peer:carrier'])
@ -787,7 +789,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
copy_unit_to_networkd_unit_path('25-wireguard.netdev', '25-wireguard.network',
'25-wireguard-23-peers.netdev', '25-wireguard-23-peers.network',
'25-wireguard-preshared-key.txt', '25-wireguard-private-key.txt')
start_networkd(0)
start_networkd()
wait_online(['wg99:carrier', 'wg98:routable'])
if shutil.which('wg'):
@ -815,7 +817,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
def test_geneve(self):
copy_unit_to_networkd_unit_path('25-geneve.netdev', 'netdev-link-local-addressing-yes.network')
start_networkd(0)
start_networkd()
wait_online(['geneve99:degraded'])
@ -831,7 +833,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
'25-ipip-tunnel.netdev', '25-tunnel.network',
'25-ipip-tunnel-local-any.netdev', '25-tunnel-local-any.network',
'25-ipip-tunnel-remote-any.netdev', '25-tunnel-remote-any.network')
start_networkd(0)
start_networkd()
wait_online(['ipiptun99:routable', 'ipiptun98:routable', 'ipiptun97:routable', 'dummy98:degraded'])
output = check_output('ip -d link show ipiptun99')
@ -849,7 +851,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
'25-gre-tunnel.netdev', '25-tunnel.network',
'25-gre-tunnel-local-any.netdev', '25-tunnel-local-any.network',
'25-gre-tunnel-remote-any.netdev', '25-tunnel-remote-any.network')
start_networkd(0)
start_networkd()
wait_online(['gretun99:routable', 'gretun98:routable', 'gretun97:routable', 'dummy98:degraded'])
output = check_output('ip -d link show gretun99')
@ -902,7 +904,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
copy_unit_to_networkd_unit_path('12-dummy.netdev', 'gretap.network',
'25-gretap-tunnel.netdev', '25-tunnel.network',
'25-gretap-tunnel-local-any.netdev', '25-tunnel-local-any.network')
start_networkd(0)
start_networkd()
wait_online(['gretap99:routable', 'gretap98:routable', 'dummy98:degraded'])
output = check_output('ip -d link show gretap99')
@ -924,7 +926,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
copy_unit_to_networkd_unit_path('12-dummy.netdev', 'ip6gretap.network',
'25-ip6gretap-tunnel.netdev', '25-tunnel.network',
'25-ip6gretap-tunnel-local-any.netdev', '25-tunnel-local-any.network')
start_networkd(0)
start_networkd()
wait_online(['ip6gretap99:routable', 'ip6gretap98:routable', 'dummy98:degraded'])
output = check_output('ip -d link show ip6gretap99')
@ -939,7 +941,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
'25-vti-tunnel.netdev', '25-tunnel.network',
'25-vti-tunnel-local-any.netdev', '25-tunnel-local-any.network',
'25-vti-tunnel-remote-any.netdev', '25-tunnel-remote-any.network')
start_networkd(0)
start_networkd()
wait_online(['vtitun99:routable', 'vtitun98:routable', 'vtitun97:routable', 'dummy98:degraded'])
output = check_output('ip -d link show vtitun99')
@ -957,7 +959,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
'25-vti6-tunnel.netdev', '25-tunnel.network',
'25-vti6-tunnel-local-any.netdev', '25-tunnel-local-any.network',
'25-vti6-tunnel-remote-any.netdev', '25-tunnel-remote-any.network')
start_networkd(0)
start_networkd()
wait_online(['vti6tun99:routable', 'vti6tun98:routable', 'vti6tun97:routable', 'dummy98:degraded'])
output = check_output('ip -d link show vti6tun99')
@ -975,7 +977,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
'25-ip6tnl-tunnel.netdev', '25-tunnel.network',
'25-ip6tnl-tunnel-local-any.netdev', '25-tunnel-local-any.network',
'25-ip6tnl-tunnel-remote-any.netdev', '25-tunnel-remote-any.network')
start_networkd(0)
start_networkd()
wait_online(['ip6tnl99:routable', 'ip6tnl98:routable', 'ip6tnl97:routable', 'dummy98:degraded'])
output = check_output('ip -d link show ip6tnl99')
@ -993,7 +995,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
'25-sit-tunnel.netdev', '25-tunnel.network',
'25-sit-tunnel-local-any.netdev', '25-tunnel-local-any.network',
'25-sit-tunnel-remote-any.netdev', '25-tunnel-remote-any.network')
start_networkd(0)
start_networkd()
wait_online(['sittun99:routable', 'sittun98:routable', 'sittun97:routable', 'dummy98:degraded'])
output = check_output('ip -d link show sittun99')
@ -1009,7 +1011,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
def test_isatap_tunnel(self):
copy_unit_to_networkd_unit_path('12-dummy.netdev', 'isatap.network',
'25-isatap-tunnel.netdev', '25-tunnel.network')
start_networkd(0)
start_networkd()
wait_online(['isataptun99:routable', 'dummy98:degraded'])
output = check_output('ip -d link show isataptun99')
@ -1019,7 +1021,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
def test_6rd_tunnel(self):
copy_unit_to_networkd_unit_path('12-dummy.netdev', '6rd.network',
'25-6rd-tunnel.netdev', '25-tunnel.network')
start_networkd(0)
start_networkd()
wait_online(['sittun99:routable', 'dummy98:degraded'])
output = check_output('ip -d link show sittun99')
@ -1031,7 +1033,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
copy_unit_to_networkd_unit_path('12-dummy.netdev', 'erspan.network',
'25-erspan-tunnel.netdev', '25-tunnel.network',
'25-erspan-tunnel-local-any.netdev', '25-tunnel-local-any.network')
start_networkd(0)
start_networkd()
wait_online(['erspan99:routable', 'erspan98:routable', 'dummy98:degraded'])
output = check_output('ip -d link show erspan99')
@ -1052,7 +1054,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
def test_tunnel_independent(self):
copy_unit_to_networkd_unit_path('25-ipip-tunnel-independent.netdev', 'netdev-link-local-addressing-yes.network')
start_networkd(0)
start_networkd()
wait_online(['ipiptun99:carrier'])
@ -1065,7 +1067,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
copy_unit_to_networkd_unit_path('25-fou-ipproto-ipip.netdev', '25-fou-ipproto-gre.netdev',
'25-fou-ipip.netdev', '25-fou-sit.netdev',
'25-fou-gre.netdev', '25-fou-gretap.netdev')
start_networkd(0)
start_networkd()
wait_online(['ipiptun96:off', 'sittun96:off', 'gretun96:off', 'gretap96:off'])
@ -1090,7 +1092,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
def test_vxlan(self):
copy_unit_to_networkd_unit_path('25-vxlan.netdev', 'vxlan.network',
'11-dummy.netdev', 'vxlan-test1.network')
start_networkd(0)
start_networkd()
wait_online(['test1:degraded', 'vxlan99:degraded'])
@ -1116,7 +1118,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
def test_macsec(self):
copy_unit_to_networkd_unit_path('25-macsec.netdev', '25-macsec.network', '25-macsec.key',
'macsec.network', '12-dummy.netdev')
start_networkd(0)
start_networkd()
wait_online(['dummy98:degraded', 'macsec99:routable'])
@ -1143,7 +1145,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
def test_nlmon(self):
copy_unit_to_networkd_unit_path('25-nlmon.netdev', 'netdev-link-local-addressing-yes.network')
start_networkd(0)
start_networkd()
wait_online(['nlmon99:carrier'])
@ -1165,18 +1167,18 @@ class NetworkdL2TPTests(unittest.TestCase, Utilities):
l2tp_tunnel_ids = [ '10' ]
def setUp(self):
l2tp_tunnel_remove(self.l2tp_tunnel_ids)
remove_l2tp_tunnels(self.l2tp_tunnel_ids)
remove_links(self.links)
def tearDown(self):
l2tp_tunnel_remove(self.l2tp_tunnel_ids)
remove_l2tp_tunnels(self.l2tp_tunnel_ids)
remove_links(self.links)
remove_unit_from_networkd_path(self.units)
@expectedFailureIfModuleIsNotAvailable('l2tp_eth')
def test_l2tp_udp(self):
copy_unit_to_networkd_unit_path('11-dummy.netdev', '25-l2tp-dummy.network', '25-l2tp-udp.netdev')
start_networkd(0)
start_networkd()
wait_online(['test1:routable', 'l2tp-ses1:off', 'l2tp-ses2:off'])
@ -1203,7 +1205,7 @@ class NetworkdL2TPTests(unittest.TestCase, Utilities):
@expectedFailureIfModuleIsNotAvailable('l2tp_ip')
def test_l2tp_ip(self):
copy_unit_to_networkd_unit_path('11-dummy.netdev', '25-l2tp-dummy.network', '25-l2tp-ip.netdev')
start_networkd(0)
start_networkd()
wait_online(['test1:routable', 'l2tp-ses3:off', 'l2tp-ses4:off'])
@ -1274,7 +1276,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
def test_address_static(self):
copy_unit_to_networkd_unit_path('25-address-static.network', '12-dummy.netdev')
start_networkd(0)
start_networkd()
wait_online(['dummy98:routable'])
@ -1323,7 +1325,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
def test_configure_without_carrier(self):
copy_unit_to_networkd_unit_path('configure-without-carrier.network', '11-dummy.netdev')
start_networkd(0)
start_networkd()
wait_online(['test1:routable'])
output = check_output(*networkctl_cmd, 'status', 'test1')
@ -1334,7 +1336,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
def test_routing_policy_rule(self):
copy_unit_to_networkd_unit_path('routing-policy-rule-test1.network', '11-dummy.netdev')
start_networkd(0)
start_networkd()
wait_online(['test1:degraded'])
output = check_output('ip rule')
@ -1367,7 +1369,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
@expectedFailureIfRoutingPolicyPortRangeIsNotAvailable()
def test_routing_policy_rule_port_range(self):
copy_unit_to_networkd_unit_path('25-fibrule-port-range.network', '11-dummy.netdev')
start_networkd(0)
start_networkd()
wait_online(['test1:degraded'])
output = check_output('ip rule')
@ -1382,7 +1384,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
@expectedFailureIfRoutingPolicyIPProtoIsNotAvailable()
def test_routing_policy_rule_invert(self):
copy_unit_to_networkd_unit_path('25-fibrule-invert.network', '11-dummy.netdev')
start_networkd(0)
start_networkd()
wait_online(['test1:degraded'])
output = check_output('ip rule')
@ -1394,7 +1396,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
def test_route_static(self):
copy_unit_to_networkd_unit_path('25-route-static.network', '12-dummy.netdev')
start_networkd(0)
start_networkd()
wait_online(['dummy98:routable'])
output = check_output('ip -6 route show dev dummy98')
@ -1435,7 +1437,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
# reuse a bond from an earlier test, which does make the addresses go through
# tentative state, and do our test on that
copy_unit_to_networkd_unit_path('23-active-slave.network', '25-route-ipv6-src.network', '25-bond-active-backup-slave.netdev', '12-dummy.netdev')
start_networkd(0)
start_networkd()
wait_online(['dummy98:enslaved', 'bond199:routable'])
output = check_output('ip -6 route list dev bond199')
@ -1446,7 +1448,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
def test_ip_link_mac_address(self):
copy_unit_to_networkd_unit_path('25-address-link-section.network', '12-dummy.netdev')
start_networkd(0)
start_networkd()
wait_online(['dummy98:degraded'])
output = check_output('ip link show dummy98')
@ -1463,7 +1465,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
def test_ipv6_address_label(self):
copy_unit_to_networkd_unit_path('25-ipv6-address-label-section.network', '12-dummy.netdev')
start_networkd(0)
start_networkd()
wait_online(['dummy98:degraded'])
output = check_output('ip addrlabel list')
@ -1472,7 +1474,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
def test_ipv6_neighbor(self):
copy_unit_to_networkd_unit_path('25-neighbor-section.network', '12-dummy.netdev')
start_networkd(0)
start_networkd()
wait_online(['dummy98:degraded'], timeout='40s')
output = check_output('ip neigh list dev dummy98')
@ -1483,7 +1485,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
def test_link_local_addressing(self):
copy_unit_to_networkd_unit_path('25-link-local-addressing-yes.network', '11-dummy.netdev',
'25-link-local-addressing-no.network', '12-dummy.netdev')
start_networkd(0)
start_networkd()
wait_online(['test1:degraded', 'dummy98:carrier'])
output = check_output('ip address show dev test1')
@ -1530,7 +1532,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
def test_sysctl(self):
copy_unit_to_networkd_unit_path('25-sysctl.network', '12-dummy.netdev')
start_networkd(0)
start_networkd()
wait_online(['dummy98:degraded'])
self.assertEqual(read_ipv6_sysctl_attr('dummy98', 'forwarding'), '1')
@ -1548,7 +1550,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
check_output('sysctl net.ipv6.conf.all.disable_ipv6=1')
check_output('sysctl net.ipv6.conf.default.disable_ipv6=1')
start_networkd(0)
start_networkd()
wait_online(['dummy98:routable'])
output = check_output('ip -4 address show dummy98')
@ -1570,7 +1572,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
check_output('sysctl net.ipv6.conf.all.disable_ipv6=0')
check_output('sysctl net.ipv6.conf.default.disable_ipv6=0')
start_networkd(0)
start_networkd()
wait_online(['dummy98:routable'])
output = check_output('ip -4 address show dummy98')
@ -1589,7 +1591,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
def test_bind_carrier(self):
copy_unit_to_networkd_unit_path('25-bind-carrier.network', '11-dummy.netdev')
start_networkd(0)
start_networkd()
wait_online(['test1:routable'])
check_output('ip link add dummy98 type dummy')
@ -1638,7 +1640,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
def test_domain(self):
copy_unit_to_networkd_unit_path('12-dummy.netdev', '24-search-domain.network')
start_networkd(0)
start_networkd()
wait_online(['dummy98:routable'])
output = check_output(*networkctl_cmd, 'status', 'dummy98', env=env)
@ -1661,7 +1663,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
print(output)
copy_unit_to_networkd_unit_path('24-keep-configuration-static.network')
start_networkd(0)
start_networkd()
wait_online(['dummy98:routable'])
output = check_output('ip address show dummy98')
@ -1682,7 +1684,6 @@ class NetworkdBondTests(unittest.TestCase, Utilities):
'23-active-slave.network',
'23-bond199.network',
'23-primary-slave.network',
'23-test1-bond199.network',
'25-bond-active-backup-slave.netdev',
'25-bond.netdev',
'bond99.network',
@ -1698,33 +1699,26 @@ class NetworkdBondTests(unittest.TestCase, Utilities):
def test_bond_active_slave(self):
copy_unit_to_networkd_unit_path('23-active-slave.network', '23-bond199.network', '25-bond-active-backup-slave.netdev', '12-dummy.netdev')
start_networkd()
self.check_link_exists('dummy98')
self.check_link_exists('bond199')
wait_online(['dummy98:enslaved', 'bond199:degraded'])
output = check_output('ip -d link show bond199')
print(output)
self.assertRegex(output, 'active_slave dummy98')
def test_bond_primary_slave(self):
copy_unit_to_networkd_unit_path('23-primary-slave.network', '23-test1-bond199.network', '25-bond-active-backup-slave.netdev', '11-dummy.netdev')
copy_unit_to_networkd_unit_path('23-primary-slave.network', '23-bond199.network', '25-bond-active-backup-slave.netdev', '12-dummy.netdev')
start_networkd()
self.check_link_exists('test1')
self.check_link_exists('bond199')
wait_online(['dummy98:enslaved', 'bond199:degraded'])
output = check_output('ip -d link show bond199')
print(output)
self.assertRegex(output, 'primary test1')
self.assertRegex(output, 'primary dummy98')
def test_bond_operstate(self):
copy_unit_to_networkd_unit_path('25-bond.netdev', '11-dummy.netdev', '12-dummy.netdev',
'bond99.network','bond-slave.network')
start_networkd()
self.check_link_exists('bond99')
self.check_link_exists('dummy98')
self.check_link_exists('test1')
wait_online(['dummy98:enslaved', 'test1:enslaved', 'bond99:routable'])
output = check_output('ip -d link show dummy98')
print(output)
@ -1790,10 +1784,14 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities):
'bridge99-ignore-carrier-loss.network',
'bridge99.network']
routing_policy_rule_tables = ['100']
def setUp(self):
remove_routing_policy_rule_tables(self.routing_policy_rule_tables)
remove_links(self.links)
def tearDown(self):
remove_routing_policy_rule_tables(self.routing_policy_rule_tables)
remove_links(self.links)
remove_unit_from_networkd_path(self.units)
@ -1802,10 +1800,7 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities):
'26-bridge-slave-interface-1.network', '26-bridge-slave-interface-2.network',
'bridge99.network')
start_networkd()
self.check_link_exists('dummy98')
self.check_link_exists('test1')
self.check_link_exists('bridge99')
wait_online(['dummy98:enslaved', 'test1:enslaved', 'bridge99:routable'])
output = check_output('ip -d link show test1')
print(output)
@ -1836,10 +1831,6 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities):
if (os.path.exists('/sys/devices/virtual/net/bridge00/lower_dummy98/brport/multicast_to_unicast')):
self.assertEqual(read_bridge_port_attr('bridge99', 'dummy98', 'multicast_to_unicast'), '1')
self.check_operstate('test1', 'enslaved')
self.check_operstate('dummy98', 'enslaved')
self.check_operstate('bridge99', 'routable')
check_output('ip address add 192.168.0.16/24 dev bridge99')
time.sleep(1)
@ -1847,8 +1838,6 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities):
print(output)
self.assertRegex(output, '192.168.0.16/24')
self.check_operstate('bridge99', 'routable')
self.assertEqual(call('ip link del test1'), 0)
time.sleep(3)
@ -1869,13 +1858,8 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities):
copy_unit_to_networkd_unit_path('11-dummy.netdev', '12-dummy.netdev', '26-bridge.netdev',
'26-bridge-slave-interface-1.network', '26-bridge-slave-interface-2.network',
'bridge99-ignore-carrier-loss.network')
call('ip rule del table 100')
start_networkd()
self.check_link_exists('dummy98')
self.check_link_exists('test1')
self.check_link_exists('bridge99')
wait_online(['dummy98:enslaved', 'test1:enslaved', 'bridge99:routable'])
check_output('ip address add 192.168.0.16/24 dev bridge99')
time.sleep(1)
@ -1890,40 +1874,19 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities):
self.assertRegex(output, 'inet 192.168.0.15/24 brd 192.168.0.255 scope global bridge99')
self.assertRegex(output, 'inet 192.168.0.16/24 scope global secondary bridge99')
call('ip rule del table 100')
def test_bridge_ignore_carrier_loss_frequent_loss_and_gain(self):
copy_unit_to_networkd_unit_path('26-bridge.netdev', '26-bridge-slave-interface-1.network',
'bridge99-ignore-carrier-loss.network')
call('ip rule del table 100')
start_networkd()
wait_online(['bridge99:no-carrier'])
self.check_link_exists('bridge99')
for trial in range(4):
check_output('ip link add dummy98 type dummy')
check_output('ip link set dummy98 up')
if trial < 3:
check_output('ip link del dummy98')
check_output('ip link add dummy98 type dummy')
check_output('ip link set dummy98 up')
check_output('ip link del dummy98')
check_output('ip link add dummy98 type dummy')
check_output('ip link set dummy98 up')
check_output('ip link del dummy98')
check_output('ip link add dummy98 type dummy')
check_output('ip link set dummy98 up')
check_output('ip link del dummy98')
check_output('ip link add dummy98 type dummy')
check_output('ip link set dummy98 up')
for trial in range(30):
if trial > 0:
time.sleep(1)
if get_operstate('bridge99') == 'routable' and get_operstate('dummy98') == 'enslaved':
break
else:
self.assertTrue(False)
wait_online(['bridge99:routable', 'dummy98:enslaved'])
output = check_output('ip address show bridge99')
print(output)
@ -1933,8 +1896,6 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities):
print(output)
self.assertEqual(output, '0: from all to 8.8.8.8 lookup 100')
call('ip rule del table 100')
class NetworkdLLDPTests(unittest.TestCase, Utilities):
links = ['veth99']
@ -1952,7 +1913,7 @@ class NetworkdLLDPTests(unittest.TestCase, Utilities):
def test_lldp(self):
copy_unit_to_networkd_unit_path('23-emit-lldp.network', '24-lldp.network', '25-veth.netdev')
start_networkd(0)
start_networkd()
wait_online(['veth99:degraded', 'veth-peer:degraded'])
output = check_output(*networkctl_cmd, 'lldp', env=env)
@ -1978,7 +1939,7 @@ class NetworkdRATests(unittest.TestCase, Utilities):
def test_ipv6_prefix_delegation(self):
warn_about_firewalld()
copy_unit_to_networkd_unit_path('25-veth.netdev', 'ipv6-prefix.network', 'ipv6-prefix-veth.network')
start_networkd(0)
start_networkd()
wait_online(['veth99:routable', 'veth-peer:degraded'])
output = check_output(*networkctl_cmd, 'status', 'veth99', env=env)
@ -2005,7 +1966,7 @@ class NetworkdDHCPServerTests(unittest.TestCase, Utilities):
def test_dhcp_server(self):
warn_about_firewalld()
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-client.network', 'dhcp-server.network')
start_networkd(0)
start_networkd()
wait_online(['veth99:routable', 'veth-peer:routable'])
output = check_output(*networkctl_cmd, 'status', 'veth99', env=env)
@ -2018,7 +1979,7 @@ class NetworkdDHCPServerTests(unittest.TestCase, Utilities):
def test_emit_router_timezone(self):
warn_about_firewalld()
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-client-timezone-router.network', 'dhcp-server-timezone-router.network')
start_networkd(0)
start_networkd()
wait_online(['veth99:routable', 'veth-peer:routable'])
output = check_output(*networkctl_cmd, 'status', 'veth99', env=env)
@ -2070,7 +2031,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
def test_dhcp_client_ipv6_only(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-ipv6-only.network')
start_networkd(0)
start_networkd()
wait_online(['veth-peer:carrier'])
start_dnsmasq()
wait_online(['veth99:routable', 'veth-peer:routable'])
@ -2088,7 +2049,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
def test_dhcp_client_ipv4_only(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-ipv4-only-ipv6-disabled.network')
start_networkd(0)
start_networkd()
wait_online(['veth-peer:carrier'])
start_dnsmasq()
wait_online(['veth99:routable', 'veth-peer:routable'])
@ -2101,7 +2062,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
def test_dhcp_client_ipv4_ipv6(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-ipv6-only.network',
'dhcp-client-ipv4-only.network')
start_networkd(0)
start_networkd()
wait_online(['veth-peer:carrier'])
start_dnsmasq()
wait_online(['veth99:routable', 'veth-peer:routable'])
@ -2118,7 +2079,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
def test_dhcp_client_settings(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-ipv4-dhcp-settings.network')
start_networkd(0)
start_networkd()
wait_online(['veth-peer:carrier'])
start_dnsmasq()
wait_online(['veth99:routable', 'veth-peer:routable'])
@ -2151,7 +2112,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
def test_dhcp6_client_settings_rapidcommit_true(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-ipv6-only.network')
start_networkd(0)
start_networkd()
wait_online(['veth-peer:carrier'])
start_dnsmasq()
wait_online(['veth99:routable', 'veth-peer:routable'])
@ -2163,7 +2124,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
def test_dhcp6_client_settings_rapidcommit_false(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-ipv6-rapid-commit.network')
start_networkd(0)
start_networkd()
wait_online(['veth-peer:carrier'])
start_dnsmasq()
wait_online(['veth99:routable', 'veth-peer:routable'])
@ -2175,7 +2136,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
def test_dhcp_client_settings_anonymize(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-anonymize.network')
start_networkd(0)
start_networkd()
wait_online(['veth-peer:carrier'])
start_dnsmasq()
wait_online(['veth99:routable', 'veth-peer:routable'])
@ -2186,7 +2147,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
def test_dhcp_client_listen_port(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-listen-port.network')
start_networkd(0)
start_networkd()
wait_online(['veth-peer:carrier'])
start_dnsmasq('--dhcp-alternate-port=67,5555')
wait_online(['veth99:routable', 'veth-peer:routable'])
@ -2201,7 +2162,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
def test_dhcp_route_table_id(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-v4-server-veth-peer.network', 'dhcp-client-route-table.network')
start_networkd(0)
start_networkd()
wait_online(['veth-peer:carrier'])
start_dnsmasq()
wait_online(['veth99:routable', 'veth-peer:routable'])
@ -2213,7 +2174,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
def test_dhcp_route_metric(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-v4-server-veth-peer.network', 'dhcp-client-route-metric.network')
start_networkd(0)
start_networkd()
wait_online(['veth-peer:carrier'])
start_dnsmasq()
wait_online(['veth99:routable', 'veth-peer:routable'])
@ -2224,7 +2185,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
def test_dhcp_keep_configuration_dhcp(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-v4-server-veth-peer.network', 'dhcp-client-keep-configuration-dhcp.network')
start_networkd(0)
start_networkd()
wait_online(['veth-peer:carrier'])
start_dnsmasq(lease_time='2m')
wait_online(['veth99:routable', 'veth-peer:routable'])
@ -2278,7 +2239,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
def test_dhcp_keep_configuration_dhcp_on_stop(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-v4-server-veth-peer.network', 'dhcp-client-keep-configuration-dhcp-on-stop.network')
start_networkd(0)
start_networkd()
wait_online(['veth-peer:carrier'])
start_dnsmasq(lease_time='2m')
wait_online(['veth99:routable', 'veth-peer:routable'])
@ -2294,7 +2255,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
print(output)
self.assertRegex(output, r'192.168.5.*')
start_networkd(0)
start_networkd()
wait_online(['veth-peer:routable'])
output = check_output('ip address show dev veth99 scope global')
@ -2303,7 +2264,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
def test_dhcp_client_reuse_address_as_static(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client.network')
start_networkd(0)
start_networkd()
wait_online(['veth-peer:carrier'])
start_dnsmasq()
wait_online(['veth99:routable', 'veth-peer:routable'])
@ -2346,7 +2307,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
def test_dhcp_client_vrf(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-vrf.network',
'25-vrf.netdev', '25-vrf.network')
start_networkd(0)
start_networkd()
wait_online(['veth-peer:carrier'])
start_dnsmasq()
wait_online(['veth99:routable', 'veth-peer:routable', 'vrf99:carrier'])
@ -2394,7 +2355,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
def test_dhcp_client_gateway_onlink_implicit(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network',
'dhcp-client-gateway-onlink-implicit.network')
start_networkd(0)
start_networkd()
wait_online(['veth-peer:carrier'])
start_dnsmasq()
wait_online(['veth99:routable', 'veth-peer:routable'])
@ -2413,7 +2374,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
def test_dhcp_client_with_ipv4ll_fallback_with_dhcp_server(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network',
'dhcp-client-with-ipv4ll-fallback-with-dhcp-server.network')
start_networkd(0)
start_networkd()
wait_online(['veth-peer:carrier'])
start_dnsmasq(lease_time='2m')
wait_online(['veth99:routable', 'veth-peer:routable'])
@ -2450,7 +2411,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
def test_dhcp_client_with_ipv4ll_fallback_without_dhcp_server(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network',
'dhcp-client-with-ipv4ll-fallback-without-dhcp-server.network')
start_networkd(0)
start_networkd()
wait_online(['veth99:degraded', 'veth-peer:routable'])
output = check_output('ip address show dev veth99')
@ -2468,7 +2429,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
def test_dhcp_client_route_remove_on_renew(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network',
'dhcp-client-ipv4-only-ipv6-disabled.network')
start_networkd(0)
start_networkd()
wait_online(['veth-peer:carrier'])
start_dnsmasq(ipv4_range='192.168.5.100,192.168.5.199', lease_time='2m')
wait_online(['veth99:routable', 'veth-peer:routable'])