network: fix an infinite loop
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 20 May 2021 07:14:17 +0000 (16:14 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 20 Jul 2021 15:39:16 +0000 (17:39 +0200)
Fixes #19467.

(cherry picked from commit e8f99f4e249916e12c09ee5cc9a108cba6a2b5c0)
(cherry picked from commit b234ee7859de556c272c36fc691cee4cb08f7230)

src/network/networkd-link.c

index 524bd6842a1827ef34f83a396df24eda1f95441a..85f4fa2d7f3754bf66e81e864bf86e79c6ebc8e8 100644 (file)
@@ -153,6 +153,12 @@ static void link_update_master_operstate(Link *link, NetDev *netdev) {
         if (netdev->ifindex <= 0)
                 return;
 
+        /* If an interface is self-mentioned in Bridge= or friends, then it introduces an infinite loop.
+         * FIXME: there still exits a possibility of an infinite loop when two or more interfaces
+         * mention each other in Bridge= or so. We need to detect such a loop. */
+        if (link->ifindex == netdev->ifindex)
+                return;
+
         if (link_get(link->manager, netdev->ifindex, &master) < 0)
                 return;