When setting the lower-layer link up/down, the ipvlan/macvlan device synchronizes its state via netif_stacked_transfer_operstate(), which only checks the carrier state. However, setting the link down does not necessarily change the carrier state for virtual interfaces like bonding. This causes the ipvlan/macvlan state to become out of sync with the lower-layer link state. Fix this by explicitly changing the IFF_UP flag, similar to how VLAN handles it.
Before the patch: # ./rtnetlink.sh -t "kci_test_vlan kci_test_ipvlan kci_test_macvlan" PASS: vlan link state correct FAIL: ipvlan link state incorrect FAIL: macvlan link state incorrect
After the patch set: # ./rtnetlink.sh -t "kci_test_vlan kci_test_ipvlan kci_test_macvlan" PASS: vlan link state correct PASS: ipvlan link state correct PASS: macvlan link state correct
Hangbin Liu (3): ipvlan: fix NETDEV_UP/NETDEV_DOWN event handling macvlan: fix NETDEV_UP/NETDEV_DOWN event handling selftests/rtnetlink.sh: add vlan/ipvlan/macvlan link state test
drivers/net/ipvlan/ipvlan_main.c | 20 +++++++- drivers/net/macvlan.c | 20 ++++++++ tools/testing/selftests/net/rtnetlink.sh | 64 ++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 1 deletion(-)