]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev/net: do not manage loopback interfaces 19701/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 23 May 2021 07:59:40 +0000 (16:59 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 23 May 2021 13:58:47 +0000 (22:58 +0900)
There are nothing we can configure in udevd for loopback interfaces;
no ethertool configs can be applied, MAC address, interface name should
not be touched.

src/udev/net/link-config.c
test/test-network/systemd-networkd-tests.py

index 35923b272a843f5f19f4a2921d55141ffa0fac50..a9e263a095d38243f68c46a5abf040de1ef31cd5 100644 (file)
@@ -243,6 +243,7 @@ int link_config_get(LinkConfigContext *ctx, sd_device *device, LinkConfig **ret)
         unsigned short iftype;
         LinkConfig *link;
         const char *name;
+        unsigned flags;
         int ifindex, r;
 
         assert(ctx);
@@ -257,10 +258,14 @@ int link_config_get(LinkConfigContext *ctx, sd_device *device, LinkConfig **ret)
         if (r < 0)
                 return r;
 
-        r = rtnl_get_link_info(&ctx->rtnl, ifindex, &iftype, NULL);
+        r = rtnl_get_link_info(&ctx->rtnl, ifindex, &iftype, &flags);
         if (r < 0)
                 return r;
 
+        /* Do not configure loopback interfaces by .link files. */
+        if (flags & IFF_LOOPBACK)
+                return -ENOENT;
+
         r = ethtool_get_permanent_macaddr(&ctx->ethtool_fd, name, &permanent_mac);
         if (r < 0)
                 log_device_debug_errno(device, r, "Failed to get permanent MAC address, ignoring: %m");
index 56a22b0a44817a0ac1e62f68d8640229ffe35fd8..d6b790bc35ae96dc0fa62a76b7390f300006446a 100755 (executable)
@@ -762,7 +762,7 @@ class NetworkctlTests(unittest.TestCase, Utilities):
 
         output = check_output(*networkctl_cmd, '-n', '0', 'status', 'lo', env=env)
         print(output)
-        self.assertRegex(output, r'Link File: (/usr)?/lib/systemd/network/99-default.link')
+        self.assertRegex(output, r'Link File: n/a')
         self.assertRegex(output, r'Network File: n/a')
 
     def test_delete_links(self):