summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/systemd/systemd/0001-networkd-fix-link-up.patch
blob: 4c7a0a33a3599a1fcee5cb6dd6190e180356fe40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
From 6bd76d2d4ff130decd3aa13e0c2dbfd56ff8d7b7 Mon Sep 17 00:00:00 2001
From: Susant Sahani <ssahani@gmail.com>
Date: Thu, 9 May 2019 07:35:35 +0530
Subject: [PATCH] networkd: fix link_up() (#12505)

Fillup IFLA_INET6_ADDR_GEN_MODE while we do link_up.

Fixes the following error:
```
dummy-test: Could not bring up interface: Invalid argument
```

After reading the kernel code when we do a link up
```
net/core/rtnetlink.c
IFLA_AF_SPEC
 af_ops->set_link_af(dev, af);
  inet6_set_link_af
   if (tb[IFLA_INET6_ADDR_GEN_MODE])
             Here it looks for IFLA_INET6_ADDR_GEN_MODE
```
Since link up we didn't filling up that it's failing.

Closes #12504.

Signed-off-by: Ricardo Ribalda Delgado <ricardo@ribalda.com>

Upstream-Status: Backport [https://github.com/systemd/systemd/commit/4eb086a38712ea98faf41e075b84555b11b54362.patch]

---
 src/network/networkd-link.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index e466b96792..042496173c 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -2034,6 +2034,8 @@ static int link_up(Link *link) {
         }
 
         if (link_ipv6_enabled(link)) {
+                uint8_t ipv6ll_mode;
+
                 r = sd_netlink_message_open_container(req, IFLA_AF_SPEC);
                 if (r < 0)
                         return log_link_error_errno(link, r, "Could not open IFLA_AF_SPEC container: %m");
@@ -2049,6 +2051,19 @@ static int link_up(Link *link) {
                                 return log_link_error_errno(link, r, "Could not append IFLA_INET6_TOKEN: %m");
                 }
 
+                if (!link_ipv6ll_enabled(link))
+                        ipv6ll_mode = IN6_ADDR_GEN_MODE_NONE;
+                else if (sysctl_read_ip_property(AF_INET6, link->ifname, "stable_secret", NULL) < 0)
+                        /* The file may not exist. And event if it exists, when stable_secret is unset,
+                         * reading the file fails with EIO. */
+                        ipv6ll_mode = IN6_ADDR_GEN_MODE_EUI64;
+                else
+                        ipv6ll_mode = IN6_ADDR_GEN_MODE_STABLE_PRIVACY;
+
+                r = sd_netlink_message_append_u8(req, IFLA_INET6_ADDR_GEN_MODE, ipv6ll_mode);
+                if (r < 0)
+                        return log_link_error_errno(link, r, "Could not append IFLA_INET6_ADDR_GEN_MODE: %m");
+
                 r = sd_netlink_message_close_container(req);
                 if (r < 0)
                         return log_link_error_errno(link, r, "Could not close AF_INET6 container: %m");