tests: Erase IP addresses from enslaved iface
We have expected that IP adresses are preserved after the enslaved iface
is brought up, as happens on my dev setup (kernel 5.15.7). But weirdly,
CI sometimes disagrees and after the master interface is brought up, it
just deletes all the IPs of the enslaved interface.
The log looks like this. No other `iproute2` commands were done, the
interface was not under the control of systemd-networkd or
NetworkManager or something similar:
(This is not a complete log, the complete relevant part of the log is
rather long, so I have removed a lot of irrelevant entries).
09.244 [15812 main T] exec: /usr/bin/sudo /sbin/ip link set dev czechlight_br0 up
09.270 [16791 system T] Netlink update on link 'czechlight0', action CHANGE
09.270 [15812 main T] /usr/bin/sudo /sbin/ip exited
09.271 [16791 main T] Processing node update /ietf-interfaces:interfaces/interface[name='czechlight0']/oper-status -> unknown
09.271 [16791 main T] Processing node update /ietf-interfaces:interfaces/interface[name='czechlight0']/phys-address -> 02:02:02:02:02:02
09.271 [16791 main T] Processing node update /ietf-interfaces:interfaces/interface[name='czechlight0']/type -> iana-if-type:ethernetCsmacd
09.272 [16791 system T] Netlink update on link 'czechlight_br0', action CHANGE
09.272 [16791 main T] Processing node update /ietf-interfaces:interfaces/interface[name='czechlight_br0']/oper-status -> down
09.272 [16791 main T] Processing node update /ietf-interfaces:interfaces/interface[name='czechlight_br0']/phys-address -> 02:22:22:22:22:22
09.272 [16791 main T] Processing node update /ietf-interfaces:interfaces/interface[name='czechlight_br0']/type -> iana-if-type:bridge
09.440 [16791 system T] Netlink update on link 'czechlight_br0', action CHANGE
09.440 [16791 main T] Processing node update /ietf-interfaces:interfaces/interface[name='czechlight_br0']/oper-status -> up
09.440 [16791 main T] Processing node update /ietf-interfaces:interfaces/interface[name='czechlight_br0']/phys-address -> 02:22:22:22:22:22
09.440 [16791 main T] Processing node update /ietf-interfaces:interfaces/interface[name='czechlight_br0']/type -> iana-if-type:bridge
09.835 [16791 system T] Netlink update on address of link 'czechlight0', action DEL
09.835 [16791 main T] Processing node deletion /ietf-interfaces:interfaces/interface[name='czechlight0']/ietf-ip:ipv6/address[ip='::ffff:192.0.2.1']
09.836 [16791 system T] Netlink update on address of link 'czechlight0', action DEL
09.836 [16791 main T] Processing node deletion /ietf-interfaces:interfaces/interface[name='czechlight0']/ietf-ip:ipv6/address[ip='fe80::2:2ff:fe02:202']
09.840 [16791 system T] Netlink update on address of link 'czechlight0', action DEL
09.840 [16791 main T] Processing node deletion /ietf-interfaces:interfaces/interface[name='czechlight0']/ietf-ip:ipv4/address[ip='192.0.2.1']
Change-Id: Id8e5e8de4a03fd43d6c6f8a91b4bdfc94cd258a8
diff --git a/tests/sysrepo_system-ietfinterfaces-sudo.cpp b/tests/sysrepo_system-ietfinterfaces-sudo.cpp
index c520b29..450af23 100644
--- a/tests/sysrepo_system-ietfinterfaces-sudo.cpp
+++ b/tests/sysrepo_system-ietfinterfaces-sudo.cpp
@@ -190,10 +190,14 @@
REQUIRE(dataFromSysrepoNoStatistics(client, "/ietf-interfaces:interfaces/interface[name='" + IFACE_BRIDGE + "']", SR_DS_OPERATIONAL) == expectedBridge);
iproute2_exec_and_wait(WAIT, "link", "set", "dev", IFACE, "up");
- expectedIface["/ietf-ip:ipv6/address[ip='fe80::2:2ff:fe02:202']"] = "";
- expectedIface["/ietf-ip:ipv6/address[ip='fe80::2:2ff:fe02:202']/ip"] = "fe80::2:2ff:fe02:202";
- expectedIface["/ietf-ip:ipv6/address[ip='fe80::2:2ff:fe02:202']/prefix-length"] = "64";
+ iproute2_exec_and_wait(WAIT, "addr", "flush", "dev", IFACE); // sometimes, addresses are preserved even when enslaved
expectedIface["/oper-status"] = "unknown";
+ expectedIface.erase("/ietf-ip:ipv6/address[ip='::ffff:192.0.2.1']");
+ expectedIface.erase("/ietf-ip:ipv6/address[ip='::ffff:192.0.2.1']/ip");
+ expectedIface.erase("/ietf-ip:ipv6/address[ip='::ffff:192.0.2.1']/prefix-length");
+ expectedIface.erase("/ietf-ip:ipv4/address[ip='192.0.2.1']");
+ expectedIface.erase("/ietf-ip:ipv4/address[ip='192.0.2.1']/ip");
+ expectedIface.erase("/ietf-ip:ipv4/address[ip='192.0.2.1']/prefix-length");
REQUIRE(dataFromSysrepoNoStatistics(client, "/ietf-interfaces:interfaces/interface[name='" + IFACE + "']", SR_DS_OPERATIONAL) == expectedIface);
REQUIRE(dataFromSysrepoNoStatistics(client, "/ietf-interfaces:interfaces/interface[name='" + IFACE_BRIDGE + "']", SR_DS_OPERATIONAL) == expectedBridge);
@@ -216,20 +220,11 @@
REQUIRE(dataFromSysrepoNoStatistics(client, "/ietf-interfaces:interfaces/interface[name='" + IFACE_BRIDGE + "']", SR_DS_OPERATIONAL) == expectedBridge);
iproute2_exec_and_wait(WAIT, "link", "set", "dev", IFACE, "down");
- expectedIface.erase("/ietf-ip:ipv6/address[ip='::ffff:192.0.2.1']");
- expectedIface.erase("/ietf-ip:ipv6/address[ip='::ffff:192.0.2.1']/ip");
- expectedIface.erase("/ietf-ip:ipv6/address[ip='::ffff:192.0.2.1']/prefix-length");
- expectedIface.erase("/ietf-ip:ipv6/address[ip='fe80::2:2ff:fe02:202']");
- expectedIface.erase("/ietf-ip:ipv6/address[ip='fe80::2:2ff:fe02:202']/ip");
- expectedIface.erase("/ietf-ip:ipv6/address[ip='fe80::2:2ff:fe02:202']/prefix-length");
expectedIface["/oper-status"] = "down";
REQUIRE(dataFromSysrepoNoStatistics(client, "/ietf-interfaces:interfaces/interface[name='" + IFACE + "']", SR_DS_OPERATIONAL) == expectedIface);
REQUIRE(dataFromSysrepoNoStatistics(client, "/ietf-interfaces:interfaces/interface[name='" + IFACE_BRIDGE + "']", SR_DS_OPERATIONAL) == expectedBridge);
iproute2_exec_and_wait(WAIT, "link", "set", "dev", IFACE, "nomaster");
- expectedIface.erase("/ietf-ip:ipv4/address[ip='192.0.2.1']");
- expectedIface.erase("/ietf-ip:ipv4/address[ip='192.0.2.1']/ip");
- expectedIface.erase("/ietf-ip:ipv4/address[ip='192.0.2.1']/prefix-length");
expectedIface.erase("/ietf-ip:ipv4");
expectedIface.erase("/ietf-ip:ipv6/autoconf");
expectedIface.erase("/ietf-ip:ipv6");