import systemd-239-51.el8
This commit is contained in:
parent
a004c9fb0a
commit
8292cc06c0
60
SOURCES/0637-define-newly-needed-constants.patch
Normal file
60
SOURCES/0637-define-newly-needed-constants.patch
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
From 81b23f487eeffbc0e217c4e57567cfb70842f668 Mon Sep 17 00:00:00 2001
|
||||||
|
From: David Tardon <dtardon@redhat.com>
|
||||||
|
Date: Thu, 26 Nov 2020 16:29:10 +0100
|
||||||
|
Subject: [PATCH] define newly needed constants
|
||||||
|
|
||||||
|
Related: #1850986
|
||||||
|
---
|
||||||
|
src/basic/missing.h | 23 +++++++++++++++++++++--
|
||||||
|
1 file changed, 21 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/basic/missing.h b/src/basic/missing.h
|
||||||
|
index 14ad3d4914..b9376617fc 100644
|
||||||
|
--- a/src/basic/missing.h
|
||||||
|
+++ b/src/basic/missing.h
|
||||||
|
@@ -747,10 +747,13 @@ struct input_mask {
|
||||||
|
#define IFLA_NUM_RX_QUEUES 32
|
||||||
|
#define IFLA_CARRIER 33
|
||||||
|
#define IFLA_PHYS_PORT_ID 34
|
||||||
|
-#define __IFLA_MAX 35
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+#define IFLA_PROP_LIST 52
|
||||||
|
+#define IFLA_ALT_IFNAME 53
|
||||||
|
+#define __IFLA_MAX 53
|
||||||
|
|
||||||
|
#define IFLA_MAX (__IFLA_MAX - 1)
|
||||||
|
-#endif
|
||||||
|
|
||||||
|
#if !HAVE_IFLA_BOND_AD_INFO
|
||||||
|
#define IFLA_BOND_UNSPEC 0
|
||||||
|
@@ -1045,6 +1048,18 @@ struct input_mask {
|
||||||
|
#define RTA_EXPIRES 23
|
||||||
|
#endif
|
||||||
|
|
||||||
|
+#ifndef RTM_NEWLINKPROP
|
||||||
|
+#define RTM_NEWLINKPROP 108
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+#ifndef RTM_DELLINKPROP
|
||||||
|
+#define RTM_DELLINKPROP 109
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+#ifndef RTM_GETLINKPROP
|
||||||
|
+#define RTM_GETLINKPROP 110
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
#ifndef IPV6_UNICAST_IF
|
||||||
|
#define IPV6_UNICAST_IF 76
|
||||||
|
#endif
|
||||||
|
@@ -1057,6 +1072,10 @@ struct input_mask {
|
||||||
|
#define IPV4_MIN_MTU 68
|
||||||
|
#endif
|
||||||
|
|
||||||
|
+#ifndef ALTIFNAMSIZ
|
||||||
|
+#define ALTIFNAMSIZ 128
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
#ifndef IFF_MULTI_QUEUE
|
||||||
|
#define IFF_MULTI_QUEUE 0x100
|
||||||
|
#endif
|
@ -0,0 +1,95 @@
|
|||||||
|
From b0b98085bb0b95395b686efca43980d463749f3d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Sun, 15 Dec 2019 20:57:51 +0900
|
||||||
|
Subject: [PATCH] sd-netlink: support IFLA_PROP_LIST and IFLA_ALT_IFNAME
|
||||||
|
attributes
|
||||||
|
|
||||||
|
(cherry picked from commit ffeb16f5d832b1c65b8c8a1dd9bdd028bd76fc72)
|
||||||
|
|
||||||
|
Related: #1850986
|
||||||
|
---
|
||||||
|
src/libsystemd/sd-netlink/netlink-message.c | 2 +-
|
||||||
|
src/libsystemd/sd-netlink/netlink-types.c | 13 +++++++++++++
|
||||||
|
src/libsystemd/sd-netlink/netlink-util.h | 4 +++-
|
||||||
|
src/libsystemd/sd-netlink/rtnl-message.c | 2 ++
|
||||||
|
4 files changed, 19 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/libsystemd/sd-netlink/netlink-message.c b/src/libsystemd/sd-netlink/netlink-message.c
|
||||||
|
index 23907c8224..db9101c163 100644
|
||||||
|
--- a/src/libsystemd/sd-netlink/netlink-message.c
|
||||||
|
+++ b/src/libsystemd/sd-netlink/netlink-message.c
|
||||||
|
@@ -89,7 +89,7 @@ int sd_netlink_message_request_dump(sd_netlink_message *m, int dump) {
|
||||||
|
assert_return(m, -EINVAL);
|
||||||
|
assert_return(m->hdr, -EINVAL);
|
||||||
|
|
||||||
|
- assert_return(IN_SET(m->hdr->nlmsg_type, RTM_GETLINK, RTM_GETADDR, RTM_GETROUTE, RTM_GETNEIGH, RTM_GETRULE, RTM_GETADDRLABEL), -EINVAL);
|
||||||
|
+ assert_return(IN_SET(m->hdr->nlmsg_type, RTM_GETLINK, RTM_GETLINKPROP, RTM_GETADDR, RTM_GETROUTE, RTM_GETNEIGH, RTM_GETRULE, RTM_GETADDRLABEL), -EINVAL);
|
||||||
|
|
||||||
|
SET_FLAG(m->hdr->nlmsg_flags, NLM_F_DUMP, dump);
|
||||||
|
|
||||||
|
diff --git a/src/libsystemd/sd-netlink/netlink-types.c b/src/libsystemd/sd-netlink/netlink-types.c
|
||||||
|
index c93fe9cb4c..47d9c7f1c4 100644
|
||||||
|
--- a/src/libsystemd/sd-netlink/netlink-types.c
|
||||||
|
+++ b/src/libsystemd/sd-netlink/netlink-types.c
|
||||||
|
@@ -451,6 +451,15 @@ static const NLTypeSystem rtnl_af_spec_type_system = {
|
||||||
|
.types = rtnl_af_spec_types,
|
||||||
|
};
|
||||||
|
|
||||||
|
+static const NLType rtnl_prop_list_types[] = {
|
||||||
|
+ [IFLA_ALT_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = ALTIFNAMSIZ - 1 },
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static const NLTypeSystem rtnl_prop_list_type_system = {
|
||||||
|
+ .count = ELEMENTSOF(rtnl_prop_list_types),
|
||||||
|
+ .types = rtnl_prop_list_types,
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
static const NLType rtnl_link_types[] = {
|
||||||
|
[IFLA_ADDRESS] = { .type = NETLINK_TYPE_ETHER_ADDR },
|
||||||
|
[IFLA_BROADCAST] = { .type = NETLINK_TYPE_ETHER_ADDR },
|
||||||
|
@@ -501,6 +510,7 @@ static const NLType rtnl_link_types[] = {
|
||||||
|
/*
|
||||||
|
[IFLA_PHYS_PORT_ID] = { .type = NETLINK_TYPE_BINARY, .len = MAX_PHYS_PORT_ID_LEN },
|
||||||
|
*/
|
||||||
|
+ [IFLA_PROP_LIST] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_prop_list_type_system },
|
||||||
|
};
|
||||||
|
|
||||||
|
static const NLTypeSystem rtnl_link_type_system = {
|
||||||
|
@@ -643,6 +653,9 @@ static const NLType rtnl_types[] = {
|
||||||
|
[RTM_DELLINK] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
|
||||||
|
[RTM_GETLINK] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
|
||||||
|
[RTM_SETLINK] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
|
||||||
|
+ [RTM_NEWLINKPROP] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
|
||||||
|
+ [RTM_DELLINKPROP] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
|
||||||
|
+ [RTM_GETLINKPROP] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
|
||||||
|
[RTM_NEWADDR] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_address_type_system, .size = sizeof(struct ifaddrmsg) },
|
||||||
|
[RTM_DELADDR] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_address_type_system, .size = sizeof(struct ifaddrmsg) },
|
||||||
|
[RTM_GETADDR] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_address_type_system, .size = sizeof(struct ifaddrmsg) },
|
||||||
|
diff --git a/src/libsystemd/sd-netlink/netlink-util.h b/src/libsystemd/sd-netlink/netlink-util.h
|
||||||
|
index 7c35a2cfa7..882a616310 100644
|
||||||
|
--- a/src/libsystemd/sd-netlink/netlink-util.h
|
||||||
|
+++ b/src/libsystemd/sd-netlink/netlink-util.h
|
||||||
|
@@ -19,7 +19,9 @@ static inline bool rtnl_message_type_is_route(uint16_t type) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool rtnl_message_type_is_link(uint16_t type) {
|
||||||
|
- return IN_SET(type, RTM_NEWLINK, RTM_SETLINK, RTM_GETLINK, RTM_DELLINK);
|
||||||
|
+ return IN_SET(type,
|
||||||
|
+ RTM_NEWLINK, RTM_SETLINK, RTM_GETLINK, RTM_DELLINK,
|
||||||
|
+ RTM_NEWLINKPROP, RTM_DELLINKPROP, RTM_GETLINKPROP);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool rtnl_message_type_is_addr(uint16_t type) {
|
||||||
|
diff --git a/src/libsystemd/sd-netlink/rtnl-message.c b/src/libsystemd/sd-netlink/rtnl-message.c
|
||||||
|
index 4416e1720c..369c402986 100644
|
||||||
|
--- a/src/libsystemd/sd-netlink/rtnl-message.c
|
||||||
|
+++ b/src/libsystemd/sd-netlink/rtnl-message.c
|
||||||
|
@@ -449,6 +449,8 @@ int sd_rtnl_message_new_link(sd_netlink *rtnl, sd_netlink_message **ret,
|
||||||
|
|
||||||
|
if (nlmsg_type == RTM_NEWLINK)
|
||||||
|
(*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_EXCL;
|
||||||
|
+ else if (nlmsg_type == RTM_NEWLINK)
|
||||||
|
+ (*ret)->hdr->nlmsg_flags |= NLM_F_EXCL | NLM_F_CREATE | NLM_F_APPEND;
|
||||||
|
|
||||||
|
ifi = NLMSG_DATA((*ret)->hdr);
|
||||||
|
|
@ -0,0 +1,106 @@
|
|||||||
|
From 3c31ef05ba732e3ab5d23761c5f84768ca8de68e Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Sun, 15 Dec 2019 21:32:25 +0900
|
||||||
|
Subject: [PATCH] sd-netlink: introduce sd_netlink_message_read_strv()
|
||||||
|
|
||||||
|
The combination of sd_netlink_message_enter_container() and
|
||||||
|
sd_netlink_message_read_string() only reads the last element if the attribute is
|
||||||
|
duplicated, such a situation easily happens for IFLA_ALT_IFNAME.
|
||||||
|
The function introduced here reads all matched attributes.
|
||||||
|
|
||||||
|
(cherry picked from commit 8f3c1859669230c2c8458675f41de13e369b47e7)
|
||||||
|
|
||||||
|
Related: #1850986
|
||||||
|
---
|
||||||
|
src/libsystemd/sd-netlink/netlink-message.c | 58 +++++++++++++++++++++
|
||||||
|
src/systemd/sd-netlink.h | 1 +
|
||||||
|
2 files changed, 59 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/src/libsystemd/sd-netlink/netlink-message.c b/src/libsystemd/sd-netlink/netlink-message.c
|
||||||
|
index db9101c163..5723e1d21c 100644
|
||||||
|
--- a/src/libsystemd/sd-netlink/netlink-message.c
|
||||||
|
+++ b/src/libsystemd/sd-netlink/netlink-message.c
|
||||||
|
@@ -14,6 +14,7 @@
|
||||||
|
#include "netlink-util.h"
|
||||||
|
#include "refcnt.h"
|
||||||
|
#include "socket-util.h"
|
||||||
|
+#include "strv.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
#define GET_CONTAINER(m, i) ((i) < (m)->n_containers ? (struct rtattr*)((uint8_t*)(m)->hdr + (m)->containers[i].offset) : NULL)
|
||||||
|
@@ -754,6 +755,63 @@ int sd_netlink_message_read_in6_addr(sd_netlink_message *m, unsigned short type,
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+int sd_netlink_message_read_strv(sd_netlink_message *m, unsigned short container_type, unsigned short type_id, char ***ret) {
|
||||||
|
+ _cleanup_strv_free_ char **s = NULL;
|
||||||
|
+ const NLTypeSystem *type_system;
|
||||||
|
+ const NLType *nl_type;
|
||||||
|
+ struct rtattr *rta;
|
||||||
|
+ void *container;
|
||||||
|
+ unsigned short rt_len;
|
||||||
|
+ int r;
|
||||||
|
+
|
||||||
|
+ assert_return(m, -EINVAL);
|
||||||
|
+ assert_return(m->n_containers < RTNL_CONTAINER_DEPTH, -EINVAL);
|
||||||
|
+
|
||||||
|
+ r = type_system_get_type(m->containers[m->n_containers].type_system,
|
||||||
|
+ &nl_type,
|
||||||
|
+ container_type);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
+
|
||||||
|
+ if (type_get_type(nl_type) != NETLINK_TYPE_NESTED)
|
||||||
|
+ return -EINVAL;
|
||||||
|
+
|
||||||
|
+ r = type_system_get_type_system(m->containers[m->n_containers].type_system,
|
||||||
|
+ &type_system,
|
||||||
|
+ container_type);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
+
|
||||||
|
+ r = type_system_get_type(type_system, &nl_type, type_id);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
+
|
||||||
|
+ if (type_get_type(nl_type) != NETLINK_TYPE_STRING)
|
||||||
|
+ return -EINVAL;
|
||||||
|
+
|
||||||
|
+ r = netlink_message_read_internal(m, container_type, &container, NULL);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
+
|
||||||
|
+ rt_len = (unsigned short) r;
|
||||||
|
+ rta = container;
|
||||||
|
+
|
||||||
|
+ for (; RTA_OK(rta, rt_len); rta = RTA_NEXT(rta, rt_len)) {
|
||||||
|
+ unsigned short type;
|
||||||
|
+
|
||||||
|
+ type = RTA_TYPE(rta);
|
||||||
|
+ if (type != type_id)
|
||||||
|
+ continue;
|
||||||
|
+
|
||||||
|
+ r = strv_extend(&s, RTA_DATA(rta));
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ *ret = TAKE_PTR(s);
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int netlink_container_parse(sd_netlink_message *m,
|
||||||
|
struct netlink_container *container,
|
||||||
|
int count,
|
||||||
|
diff --git a/src/systemd/sd-netlink.h b/src/systemd/sd-netlink.h
|
||||||
|
index 51f0fa16b4..1f5c093f11 100644
|
||||||
|
--- a/src/systemd/sd-netlink.h
|
||||||
|
+++ b/src/systemd/sd-netlink.h
|
||||||
|
@@ -82,6 +82,7 @@ int sd_netlink_message_open_container_union(sd_netlink_message *m, unsigned shor
|
||||||
|
int sd_netlink_message_close_container(sd_netlink_message *m);
|
||||||
|
|
||||||
|
int sd_netlink_message_read_string(sd_netlink_message *m, unsigned short type, const char **data);
|
||||||
|
+int sd_netlink_message_read_strv(sd_netlink_message *m, unsigned short container_type, unsigned short type_id, char ***ret);
|
||||||
|
int sd_netlink_message_read_u8(sd_netlink_message *m, unsigned short type, uint8_t *data);
|
||||||
|
int sd_netlink_message_read_u16(sd_netlink_message *m, unsigned short type, uint16_t *data);
|
||||||
|
int sd_netlink_message_read_u32(sd_netlink_message *m, unsigned short type, uint32_t *data);
|
@ -0,0 +1,65 @@
|
|||||||
|
From 7888c8796197357f0214ea5fe17b11a8814fc313 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Sun, 15 Dec 2019 21:47:21 +0900
|
||||||
|
Subject: [PATCH] sd-netlink: introduce sd_netlink_message_append_strv()
|
||||||
|
|
||||||
|
(cherry picked from commit 6d725977c4f98a8f5effc33f44aa646cc2b6a0b7)
|
||||||
|
|
||||||
|
Related: #1850986
|
||||||
|
---
|
||||||
|
src/libsystemd/sd-netlink/netlink-message.c | 29 +++++++++++++++++++++
|
||||||
|
src/systemd/sd-netlink.h | 1 +
|
||||||
|
2 files changed, 30 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/src/libsystemd/sd-netlink/netlink-message.c b/src/libsystemd/sd-netlink/netlink-message.c
|
||||||
|
index 5723e1d21c..55d6510b63 100644
|
||||||
|
--- a/src/libsystemd/sd-netlink/netlink-message.c
|
||||||
|
+++ b/src/libsystemd/sd-netlink/netlink-message.c
|
||||||
|
@@ -259,6 +259,35 @@ int sd_netlink_message_append_string(sd_netlink_message *m, unsigned short type,
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+int sd_netlink_message_append_strv(sd_netlink_message *m, unsigned short type, char * const *data) {
|
||||||
|
+ size_t length, size;
|
||||||
|
+ char * const *p;
|
||||||
|
+ int r;
|
||||||
|
+
|
||||||
|
+ assert_return(m, -EINVAL);
|
||||||
|
+ assert_return(!m->sealed, -EPERM);
|
||||||
|
+ assert_return(data, -EINVAL);
|
||||||
|
+
|
||||||
|
+ r = message_attribute_has_type(m, &size, type, NETLINK_TYPE_STRING);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
+
|
||||||
|
+ STRV_FOREACH(p, data) {
|
||||||
|
+ if (size) {
|
||||||
|
+ length = strnlen(*p, size+1);
|
||||||
|
+ if (length > size)
|
||||||
|
+ return -EINVAL;
|
||||||
|
+ } else
|
||||||
|
+ length = strlen(*p);
|
||||||
|
+
|
||||||
|
+ r = add_rtattr(m, type, *p, length + 1);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
int sd_netlink_message_append_flag(sd_netlink_message *m, unsigned short type) {
|
||||||
|
size_t size;
|
||||||
|
int r;
|
||||||
|
diff --git a/src/systemd/sd-netlink.h b/src/systemd/sd-netlink.h
|
||||||
|
index 1f5c093f11..5a05cd4485 100644
|
||||||
|
--- a/src/systemd/sd-netlink.h
|
||||||
|
+++ b/src/systemd/sd-netlink.h
|
||||||
|
@@ -67,6 +67,7 @@ int sd_netlink_attach_event(sd_netlink *nl, sd_event *e, int64_t priority);
|
||||||
|
int sd_netlink_detach_event(sd_netlink *nl);
|
||||||
|
|
||||||
|
int sd_netlink_message_append_string(sd_netlink_message *m, unsigned short type, const char *data);
|
||||||
|
+int sd_netlink_message_append_strv(sd_netlink_message *m, unsigned short type, char * const *data);
|
||||||
|
int sd_netlink_message_append_flag(sd_netlink_message *m, unsigned short type);
|
||||||
|
int sd_netlink_message_append_u8(sd_netlink_message *m, unsigned short type, uint8_t data);
|
||||||
|
int sd_netlink_message_append_u16(sd_netlink_message *m, unsigned short type, uint16_t data);
|
@ -0,0 +1,71 @@
|
|||||||
|
From aff5197c5f06617b1ca0291614a0fb02c0c2e948 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Sun, 15 Dec 2019 21:48:12 +0900
|
||||||
|
Subject: [PATCH] test: add a test for sd_netlink_message_{append,read}_strv()
|
||||||
|
|
||||||
|
(cherry picked from commit d08d92d5ee508a80e35d6b95b962bd09527fb5f2)
|
||||||
|
|
||||||
|
Related: #1850986
|
||||||
|
---
|
||||||
|
src/libsystemd/sd-netlink/test-netlink.c | 33 ++++++++++++++++++++++++
|
||||||
|
1 file changed, 33 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/src/libsystemd/sd-netlink/test-netlink.c b/src/libsystemd/sd-netlink/test-netlink.c
|
||||||
|
index 03773fb936..8ee6551385 100644
|
||||||
|
--- a/src/libsystemd/sd-netlink/test-netlink.c
|
||||||
|
+++ b/src/libsystemd/sd-netlink/test-netlink.c
|
||||||
|
@@ -10,7 +10,9 @@
|
||||||
|
#include "missing.h"
|
||||||
|
#include "netlink-util.h"
|
||||||
|
#include "socket-util.h"
|
||||||
|
+#include "stdio-util.h"
|
||||||
|
#include "string-util.h"
|
||||||
|
+#include "strv.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
static void test_message_link_bridge(sd_netlink *rtnl) {
|
||||||
|
@@ -357,6 +359,36 @@ static void test_message(sd_netlink *rtnl) {
|
||||||
|
assert_se(sd_netlink_message_get_errno(m) == -ETIMEDOUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void test_strv(sd_netlink *rtnl) {
|
||||||
|
+ _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
|
||||||
|
+ _cleanup_strv_free_ char **names_in = NULL, **names_out;
|
||||||
|
+ const char *p;
|
||||||
|
+
|
||||||
|
+ assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_NEWLINKPROP, 1) >= 0);
|
||||||
|
+
|
||||||
|
+ for (unsigned i = 0; i < 10; i++) {
|
||||||
|
+ char name[STRLEN("hoge") + DECIMAL_STR_MAX(uint32_t)];
|
||||||
|
+
|
||||||
|
+ xsprintf(name, "hoge%" PRIu32, i + 1000);
|
||||||
|
+ assert_se(strv_extend(&names_in, name) >= 0);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ assert_se(sd_netlink_message_open_container(m, IFLA_PROP_LIST) >= 0);
|
||||||
|
+ assert_se(sd_netlink_message_append_strv(m, IFLA_ALT_IFNAME, names_in) >= 0);
|
||||||
|
+ assert_se(sd_netlink_message_close_container(m) >= 0);
|
||||||
|
+
|
||||||
|
+ rtnl_message_seal(m);
|
||||||
|
+ assert_se(sd_netlink_message_rewind(m) >= 0);
|
||||||
|
+
|
||||||
|
+ assert_se(sd_netlink_message_read_strv(m, IFLA_PROP_LIST, IFLA_ALT_IFNAME, &names_out) >= 0);
|
||||||
|
+ assert_se(strv_equal(names_in, names_out));
|
||||||
|
+
|
||||||
|
+ assert_se(sd_netlink_message_enter_container(m, IFLA_PROP_LIST) >= 0);
|
||||||
|
+ assert_se(sd_netlink_message_read_string(m, IFLA_ALT_IFNAME, &p) >= 0);
|
||||||
|
+ assert_se(streq(p, "hoge1009"));
|
||||||
|
+ assert_se(sd_netlink_message_exit_container(m) >= 0);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
int main(void) {
|
||||||
|
sd_netlink *rtnl;
|
||||||
|
sd_netlink_message *m;
|
||||||
|
@@ -377,6 +409,7 @@ int main(void) {
|
||||||
|
test_message(rtnl);
|
||||||
|
|
||||||
|
test_container(rtnl);
|
||||||
|
+ test_strv(rtnl);
|
||||||
|
|
||||||
|
if_loopback = (int) if_nametoindex("lo");
|
||||||
|
assert_se(if_loopback > 0);
|
79
SOURCES/0642-util-introduce-ifname_valid_full.patch
Normal file
79
SOURCES/0642-util-introduce-ifname_valid_full.patch
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
From c50aab5f23535ea7f3ef004910465e7054931199 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Sun, 15 Dec 2019 23:01:54 +0900
|
||||||
|
Subject: [PATCH] util: introduce ifname_valid_full()
|
||||||
|
|
||||||
|
(cherry picked from commit 4252696aec9ec038ff312a164e25f039da25126f)
|
||||||
|
|
||||||
|
Related: #1850986
|
||||||
|
---
|
||||||
|
src/basic/socket-util.c | 12 +++++++++---
|
||||||
|
src/basic/socket-util.h | 5 ++++-
|
||||||
|
src/test/test-socket-util.c | 1 +
|
||||||
|
3 files changed, 14 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c
|
||||||
|
index 053bcba670..7f8066123b 100644
|
||||||
|
--- a/src/basic/socket-util.c
|
||||||
|
+++ b/src/basic/socket-util.c
|
||||||
|
@@ -13,6 +13,7 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
+#include <linux/if.h>
|
||||||
|
|
||||||
|
#include "alloc-util.h"
|
||||||
|
#include "fd-util.h"
|
||||||
|
@@ -868,7 +869,7 @@ static const char* const ip_tos_table[] = {
|
||||||
|
|
||||||
|
DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(ip_tos, int, 0xff);
|
||||||
|
|
||||||
|
-bool ifname_valid(const char *p) {
|
||||||
|
+bool ifname_valid_full(const char *p, bool alternative) {
|
||||||
|
bool numeric = true;
|
||||||
|
|
||||||
|
/* Checks whether a network interface name is valid. This is inspired by dev_valid_name() in the kernel sources
|
||||||
|
@@ -878,8 +879,13 @@ bool ifname_valid(const char *p) {
|
||||||
|
if (isempty(p))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
- if (strlen(p) >= IFNAMSIZ)
|
||||||
|
- return false;
|
||||||
|
+ if (alternative) {
|
||||||
|
+ if (strlen(p) >= ALTIFNAMSIZ)
|
||||||
|
+ return false;
|
||||||
|
+ } else {
|
||||||
|
+ if (strlen(p) >= IFNAMSIZ)
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
if (dot_or_dot_dot(p))
|
||||||
|
return false;
|
||||||
|
diff --git a/src/basic/socket-util.h b/src/basic/socket-util.h
|
||||||
|
index c7c9ad34d6..30baba6c03 100644
|
||||||
|
--- a/src/basic/socket-util.h
|
||||||
|
+++ b/src/basic/socket-util.h
|
||||||
|
@@ -123,7 +123,10 @@ int fd_inc_rcvbuf(int fd, size_t n);
|
||||||
|
int ip_tos_to_string_alloc(int i, char **s);
|
||||||
|
int ip_tos_from_string(const char *s);
|
||||||
|
|
||||||
|
-bool ifname_valid(const char *p);
|
||||||
|
+bool ifname_valid_full(const char *p, bool alternative);
|
||||||
|
+static inline bool ifname_valid(const char *p) {
|
||||||
|
+ return ifname_valid_full(p, false);
|
||||||
|
+}
|
||||||
|
bool address_label_valid(const char *p);
|
||||||
|
|
||||||
|
int getpeercred(int fd, struct ucred *ucred);
|
||||||
|
diff --git a/src/test/test-socket-util.c b/src/test/test-socket-util.c
|
||||||
|
index 19c5395b92..c545622c09 100644
|
||||||
|
--- a/src/test/test-socket-util.c
|
||||||
|
+++ b/src/test/test-socket-util.c
|
||||||
|
@@ -39,6 +39,7 @@ static void test_ifname_valid(void) {
|
||||||
|
|
||||||
|
assert(ifname_valid("xxxxxxxxxxxxxxx"));
|
||||||
|
assert(!ifname_valid("xxxxxxxxxxxxxxxx"));
|
||||||
|
+ assert(ifname_valid_full("xxxxxxxxxxxxxxxx", true));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_socket_address_parse(void) {
|
69
SOURCES/0643-rename-function.patch
Normal file
69
SOURCES/0643-rename-function.patch
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
From 7fc7c2774e0836ace524215ced5c60db405a154a Mon Sep 17 00:00:00 2001
|
||||||
|
From: David Tardon <dtardon@redhat.com>
|
||||||
|
Date: Fri, 27 Nov 2020 10:25:12 +0100
|
||||||
|
Subject: [PATCH] rename function
|
||||||
|
|
||||||
|
This happened upstream in commit
|
||||||
|
54a8423788ec3cc6240959ab9f5cdac40baf047a, but I don't want to backport
|
||||||
|
the whole commit...
|
||||||
|
|
||||||
|
Related: #1850986
|
||||||
|
---
|
||||||
|
src/libsystemd-network/network-internal.c | 2 +-
|
||||||
|
src/libsystemd-network/network-internal.h | 2 +-
|
||||||
|
src/network/networkd-network-gperf.gperf | 2 +-
|
||||||
|
src/udev/net/link-config-gperf.gperf | 2 +-
|
||||||
|
4 files changed, 4 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c
|
||||||
|
index 0849b44ee2..629e858def 100644
|
||||||
|
--- a/src/libsystemd-network/network-internal.c
|
||||||
|
+++ b/src/libsystemd-network/network-internal.c
|
||||||
|
@@ -183,7 +183,7 @@ int config_parse_net_condition(const char *unit,
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
-int config_parse_ifnames(
|
||||||
|
+int config_parse_match_ifnames(
|
||||||
|
const char *unit,
|
||||||
|
const char *filename,
|
||||||
|
unsigned line,
|
||||||
|
diff --git a/src/libsystemd-network/network-internal.h b/src/libsystemd-network/network-internal.h
|
||||||
|
index 883f34b95c..9074758bbb 100644
|
||||||
|
--- a/src/libsystemd-network/network-internal.h
|
||||||
|
+++ b/src/libsystemd-network/network-internal.h
|
||||||
|
@@ -34,7 +34,7 @@ bool net_match_config(Set *match_mac,
|
||||||
|
CONFIG_PARSER_PROTOTYPE(config_parse_net_condition);
|
||||||
|
CONFIG_PARSER_PROTOTYPE(config_parse_hwaddr);
|
||||||
|
CONFIG_PARSER_PROTOTYPE(config_parse_hwaddrs);
|
||||||
|
-CONFIG_PARSER_PROTOTYPE(config_parse_ifnames);
|
||||||
|
+CONFIG_PARSER_PROTOTYPE(config_parse_match_ifnames);
|
||||||
|
CONFIG_PARSER_PROTOTYPE(config_parse_ifalias);
|
||||||
|
CONFIG_PARSER_PROTOTYPE(config_parse_iaid);
|
||||||
|
CONFIG_PARSER_PROTOTYPE(config_parse_bridge_port_priority);
|
||||||
|
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
|
||||||
|
index 6ad5257f79..c4a2eccdc2 100644
|
||||||
|
--- a/src/network/networkd-network-gperf.gperf
|
||||||
|
+++ b/src/network/networkd-network-gperf.gperf
|
||||||
|
@@ -24,7 +24,7 @@ Match.MACAddress, config_parse_hwaddrs,
|
||||||
|
Match.Path, config_parse_strv, 0, offsetof(Network, match_path)
|
||||||
|
Match.Driver, config_parse_strv, 0, offsetof(Network, match_driver)
|
||||||
|
Match.Type, config_parse_strv, 0, offsetof(Network, match_type)
|
||||||
|
-Match.Name, config_parse_ifnames, 0, offsetof(Network, match_name)
|
||||||
|
+Match.Name, config_parse_match_ifnames, 0, offsetof(Network, match_name)
|
||||||
|
Match.Host, config_parse_net_condition, CONDITION_HOST, offsetof(Network, match_host)
|
||||||
|
Match.Virtualization, config_parse_net_condition, CONDITION_VIRTUALIZATION, offsetof(Network, match_virt)
|
||||||
|
Match.KernelCommandLine, config_parse_net_condition, CONDITION_KERNEL_COMMAND_LINE, offsetof(Network, match_kernel_cmdline)
|
||||||
|
diff --git a/src/udev/net/link-config-gperf.gperf b/src/udev/net/link-config-gperf.gperf
|
||||||
|
index 5640fa0513..b37836d852 100644
|
||||||
|
--- a/src/udev/net/link-config-gperf.gperf
|
||||||
|
+++ b/src/udev/net/link-config-gperf.gperf
|
||||||
|
@@ -20,7 +20,7 @@ struct ConfigPerfItem;
|
||||||
|
%includes
|
||||||
|
%%
|
||||||
|
Match.MACAddress, config_parse_hwaddrs, 0, offsetof(link_config, match_mac)
|
||||||
|
-Match.OriginalName, config_parse_ifnames, 0, offsetof(link_config, match_name)
|
||||||
|
+Match.OriginalName, config_parse_match_ifnames, 0, offsetof(link_config, match_name)
|
||||||
|
Match.Path, config_parse_strv, 0, offsetof(link_config, match_path)
|
||||||
|
Match.Driver, config_parse_strv, 0, offsetof(link_config, match_driver)
|
||||||
|
Match.Type, config_parse_strv, 0, offsetof(link_config, match_type)
|
@ -0,0 +1,238 @@
|
|||||||
|
From b99b055ba975c1663beaf94dbfe8f5c5c7398996 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Sun, 15 Dec 2019 23:21:18 +0900
|
||||||
|
Subject: [PATCH] udev: support AlternativeName= setting in .link file
|
||||||
|
|
||||||
|
(cherry picked from commit a5053a158b43c5ddee90f4915b9fc603e0191d6d)
|
||||||
|
|
||||||
|
Related: #1850986
|
||||||
|
---
|
||||||
|
man/systemd.link.xml | 8 ++++
|
||||||
|
src/libsystemd/sd-netlink/netlink-util.c | 40 ++++++++++++++++
|
||||||
|
src/libsystemd/sd-netlink/netlink-util.h | 1 +
|
||||||
|
src/shared/conf-parser.c | 60 ++++++++++++++++++++++++
|
||||||
|
src/shared/conf-parser.h | 1 +
|
||||||
|
src/udev/net/link-config-gperf.gperf | 1 +
|
||||||
|
src/udev/net/link-config.c | 5 ++
|
||||||
|
src/udev/net/link-config.h | 1 +
|
||||||
|
8 files changed, 117 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/man/systemd.link.xml b/man/systemd.link.xml
|
||||||
|
index 32657308d0..0b0d83349d 100644
|
||||||
|
--- a/man/systemd.link.xml
|
||||||
|
+++ b/man/systemd.link.xml
|
||||||
|
@@ -343,6 +343,14 @@
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
+ <varlistentry>
|
||||||
|
+ <term><varname>AlternativeName=</varname></term>
|
||||||
|
+ <listitem>
|
||||||
|
+ <para>The alternative interface name to use. This option can be specified multiple times.
|
||||||
|
+ If the empty string is assigned to this option, the list is reset, and all prior assignments
|
||||||
|
+ have no effect.</para>
|
||||||
|
+ </listitem>
|
||||||
|
+ </varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><varname>MTUBytes=</varname></term>
|
||||||
|
<listitem>
|
||||||
|
diff --git a/src/libsystemd/sd-netlink/netlink-util.c b/src/libsystemd/sd-netlink/netlink-util.c
|
||||||
|
index 3928dfbabf..c1c306f121 100644
|
||||||
|
--- a/src/libsystemd/sd-netlink/netlink-util.c
|
||||||
|
+++ b/src/libsystemd/sd-netlink/netlink-util.c
|
||||||
|
@@ -4,6 +4,7 @@
|
||||||
|
|
||||||
|
#include "netlink-internal.h"
|
||||||
|
#include "netlink-util.h"
|
||||||
|
+#include "strv.h"
|
||||||
|
|
||||||
|
int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name) {
|
||||||
|
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL;
|
||||||
|
@@ -80,6 +81,45 @@ int rtnl_set_link_properties(sd_netlink **rtnl, int ifindex, const char *alias,
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+int rtnl_set_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const *alternative_names) {
|
||||||
|
+ _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL;
|
||||||
|
+ int r;
|
||||||
|
+
|
||||||
|
+ assert(rtnl);
|
||||||
|
+ assert(ifindex > 0);
|
||||||
|
+
|
||||||
|
+ if (strv_isempty(alternative_names))
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ if (!*rtnl) {
|
||||||
|
+ r = sd_netlink_open(rtnl);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ r = sd_rtnl_message_new_link(*rtnl, &message, RTM_NEWLINKPROP, ifindex);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
+
|
||||||
|
+ r = sd_netlink_message_open_container(message, IFLA_PROP_LIST);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
+
|
||||||
|
+ r = sd_netlink_message_append_strv(message, IFLA_ALT_IFNAME, alternative_names);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
+
|
||||||
|
+ r = sd_netlink_message_close_container(message);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
+
|
||||||
|
+ r = sd_netlink_call(*rtnl, message, 0, NULL);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
int rtnl_message_new_synthetic_error(sd_netlink *rtnl, int error, uint32_t serial, sd_netlink_message **ret) {
|
||||||
|
struct nlmsgerr *err;
|
||||||
|
int r;
|
||||||
|
diff --git a/src/libsystemd/sd-netlink/netlink-util.h b/src/libsystemd/sd-netlink/netlink-util.h
|
||||||
|
index 882a616310..92de19c092 100644
|
||||||
|
--- a/src/libsystemd/sd-netlink/netlink-util.h
|
||||||
|
+++ b/src/libsystemd/sd-netlink/netlink-util.h
|
||||||
|
@@ -38,6 +38,7 @@ static inline bool rtnl_message_type_is_routing_policy_rule(uint16_t type) {
|
||||||
|
|
||||||
|
int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name);
|
||||||
|
int rtnl_set_link_properties(sd_netlink **rtnl, int ifindex, const char *alias, const struct ether_addr *mac, uint32_t mtu);
|
||||||
|
+int rtnl_set_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const *alternative_names);
|
||||||
|
|
||||||
|
int rtnl_log_parse_error(int r);
|
||||||
|
int rtnl_log_create_error(int r);
|
||||||
|
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
|
||||||
|
index 246b7431e4..1f40f00c72 100644
|
||||||
|
--- a/src/shared/conf-parser.c
|
||||||
|
+++ b/src/shared/conf-parser.c
|
||||||
|
@@ -970,6 +970,66 @@ int config_parse_ifname(
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+int config_parse_ifnames(
|
||||||
|
+ const char *unit,
|
||||||
|
+ const char *filename,
|
||||||
|
+ unsigned line,
|
||||||
|
+ const char *section,
|
||||||
|
+ unsigned section_line,
|
||||||
|
+ const char *lvalue,
|
||||||
|
+ int ltype,
|
||||||
|
+ const char *rvalue,
|
||||||
|
+ void *data,
|
||||||
|
+ void *userdata) {
|
||||||
|
+
|
||||||
|
+ _cleanup_strv_free_ char **names = NULL;
|
||||||
|
+ char ***s = data;
|
||||||
|
+ const char *p;
|
||||||
|
+ int r;
|
||||||
|
+
|
||||||
|
+ assert(filename);
|
||||||
|
+ assert(lvalue);
|
||||||
|
+ assert(rvalue);
|
||||||
|
+ assert(data);
|
||||||
|
+
|
||||||
|
+ if (isempty(rvalue)) {
|
||||||
|
+ *s = strv_free(*s);
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ p = rvalue;
|
||||||
|
+ for (;;) {
|
||||||
|
+ _cleanup_free_ char *word = NULL;
|
||||||
|
+
|
||||||
|
+ r = extract_first_word(&p, &word, NULL, 0);
|
||||||
|
+ if (r < 0) {
|
||||||
|
+ log_syntax(unit, LOG_ERR, filename, line, r,
|
||||||
|
+ "Failed to extract interface name, ignoring assignment: %s",
|
||||||
|
+ rvalue);
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ if (r == 0)
|
||||||
|
+ break;
|
||||||
|
+
|
||||||
|
+ if (!ifname_valid_full(word, ltype)) {
|
||||||
|
+ log_syntax(unit, LOG_ERR, filename, line, 0,
|
||||||
|
+ "Interface name is not valid or too long, ignoring assignment: %s",
|
||||||
|
+ word);
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ r = strv_consume(&names, TAKE_PTR(word));
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return log_oom();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ r = strv_extend_strv(s, names, true);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return log_oom();
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
int config_parse_ip_port(
|
||||||
|
const char *unit,
|
||||||
|
const char *filename,
|
||||||
|
diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h
|
||||||
|
index a0a5c89c27..375b2e5a74 100644
|
||||||
|
--- a/src/shared/conf-parser.h
|
||||||
|
+++ b/src/shared/conf-parser.h
|
||||||
|
@@ -137,6 +137,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_signal);
|
||||||
|
CONFIG_PARSER_PROTOTYPE(config_parse_personality);
|
||||||
|
CONFIG_PARSER_PROTOTYPE(config_parse_permille);
|
||||||
|
CONFIG_PARSER_PROTOTYPE(config_parse_ifname);
|
||||||
|
+CONFIG_PARSER_PROTOTYPE(config_parse_ifnames);
|
||||||
|
CONFIG_PARSER_PROTOTYPE(config_parse_ip_port);
|
||||||
|
CONFIG_PARSER_PROTOTYPE(config_parse_join_controllers);
|
||||||
|
CONFIG_PARSER_PROTOTYPE(config_parse_mtu);
|
||||||
|
diff --git a/src/udev/net/link-config-gperf.gperf b/src/udev/net/link-config-gperf.gperf
|
||||||
|
index b37836d852..913c754145 100644
|
||||||
|
--- a/src/udev/net/link-config-gperf.gperf
|
||||||
|
+++ b/src/udev/net/link-config-gperf.gperf
|
||||||
|
@@ -34,6 +34,7 @@ Link.MACAddressPolicy, config_parse_mac_policy, 0,
|
||||||
|
Link.MACAddress, config_parse_hwaddr, 0, offsetof(link_config, mac)
|
||||||
|
Link.NamePolicy, config_parse_name_policy, 0, offsetof(link_config, name_policy)
|
||||||
|
Link.Name, config_parse_ifname, 0, offsetof(link_config, name)
|
||||||
|
+Link.AlternativeName, config_parse_ifnames, 1, offsetof(link_config, alternative_names)
|
||||||
|
Link.Alias, config_parse_ifalias, 0, offsetof(link_config, alias)
|
||||||
|
Link.MTUBytes, config_parse_mtu, AF_UNSPEC, offsetof(link_config, mtu)
|
||||||
|
Link.BitsPerSecond, config_parse_si_size, 0, offsetof(link_config, speed)
|
||||||
|
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
|
||||||
|
index 5113586457..d07a1a1874 100644
|
||||||
|
--- a/src/udev/net/link-config.c
|
||||||
|
+++ b/src/udev/net/link-config.c
|
||||||
|
@@ -67,6 +67,7 @@ static void link_config_free(link_config *link) {
|
||||||
|
free(link->mac);
|
||||||
|
free(link->name_policy);
|
||||||
|
free(link->name);
|
||||||
|
+ strv_free(link->alternative_names);
|
||||||
|
free(link->alias);
|
||||||
|
|
||||||
|
free(link);
|
||||||
|
@@ -468,6 +469,10 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
|
||||||
|
if (r < 0)
|
||||||
|
return log_warning_errno(r, "Could not set Alias=, MACAddress= or MTU= on %s: %m", old_name);
|
||||||
|
|
||||||
|
+ r = rtnl_set_link_alternative_names(&ctx->rtnl, ifindex, config->alternative_names);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return log_warning_errno(r, "Could not set AlternativeName= on %s: %m", old_name);
|
||||||
|
+
|
||||||
|
*name = new_name;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
diff --git a/src/udev/net/link-config.h b/src/udev/net/link-config.h
|
||||||
|
index 4798bb101c..93d5fdce59 100644
|
||||||
|
--- a/src/udev/net/link-config.h
|
||||||
|
+++ b/src/udev/net/link-config.h
|
||||||
|
@@ -50,6 +50,7 @@ struct link_config {
|
||||||
|
MACPolicy mac_policy;
|
||||||
|
NamePolicy *name_policy;
|
||||||
|
char *name;
|
||||||
|
+ char **alternative_names;
|
||||||
|
char *alias;
|
||||||
|
uint32_t mtu;
|
||||||
|
size_t speed;
|
@ -0,0 +1,115 @@
|
|||||||
|
From c76d050d8d61b4a63d4407bd03bd3f49cd9915ce Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Sun, 15 Dec 2019 22:46:19 +0900
|
||||||
|
Subject: [PATCH] network: make Name= in [Match] support alternative names of
|
||||||
|
interfaces
|
||||||
|
|
||||||
|
(cherry picked from commit 572b21d96cabd5860b0670e98440b6cb99a4b749
|
||||||
|
src/network bits have been left out.)
|
||||||
|
|
||||||
|
Related: #1850986
|
||||||
|
---
|
||||||
|
man/systemd.network.xml | 7 +++----
|
||||||
|
src/libsystemd-network/network-internal.c | 20 ++++++++++++++++++--
|
||||||
|
src/libsystemd-network/network-internal.h | 3 ++-
|
||||||
|
src/udev/net/link-config.c | 3 ++-
|
||||||
|
4 files changed, 25 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/man/systemd.network.xml b/man/systemd.network.xml
|
||||||
|
index fc8e0aea68..8300540096 100644
|
||||||
|
--- a/man/systemd.network.xml
|
||||||
|
+++ b/man/systemd.network.xml
|
||||||
|
@@ -133,10 +133,9 @@
|
||||||
|
<varlistentry>
|
||||||
|
<term><varname>Name=</varname></term>
|
||||||
|
<listitem>
|
||||||
|
- <para>A whitespace-separated list of shell-style globs
|
||||||
|
- matching the device name, as exposed by the udev property
|
||||||
|
- <literal>INTERFACE</literal>. If the list is prefixed
|
||||||
|
- with a "!", the test is inverted.</para>
|
||||||
|
+ <para>A whitespace-separated list of shell-style globs matching the device name, as exposed
|
||||||
|
+ by the udev property <literal>INTERFACE</literal>, or device's alternative names. If the
|
||||||
|
+ list is prefixed with a "!", the test is inverted.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c
|
||||||
|
index 629e858def..a935709cd0 100644
|
||||||
|
--- a/src/libsystemd-network/network-internal.c
|
||||||
|
+++ b/src/libsystemd-network/network-internal.c
|
||||||
|
@@ -92,6 +92,18 @@ static bool net_condition_test_strv(char * const *raw_patterns,
|
||||||
|
return string && strv_fnmatch(raw_patterns, string, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static bool net_condition_test_ifname(char * const *patterns, const char *ifname, char * const *alternative_names) {
|
||||||
|
+ if (net_condition_test_strv(patterns, ifname))
|
||||||
|
+ return true;
|
||||||
|
+
|
||||||
|
+ char * const *p;
|
||||||
|
+ STRV_FOREACH(p, alternative_names)
|
||||||
|
+ if (net_condition_test_strv(patterns, *p))
|
||||||
|
+ return true;
|
||||||
|
+
|
||||||
|
+ return false;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
bool net_match_config(Set *match_mac,
|
||||||
|
char * const *match_paths,
|
||||||
|
char * const *match_drivers,
|
||||||
|
@@ -107,7 +119,8 @@ bool net_match_config(Set *match_mac,
|
||||||
|
const char *dev_parent_driver,
|
||||||
|
const char *dev_driver,
|
||||||
|
const char *dev_type,
|
||||||
|
- const char *dev_name) {
|
||||||
|
+ const char *dev_name,
|
||||||
|
+ char * const *alternative_names) {
|
||||||
|
|
||||||
|
if (match_host && condition_test(match_host) <= 0)
|
||||||
|
return false;
|
||||||
|
@@ -124,6 +137,9 @@ bool net_match_config(Set *match_mac,
|
||||||
|
if (match_arch && condition_test(match_arch) <= 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
+ if (!net_condition_test_ifname(match_names, dev_name, alternative_names))
|
||||||
|
+ return false;
|
||||||
|
+
|
||||||
|
if (match_mac && dev_mac && !set_contains(match_mac, dev_mac))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
@@ -214,7 +230,7 @@ int config_parse_match_ifnames(
|
||||||
|
if (r == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
- if (!ifname_valid(word)) {
|
||||||
|
+ if (!ifname_valid_full(word, ltype)) {
|
||||||
|
log_syntax(unit, LOG_ERR, filename, line, 0, "Interface name is not valid or too long, ignoring assignment: %s", rvalue);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
diff --git a/src/libsystemd-network/network-internal.h b/src/libsystemd-network/network-internal.h
|
||||||
|
index 9074758bbb..e1d098f3fe 100644
|
||||||
|
--- a/src/libsystemd-network/network-internal.h
|
||||||
|
+++ b/src/libsystemd-network/network-internal.h
|
||||||
|
@@ -29,7 +29,8 @@ bool net_match_config(Set *match_mac,
|
||||||
|
const char *dev_parent_driver,
|
||||||
|
const char *dev_driver,
|
||||||
|
const char *dev_type,
|
||||||
|
- const char *dev_name);
|
||||||
|
+ const char *dev_name,
|
||||||
|
+ char * const *alternative_names);
|
||||||
|
|
||||||
|
CONFIG_PARSER_PROTOTYPE(config_parse_net_condition);
|
||||||
|
CONFIG_PARSER_PROTOTYPE(config_parse_hwaddr);
|
||||||
|
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
|
||||||
|
index d07a1a1874..e5052f8f29 100644
|
||||||
|
--- a/src/udev/net/link-config.c
|
||||||
|
+++ b/src/udev/net/link-config.c
|
||||||
|
@@ -238,7 +238,8 @@ int link_config_get(link_config_ctx *ctx, struct udev_device *device,
|
||||||
|
udev_device_get_driver(udev_device_get_parent(device)),
|
||||||
|
udev_device_get_property_value(device, "ID_NET_DRIVER"),
|
||||||
|
udev_device_get_devtype(device),
|
||||||
|
- udev_device_get_sysname(device))) {
|
||||||
|
+ udev_device_get_sysname(device),
|
||||||
|
+ NULL)) {
|
||||||
|
if (link->match_name) {
|
||||||
|
unsigned char name_assign_type = NET_NAME_UNKNOWN;
|
||||||
|
|
@ -0,0 +1,170 @@
|
|||||||
|
From 22dd44ae3cfd66e622e0b672af96728b6f505ad1 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Tue, 17 Dec 2019 11:01:35 +0900
|
||||||
|
Subject: [PATCH] udev: extend the length of ID_NET_NAME_XXX= to ALTIFNAMSIZ
|
||||||
|
|
||||||
|
(cherry picked from commit 78f8849f84ca0939796edb840e878a9d2e124a4d)
|
||||||
|
|
||||||
|
Related: #1850986
|
||||||
|
---
|
||||||
|
src/udev/net/link-config.c | 5 ++++-
|
||||||
|
src/udev/udev-builtin-net_id.c | 33 +++++++++++++++++----------------
|
||||||
|
src/udev/udev-event.c | 4 ++--
|
||||||
|
3 files changed, 23 insertions(+), 19 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
|
||||||
|
index e5052f8f29..4de8ee7d7e 100644
|
||||||
|
--- a/src/udev/net/link-config.c
|
||||||
|
+++ b/src/udev/net/link-config.c
|
||||||
|
@@ -19,6 +19,7 @@
|
||||||
|
#include "path-util.h"
|
||||||
|
#include "proc-cmdline.h"
|
||||||
|
#include "random-util.h"
|
||||||
|
+#include "socket-util.h"
|
||||||
|
#include "stat-util.h"
|
||||||
|
#include "string-table.h"
|
||||||
|
#include "string-util.h"
|
||||||
|
@@ -405,7 +406,7 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
|
||||||
|
NamePolicy *policy;
|
||||||
|
|
||||||
|
for (policy = config->name_policy;
|
||||||
|
- !new_name && *policy != _NAMEPOLICY_INVALID; policy++) {
|
||||||
|
+ *policy != _NAMEPOLICY_INVALID; policy++) {
|
||||||
|
switch (*policy) {
|
||||||
|
case NAMEPOLICY_KERNEL:
|
||||||
|
respect_predictable = true;
|
||||||
|
@@ -428,6 +429,8 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
+ if (ifname_valid(new_name))
|
||||||
|
+ break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
|
||||||
|
index 7c153f0aef..0611c08234 100644
|
||||||
|
--- a/src/udev/udev-builtin-net_id.c
|
||||||
|
+++ b/src/udev/udev-builtin-net_id.c
|
||||||
|
@@ -90,6 +90,7 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
+#include <linux/if.h>
|
||||||
|
#include <linux/pci_regs.h>
|
||||||
|
|
||||||
|
#include "dirent-util.h"
|
||||||
|
@@ -172,21 +173,21 @@ struct netnames {
|
||||||
|
bool mac_valid;
|
||||||
|
|
||||||
|
struct udev_device *pcidev;
|
||||||
|
- char pci_slot[IFNAMSIZ];
|
||||||
|
- char pci_path[IFNAMSIZ];
|
||||||
|
- char pci_onboard[IFNAMSIZ];
|
||||||
|
+ char pci_slot[ALTIFNAMSIZ];
|
||||||
|
+ char pci_path[ALTIFNAMSIZ];
|
||||||
|
+ char pci_onboard[ALTIFNAMSIZ];
|
||||||
|
const char *pci_onboard_label;
|
||||||
|
|
||||||
|
- char usb_ports[IFNAMSIZ];
|
||||||
|
- char bcma_core[IFNAMSIZ];
|
||||||
|
- char ccw_busid[IFNAMSIZ];
|
||||||
|
- char vio_slot[IFNAMSIZ];
|
||||||
|
- char platform_path[IFNAMSIZ];
|
||||||
|
+ char usb_ports[ALTIFNAMSIZ];
|
||||||
|
+ char bcma_core[ALTIFNAMSIZ];
|
||||||
|
+ char ccw_busid[ALTIFNAMSIZ];
|
||||||
|
+ char vio_slot[ALTIFNAMSIZ];
|
||||||
|
+ char platform_path[ALTIFNAMSIZ];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct virtfn_info {
|
||||||
|
struct udev_device *physfn_pcidev;
|
||||||
|
- char suffix[IFNAMSIZ];
|
||||||
|
+ char suffix[ALTIFNAMSIZ];
|
||||||
|
};
|
||||||
|
|
||||||
|
static const NamingScheme* naming_scheme_from_name(const char *name) {
|
||||||
|
@@ -883,7 +884,7 @@ static int builtin_net_id(struct udev_device *dev, int argc, char *argv[], bool
|
||||||
|
|
||||||
|
err = names_mac(dev, &names);
|
||||||
|
if (err >= 0 && names.mac_valid) {
|
||||||
|
- char str[IFNAMSIZ];
|
||||||
|
+ char str[ALTIFNAMSIZ];
|
||||||
|
|
||||||
|
xsprintf(str, "%sx%02x%02x%02x%02x%02x%02x", prefix,
|
||||||
|
names.mac[0], names.mac[1], names.mac[2],
|
||||||
|
@@ -896,7 +897,7 @@ static int builtin_net_id(struct udev_device *dev, int argc, char *argv[], bool
|
||||||
|
/* get path names for Linux on System z network devices */
|
||||||
|
err = names_ccw(dev, &names);
|
||||||
|
if (err >= 0 && names.type == NET_CCW) {
|
||||||
|
- char str[IFNAMSIZ];
|
||||||
|
+ char str[ALTIFNAMSIZ];
|
||||||
|
|
||||||
|
if (snprintf_ok(str, sizeof str, "%s%s", prefix, names.ccw_busid))
|
||||||
|
udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
|
||||||
|
@@ -906,7 +907,7 @@ static int builtin_net_id(struct udev_device *dev, int argc, char *argv[], bool
|
||||||
|
/* get ibmveth/ibmvnic slot-based names. */
|
||||||
|
err = names_vio(dev, &names);
|
||||||
|
if (err >= 0 && names.type == NET_VIO) {
|
||||||
|
- char str[IFNAMSIZ];
|
||||||
|
+ char str[ALTIFNAMSIZ];
|
||||||
|
|
||||||
|
if (snprintf_ok(str, sizeof str, "%s%s", prefix, names.vio_slot))
|
||||||
|
udev_builtin_add_property(dev, test, "ID_NET_NAME_SLOT", str);
|
||||||
|
@@ -916,7 +917,7 @@ static int builtin_net_id(struct udev_device *dev, int argc, char *argv[], bool
|
||||||
|
/* get ACPI path names for ARM64 platform devices */
|
||||||
|
err = names_platform(dev, &names, test);
|
||||||
|
if (err >= 0 && names.type == NET_PLATFORM) {
|
||||||
|
- char str[IFNAMSIZ];
|
||||||
|
+ char str[ALTIFNAMSIZ];
|
||||||
|
|
||||||
|
if (snprintf_ok(str, sizeof str, "%s%s", prefix, names.platform_path))
|
||||||
|
udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
|
||||||
|
@@ -930,7 +931,7 @@ static int builtin_net_id(struct udev_device *dev, int argc, char *argv[], bool
|
||||||
|
|
||||||
|
/* plain PCI device */
|
||||||
|
if (names.type == NET_PCI) {
|
||||||
|
- char str[IFNAMSIZ];
|
||||||
|
+ char str[ALTIFNAMSIZ];
|
||||||
|
|
||||||
|
if (names.pci_onboard[0] &&
|
||||||
|
snprintf_ok(str, sizeof str, "%s%s", prefix, names.pci_onboard))
|
||||||
|
@@ -953,7 +954,7 @@ static int builtin_net_id(struct udev_device *dev, int argc, char *argv[], bool
|
||||||
|
/* USB device */
|
||||||
|
err = names_usb(dev, &names);
|
||||||
|
if (err >= 0 && names.type == NET_USB) {
|
||||||
|
- char str[IFNAMSIZ];
|
||||||
|
+ char str[ALTIFNAMSIZ];
|
||||||
|
|
||||||
|
if (names.pci_path[0] &&
|
||||||
|
snprintf_ok(str, sizeof str, "%s%s%s", prefix, names.pci_path, names.usb_ports))
|
||||||
|
@@ -968,7 +969,7 @@ static int builtin_net_id(struct udev_device *dev, int argc, char *argv[], bool
|
||||||
|
/* Broadcom bus */
|
||||||
|
err = names_bcma(dev, &names);
|
||||||
|
if (err >= 0 && names.type == NET_BCMA) {
|
||||||
|
- char str[IFNAMSIZ];
|
||||||
|
+ char str[ALTIFNAMSIZ];
|
||||||
|
|
||||||
|
if (names.pci_path[0] &&
|
||||||
|
snprintf_ok(str, sizeof str, "%s%s%s", prefix, names.pci_path, names.bcma_core))
|
||||||
|
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
|
||||||
|
index fd8406d959..19b100d4f8 100644
|
||||||
|
--- a/src/udev/udev-event.c
|
||||||
|
+++ b/src/udev/udev-event.c
|
||||||
|
@@ -816,13 +816,13 @@ out:
|
||||||
|
|
||||||
|
static int rename_netif(struct udev_event *event) {
|
||||||
|
struct udev_device *dev = event->dev;
|
||||||
|
- char name[IFNAMSIZ];
|
||||||
|
+ char name[ALTIFNAMSIZ];
|
||||||
|
const char *oldname;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
oldname = udev_device_get_sysname(dev);
|
||||||
|
|
||||||
|
- strscpy(name, IFNAMSIZ, event->name);
|
||||||
|
+ strscpy(name, ALTIFNAMSIZ, event->name);
|
||||||
|
|
||||||
|
r = rtnl_set_link_name(&event->rtnl, udev_device_get_ifindex(dev), name);
|
||||||
|
if (r < 0)
|
@ -0,0 +1,43 @@
|
|||||||
|
From 42894fc33ae88f3be49aa01ac24dd1c3e96770f6 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Tue, 17 Dec 2019 15:32:22 +0900
|
||||||
|
Subject: [PATCH] udev: do not fail if kernel does not support alternative
|
||||||
|
names
|
||||||
|
|
||||||
|
(cherry picked from commit bb181dd4a664ca8e82a8f7194261fd6531e861d8)
|
||||||
|
|
||||||
|
Related: #1850986
|
||||||
|
---
|
||||||
|
man/systemd.link.xml | 3 ++-
|
||||||
|
src/udev/net/link-config.c | 4 +++-
|
||||||
|
2 files changed, 5 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/man/systemd.link.xml b/man/systemd.link.xml
|
||||||
|
index 0b0d83349d..c8ebb751ee 100644
|
||||||
|
--- a/man/systemd.link.xml
|
||||||
|
+++ b/man/systemd.link.xml
|
||||||
|
@@ -348,7 +348,8 @@
|
||||||
|
<listitem>
|
||||||
|
<para>The alternative interface name to use. This option can be specified multiple times.
|
||||||
|
If the empty string is assigned to this option, the list is reset, and all prior assignments
|
||||||
|
- have no effect.</para>
|
||||||
|
+ have no effect. If the kernel does not support the alternative names, then this setting will
|
||||||
|
+ be ignored.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
|
||||||
|
index 4de8ee7d7e..8e88c8e5c4 100644
|
||||||
|
--- a/src/udev/net/link-config.c
|
||||||
|
+++ b/src/udev/net/link-config.c
|
||||||
|
@@ -474,7 +474,9 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
|
||||||
|
return log_warning_errno(r, "Could not set Alias=, MACAddress= or MTU= on %s: %m", old_name);
|
||||||
|
|
||||||
|
r = rtnl_set_link_alternative_names(&ctx->rtnl, ifindex, config->alternative_names);
|
||||||
|
- if (r < 0)
|
||||||
|
+ if (r == -EOPNOTSUPP)
|
||||||
|
+ log_debug_errno(r, "Could not set AlternativeName= on %s, ignoring: %m", old_name);
|
||||||
|
+ else if (r < 0)
|
||||||
|
return log_warning_errno(r, "Could not set AlternativeName= on %s: %m", old_name);
|
||||||
|
|
||||||
|
*name = new_name;
|
169
SOURCES/0648-udev-introduce-AlternativeNamesPolicy-setting.patch
Normal file
169
SOURCES/0648-udev-introduce-AlternativeNamesPolicy-setting.patch
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
From 4f47e35ee4026f24ee99a0bfa7ba5b2f24a92a02 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Mon, 16 Dec 2019 23:44:42 +0900
|
||||||
|
Subject: [PATCH] udev: introduce AlternativeNamesPolicy= setting
|
||||||
|
|
||||||
|
(cherry picked from commit ef1d2c07f9567dfea8a4e012d8779a4ded2d9ae6)
|
||||||
|
|
||||||
|
Resolves: #1850986
|
||||||
|
---
|
||||||
|
man/systemd.link.xml | 11 +++++
|
||||||
|
src/udev/net/link-config-gperf.gperf | 1 +
|
||||||
|
src/udev/net/link-config.c | 62 ++++++++++++++++++++++++++--
|
||||||
|
src/udev/net/link-config.h | 5 +++
|
||||||
|
4 files changed, 76 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/man/systemd.link.xml b/man/systemd.link.xml
|
||||||
|
index c8ebb751ee..13dcce0879 100644
|
||||||
|
--- a/man/systemd.link.xml
|
||||||
|
+++ b/man/systemd.link.xml
|
||||||
|
@@ -343,6 +343,17 @@
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
+ <varlistentry>
|
||||||
|
+ <term><varname>AlternativeNamesPolicy=</varname></term>
|
||||||
|
+ <listitem>
|
||||||
|
+ <para>A space-separated list of policies by which the interface's alternative names
|
||||||
|
+ should be set. Each of the policies may fail, and all successful policies are used. The
|
||||||
|
+ available policies are <literal>database</literal>, <literal>onboard</literal>,
|
||||||
|
+ <literal>slot</literal>, <literal>path</literal>, and <literal>mac</literal>. If the
|
||||||
|
+ kernel does not support the alternative names, then this setting will be ignored.
|
||||||
|
+ </para>
|
||||||
|
+ </listitem>
|
||||||
|
+ </varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><varname>AlternativeName=</varname></term>
|
||||||
|
<listitem>
|
||||||
|
diff --git a/src/udev/net/link-config-gperf.gperf b/src/udev/net/link-config-gperf.gperf
|
||||||
|
index 913c754145..df8404e7b8 100644
|
||||||
|
--- a/src/udev/net/link-config-gperf.gperf
|
||||||
|
+++ b/src/udev/net/link-config-gperf.gperf
|
||||||
|
@@ -35,6 +35,7 @@ Link.MACAddress, config_parse_hwaddr, 0,
|
||||||
|
Link.NamePolicy, config_parse_name_policy, 0, offsetof(link_config, name_policy)
|
||||||
|
Link.Name, config_parse_ifname, 0, offsetof(link_config, name)
|
||||||
|
Link.AlternativeName, config_parse_ifnames, 1, offsetof(link_config, alternative_names)
|
||||||
|
+Link.AlternativeNamesPolicy, config_parse_alternative_names_policy, 0, offsetof(link_config, alternative_names_policy)
|
||||||
|
Link.Alias, config_parse_ifalias, 0, offsetof(link_config, alias)
|
||||||
|
Link.MTUBytes, config_parse_mtu, AF_UNSPEC, offsetof(link_config, mtu)
|
||||||
|
Link.BitsPerSecond, config_parse_si_size, 0, offsetof(link_config, speed)
|
||||||
|
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
|
||||||
|
index 8e88c8e5c4..6ceb4c698e 100644
|
||||||
|
--- a/src/udev/net/link-config.c
|
||||||
|
+++ b/src/udev/net/link-config.c
|
||||||
|
@@ -69,6 +69,7 @@ static void link_config_free(link_config *link) {
|
||||||
|
free(link->name_policy);
|
||||||
|
free(link->name);
|
||||||
|
strv_free(link->alternative_names);
|
||||||
|
+ free(link->alternative_names_policy);
|
||||||
|
free(link->alias);
|
||||||
|
|
||||||
|
free(link);
|
||||||
|
@@ -349,6 +350,7 @@ static int get_mac(struct udev_device *device, bool want_random,
|
||||||
|
|
||||||
|
int link_config_apply(link_config_ctx *ctx, link_config *config,
|
||||||
|
struct udev_device *device, const char **name) {
|
||||||
|
+ _cleanup_strv_free_ char **altnames = NULL;
|
||||||
|
bool respect_predictable = false;
|
||||||
|
struct ether_addr generated_mac;
|
||||||
|
struct ether_addr *mac = NULL;
|
||||||
|
@@ -473,11 +475,52 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
|
||||||
|
if (r < 0)
|
||||||
|
return log_warning_errno(r, "Could not set Alias=, MACAddress= or MTU= on %s: %m", old_name);
|
||||||
|
|
||||||
|
- r = rtnl_set_link_alternative_names(&ctx->rtnl, ifindex, config->alternative_names);
|
||||||
|
+ if (config->alternative_names) {
|
||||||
|
+ altnames = strv_copy(config->alternative_names);
|
||||||
|
+ if (!altnames)
|
||||||
|
+ return log_oom();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (config->alternative_names_policy)
|
||||||
|
+ for (NamePolicy *p = config->alternative_names_policy; *p != _NAMEPOLICY_INVALID; p++) {
|
||||||
|
+ const char *n;
|
||||||
|
+
|
||||||
|
+ switch (*p) {
|
||||||
|
+ case NAMEPOLICY_DATABASE:
|
||||||
|
+ n = udev_device_get_property_value(device, "ID_NET_NAME_FROM_DATABASE");
|
||||||
|
+ break;
|
||||||
|
+ case NAMEPOLICY_ONBOARD:
|
||||||
|
+ n = udev_device_get_property_value(device, "ID_NET_NAME_ONBOARD");
|
||||||
|
+ break;
|
||||||
|
+ case NAMEPOLICY_SLOT:
|
||||||
|
+ n = udev_device_get_property_value(device, "ID_NET_NAME_SLOT");
|
||||||
|
+ break;
|
||||||
|
+ case NAMEPOLICY_PATH:
|
||||||
|
+ n = udev_device_get_property_value(device, "ID_NET_NAME_PATH");
|
||||||
|
+ break;
|
||||||
|
+ case NAMEPOLICY_MAC:
|
||||||
|
+ n = udev_device_get_property_value(device, "ID_NET_NAME_MAC");
|
||||||
|
+ break;
|
||||||
|
+ default:
|
||||||
|
+ assert_not_reached("invalid policy");
|
||||||
|
+ }
|
||||||
|
+ if (!isempty(n)) {
|
||||||
|
+ r = strv_extend(&altnames, n);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return log_oom();
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (new_name)
|
||||||
|
+ strv_remove(altnames, new_name);
|
||||||
|
+ strv_remove(altnames, old_name);
|
||||||
|
+ strv_uniq(altnames);
|
||||||
|
+
|
||||||
|
+ r = rtnl_set_link_alternative_names(&ctx->rtnl, ifindex, altnames);
|
||||||
|
if (r == -EOPNOTSUPP)
|
||||||
|
- log_debug_errno(r, "Could not set AlternativeName= on %s, ignoring: %m", old_name);
|
||||||
|
+ log_debug_errno(r, "Could not set AlternativeName= or apply AlternativeNamesPolicy= on %s, ignoring: %m", old_name);
|
||||||
|
else if (r < 0)
|
||||||
|
- return log_warning_errno(r, "Could not set AlternativeName= on %s: %m", old_name);
|
||||||
|
+ return log_warning_errno(r, "Could not set AlternativeName= or apply AlternativeNamesPolicy= on %s: %m", old_name);
|
||||||
|
|
||||||
|
*name = new_name;
|
||||||
|
|
||||||
|
@@ -524,3 +567,16 @@ DEFINE_STRING_TABLE_LOOKUP(name_policy, NamePolicy);
|
||||||
|
DEFINE_CONFIG_PARSE_ENUMV(config_parse_name_policy, name_policy, NamePolicy,
|
||||||
|
_NAMEPOLICY_INVALID,
|
||||||
|
"Failed to parse interface name policy");
|
||||||
|
+
|
||||||
|
+static const char* const alternative_names_policy_table[_NAMEPOLICY_MAX] = {
|
||||||
|
+ [NAMEPOLICY_DATABASE] = "database",
|
||||||
|
+ [NAMEPOLICY_ONBOARD] = "onboard",
|
||||||
|
+ [NAMEPOLICY_SLOT] = "slot",
|
||||||
|
+ [NAMEPOLICY_PATH] = "path",
|
||||||
|
+ [NAMEPOLICY_MAC] = "mac",
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+DEFINE_STRING_TABLE_LOOKUP(alternative_names_policy, NamePolicy);
|
||||||
|
+DEFINE_CONFIG_PARSE_ENUMV(config_parse_alternative_names_policy, alternative_names_policy, NamePolicy,
|
||||||
|
+ _NAMEPOLICY_INVALID,
|
||||||
|
+ "Failed to parse alternative names policy");
|
||||||
|
diff --git a/src/udev/net/link-config.h b/src/udev/net/link-config.h
|
||||||
|
index 93d5fdce59..634bd2ec54 100644
|
||||||
|
--- a/src/udev/net/link-config.h
|
||||||
|
+++ b/src/udev/net/link-config.h
|
||||||
|
@@ -49,6 +49,7 @@ struct link_config {
|
||||||
|
struct ether_addr *mac;
|
||||||
|
MACPolicy mac_policy;
|
||||||
|
NamePolicy *name_policy;
|
||||||
|
+ NamePolicy *alternative_names_policy;
|
||||||
|
char *name;
|
||||||
|
char **alternative_names;
|
||||||
|
char *alias;
|
||||||
|
@@ -78,6 +79,9 @@ int link_get_driver(link_config_ctx *ctx, struct udev_device *device, char **ret
|
||||||
|
const char *name_policy_to_string(NamePolicy p) _const_;
|
||||||
|
NamePolicy name_policy_from_string(const char *p) _pure_;
|
||||||
|
|
||||||
|
+const char *alternative_names_policy_to_string(NamePolicy p) _const_;
|
||||||
|
+NamePolicy alternative_names_policy_from_string(const char *p) _pure_;
|
||||||
|
+
|
||||||
|
const char *mac_policy_to_string(MACPolicy p) _const_;
|
||||||
|
MACPolicy mac_policy_from_string(const char *p) _pure_;
|
||||||
|
|
||||||
|
@@ -86,3 +90,4 @@ const struct ConfigPerfItem* link_config_gperf_lookup(const char *key, GPERF_LEN
|
||||||
|
|
||||||
|
int config_parse_mac_policy(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
||||||
|
int config_parse_name_policy(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
||||||
|
+int config_parse_alternative_names_policy(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
@ -0,0 +1,22 @@
|
|||||||
|
From 433d85ac89baa0683290cf8b5a913e7c6d666ef1 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Tue, 17 Dec 2019 00:30:38 +0900
|
||||||
|
Subject: [PATCH] network: set AlternativeNamesPolicy= in 99-default.link
|
||||||
|
|
||||||
|
(cherry picked from commit 49f5cbe92484a6661bccc0ae6c547bc5767c83bf)
|
||||||
|
|
||||||
|
Related: #1850986
|
||||||
|
---
|
||||||
|
network/99-default.link | 1 +
|
||||||
|
1 file changed, 1 insertion(+)
|
||||||
|
|
||||||
|
diff --git a/network/99-default.link b/network/99-default.link
|
||||||
|
index 561bf329e4..58c0b74a7c 100644
|
||||||
|
--- a/network/99-default.link
|
||||||
|
+++ b/network/99-default.link
|
||||||
|
@@ -9,4 +9,5 @@
|
||||||
|
|
||||||
|
[Link]
|
||||||
|
NamePolicy=kernel database onboard slot path
|
||||||
|
+AlternativeNamesPolicy=database onboard slot path
|
||||||
|
MACAddressPolicy=persistent
|
@ -0,0 +1,59 @@
|
|||||||
|
From c4c771f2dc5c590990d1f9105886b833afa59852 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Mon, 16 Dec 2019 19:47:48 +0900
|
||||||
|
Subject: [PATCH] random-util: call initialize_srand() after fork()
|
||||||
|
|
||||||
|
(cherry picked from commit a0f11d1d11a546f791855ec9c47c2ff830e6a5aa)
|
||||||
|
|
||||||
|
Related: #1850986
|
||||||
|
---
|
||||||
|
src/basic/random-util.c | 14 +++++++++++++-
|
||||||
|
1 file changed, 13 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/src/basic/random-util.c b/src/basic/random-util.c
|
||||||
|
index 91481559db..801f6ad131 100644
|
||||||
|
--- a/src/basic/random-util.c
|
||||||
|
+++ b/src/basic/random-util.c
|
||||||
|
@@ -4,6 +4,7 @@
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <linux/random.h>
|
||||||
|
+#include <pthread.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
@@ -26,6 +27,8 @@
|
||||||
|
#include "random-util.h"
|
||||||
|
#include "time-util.h"
|
||||||
|
|
||||||
|
+static bool srand_called = false;
|
||||||
|
+
|
||||||
|
int acquire_random_bytes(void *p, size_t n, bool high_quality_required) {
|
||||||
|
static int have_syscall = -1;
|
||||||
|
|
||||||
|
@@ -81,8 +84,12 @@ int acquire_random_bytes(void *p, size_t n, bool high_quality_required) {
|
||||||
|
return loop_read_exact(fd, (uint8_t*) p + already_done, n - already_done, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void clear_srand_initialization(void) {
|
||||||
|
+ srand_called = false;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void initialize_srand(void) {
|
||||||
|
- static bool srand_called = false;
|
||||||
|
+ static bool pthread_atfork_registered = false;
|
||||||
|
unsigned x;
|
||||||
|
#if HAVE_SYS_AUXV_H
|
||||||
|
void *auxv;
|
||||||
|
@@ -109,6 +116,11 @@ void initialize_srand(void) {
|
||||||
|
|
||||||
|
srand(x);
|
||||||
|
srand_called = true;
|
||||||
|
+
|
||||||
|
+ if (!pthread_atfork_registered) {
|
||||||
|
+ (void) pthread_atfork(NULL, NULL, clear_srand_initialization);
|
||||||
|
+ pthread_atfork_registered = true;
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* INT_MAX gives us only 31 bits, so use 24 out of that. */
|
@ -0,0 +1,78 @@
|
|||||||
|
From 8db22aec9bfd140855b64f2879b7ca6d1cba69c6 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Tue, 17 Dec 2019 18:28:36 +0900
|
||||||
|
Subject: [PATCH] sd-netlink: introduce rtnl_resolve_link_alternative_names()
|
||||||
|
|
||||||
|
(cherry picked from commit b04c5e51da7a61d41d564e73a1e92bd8b29b0223)
|
||||||
|
|
||||||
|
Related: #1850986
|
||||||
|
---
|
||||||
|
src/libsystemd/sd-netlink/netlink-types.c | 1 +
|
||||||
|
src/libsystemd/sd-netlink/netlink-util.c | 29 +++++++++++++++++++++++
|
||||||
|
src/libsystemd/sd-netlink/netlink-util.h | 1 +
|
||||||
|
3 files changed, 31 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/src/libsystemd/sd-netlink/netlink-types.c b/src/libsystemd/sd-netlink/netlink-types.c
|
||||||
|
index 47d9c7f1c4..e118a0aa30 100644
|
||||||
|
--- a/src/libsystemd/sd-netlink/netlink-types.c
|
||||||
|
+++ b/src/libsystemd/sd-netlink/netlink-types.c
|
||||||
|
@@ -511,6 +511,7 @@ static const NLType rtnl_link_types[] = {
|
||||||
|
[IFLA_PHYS_PORT_ID] = { .type = NETLINK_TYPE_BINARY, .len = MAX_PHYS_PORT_ID_LEN },
|
||||||
|
*/
|
||||||
|
[IFLA_PROP_LIST] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_prop_list_type_system },
|
||||||
|
+ [IFLA_ALT_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = ALTIFNAMSIZ - 1 },
|
||||||
|
};
|
||||||
|
|
||||||
|
static const NLTypeSystem rtnl_link_type_system = {
|
||||||
|
diff --git a/src/libsystemd/sd-netlink/netlink-util.c b/src/libsystemd/sd-netlink/netlink-util.c
|
||||||
|
index c1c306f121..62fc71a3d8 100644
|
||||||
|
--- a/src/libsystemd/sd-netlink/netlink-util.c
|
||||||
|
+++ b/src/libsystemd/sd-netlink/netlink-util.c
|
||||||
|
@@ -120,6 +120,35 @@ int rtnl_set_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+int rtnl_resolve_link_alternative_name(sd_netlink **rtnl, const char *name, int *ret) {
|
||||||
|
+ _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL, *reply = NULL;
|
||||||
|
+ int r;
|
||||||
|
+
|
||||||
|
+ assert(rtnl);
|
||||||
|
+ assert(name);
|
||||||
|
+ assert(ret);
|
||||||
|
+
|
||||||
|
+ if (!*rtnl) {
|
||||||
|
+ r = sd_netlink_open(rtnl);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ r = sd_rtnl_message_new_link(*rtnl, &message, RTM_GETLINK, 0);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
+
|
||||||
|
+ r = sd_netlink_message_append_string(message, IFLA_ALT_IFNAME, name);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
+
|
||||||
|
+ r = sd_netlink_call(*rtnl, message, 0, &reply);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
+
|
||||||
|
+ return sd_rtnl_message_link_get_ifindex(reply, ret);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
int rtnl_message_new_synthetic_error(sd_netlink *rtnl, int error, uint32_t serial, sd_netlink_message **ret) {
|
||||||
|
struct nlmsgerr *err;
|
||||||
|
int r;
|
||||||
|
diff --git a/src/libsystemd/sd-netlink/netlink-util.h b/src/libsystemd/sd-netlink/netlink-util.h
|
||||||
|
index 92de19c092..ea98439fad 100644
|
||||||
|
--- a/src/libsystemd/sd-netlink/netlink-util.h
|
||||||
|
+++ b/src/libsystemd/sd-netlink/netlink-util.h
|
||||||
|
@@ -39,6 +39,7 @@ static inline bool rtnl_message_type_is_routing_policy_rule(uint16_t type) {
|
||||||
|
int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name);
|
||||||
|
int rtnl_set_link_properties(sd_netlink **rtnl, int ifindex, const char *alias, const struct ether_addr *mac, uint32_t mtu);
|
||||||
|
int rtnl_set_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const *alternative_names);
|
||||||
|
+int rtnl_resolve_link_alternative_name(sd_netlink **rtnl, const char *name, int *ret);
|
||||||
|
|
||||||
|
int rtnl_log_parse_error(int r);
|
||||||
|
int rtnl_log_create_error(int r);
|
27
SOURCES/0652-udev-sort-alternative-names.patch
Normal file
27
SOURCES/0652-udev-sort-alternative-names.patch
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
From eeea9a2f94b5defb97c20c62a23345a367a734aa Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Tue, 17 Dec 2019 20:41:21 +0900
|
||||||
|
Subject: [PATCH] udev: sort alternative names
|
||||||
|
|
||||||
|
Kernel preserves the order of alternative names. So, for user
|
||||||
|
visibility, let's sort the alternative names.
|
||||||
|
|
||||||
|
(cherry picked from commit 4d016e965b13883cccc963a34a1299a0c4f900ca)
|
||||||
|
|
||||||
|
Related: #1850986
|
||||||
|
---
|
||||||
|
src/udev/net/link-config.c | 1 +
|
||||||
|
1 file changed, 1 insertion(+)
|
||||||
|
|
||||||
|
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
|
||||||
|
index 6ceb4c698e..8bd374d352 100644
|
||||||
|
--- a/src/udev/net/link-config.c
|
||||||
|
+++ b/src/udev/net/link-config.c
|
||||||
|
@@ -515,6 +515,7 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
|
||||||
|
strv_remove(altnames, new_name);
|
||||||
|
strv_remove(altnames, old_name);
|
||||||
|
strv_uniq(altnames);
|
||||||
|
+ strv_sort(altnames);
|
||||||
|
|
||||||
|
r = rtnl_set_link_alternative_names(&ctx->rtnl, ifindex, altnames);
|
||||||
|
if (r == -EOPNOTSUPP)
|
@ -0,0 +1,102 @@
|
|||||||
|
From 8f946da7ee9bbb6e52e99b452c1f4f6f76e7b3c2 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Fri, 17 Jul 2020 21:29:13 +0900
|
||||||
|
Subject: [PATCH] netlink: introduce rtnl_get/delete_link_alternative_names()
|
||||||
|
|
||||||
|
(cherry picked from commit 14982526145de84201c7e3b4fc6be6aa5e9a08f7)
|
||||||
|
|
||||||
|
Related: #1850986
|
||||||
|
---
|
||||||
|
src/libsystemd/sd-netlink/netlink-util.c | 45 ++++++++++++++++++++++--
|
||||||
|
src/libsystemd/sd-netlink/netlink-util.h | 2 ++
|
||||||
|
2 files changed, 45 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/libsystemd/sd-netlink/netlink-util.c b/src/libsystemd/sd-netlink/netlink-util.c
|
||||||
|
index 62fc71a3d8..7f09261981 100644
|
||||||
|
--- a/src/libsystemd/sd-netlink/netlink-util.c
|
||||||
|
+++ b/src/libsystemd/sd-netlink/netlink-util.c
|
||||||
|
@@ -81,12 +81,45 @@ int rtnl_set_link_properties(sd_netlink **rtnl, int ifindex, const char *alias,
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
-int rtnl_set_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const *alternative_names) {
|
||||||
|
+int rtnl_get_link_alternative_names(sd_netlink **rtnl, int ifindex, char ***ret) {
|
||||||
|
+ _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL, *reply = NULL;
|
||||||
|
+ _cleanup_strv_free_ char **names = NULL;
|
||||||
|
+ int r;
|
||||||
|
+
|
||||||
|
+ assert(rtnl);
|
||||||
|
+ assert(ifindex > 0);
|
||||||
|
+ assert(ret);
|
||||||
|
+
|
||||||
|
+ if (!*rtnl) {
|
||||||
|
+ r = sd_netlink_open(rtnl);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ r = sd_rtnl_message_new_link(*rtnl, &message, RTM_GETLINK, ifindex);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
+
|
||||||
|
+ r = sd_netlink_call(*rtnl, message, 0, &reply);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
+
|
||||||
|
+ r = sd_netlink_message_read_strv(reply, IFLA_PROP_LIST, IFLA_ALT_IFNAME, &names);
|
||||||
|
+ if (r < 0 && r != -ENODATA)
|
||||||
|
+ return r;
|
||||||
|
+
|
||||||
|
+ *ret = TAKE_PTR(names);
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int rtnl_update_link_alternative_names(sd_netlink **rtnl, uint16_t nlmsg_type, int ifindex, char * const *alternative_names) {
|
||||||
|
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(rtnl);
|
||||||
|
assert(ifindex > 0);
|
||||||
|
+ assert(IN_SET(nlmsg_type, RTM_NEWLINKPROP, RTM_DELLINKPROP));
|
||||||
|
|
||||||
|
if (strv_isempty(alternative_names))
|
||||||
|
return 0;
|
||||||
|
@@ -97,7 +130,7 @@ int rtnl_set_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
- r = sd_rtnl_message_new_link(*rtnl, &message, RTM_NEWLINKPROP, ifindex);
|
||||||
|
+ r = sd_rtnl_message_new_link(*rtnl, &message, nlmsg_type, ifindex);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
@@ -120,6 +153,14 @@ int rtnl_set_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+int rtnl_set_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const *alternative_names) {
|
||||||
|
+ return rtnl_update_link_alternative_names(rtnl, RTM_NEWLINKPROP, ifindex, alternative_names);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+int rtnl_delete_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const *alternative_names) {
|
||||||
|
+ return rtnl_update_link_alternative_names(rtnl, RTM_DELLINKPROP, ifindex, alternative_names);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
int rtnl_resolve_link_alternative_name(sd_netlink **rtnl, const char *name, int *ret) {
|
||||||
|
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL, *reply = NULL;
|
||||||
|
int r;
|
||||||
|
diff --git a/src/libsystemd/sd-netlink/netlink-util.h b/src/libsystemd/sd-netlink/netlink-util.h
|
||||||
|
index ea98439fad..4fc31aa274 100644
|
||||||
|
--- a/src/libsystemd/sd-netlink/netlink-util.h
|
||||||
|
+++ b/src/libsystemd/sd-netlink/netlink-util.h
|
||||||
|
@@ -38,7 +38,9 @@ static inline bool rtnl_message_type_is_routing_policy_rule(uint16_t type) {
|
||||||
|
|
||||||
|
int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name);
|
||||||
|
int rtnl_set_link_properties(sd_netlink **rtnl, int ifindex, const char *alias, const struct ether_addr *mac, uint32_t mtu);
|
||||||
|
+int rtnl_get_link_alternative_names(sd_netlink **rtnl, int ifindex, char ***ret);
|
||||||
|
int rtnl_set_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const *alternative_names);
|
||||||
|
+int rtnl_delete_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const *alternative_names);
|
||||||
|
int rtnl_resolve_link_alternative_name(sd_netlink **rtnl, const char *name, int *ret);
|
||||||
|
|
||||||
|
int rtnl_log_parse_error(int r);
|
@ -0,0 +1,81 @@
|
|||||||
|
From 6db267672de69d6bf4809f433cde106e11145ca8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Fri, 17 Jul 2020 21:31:24 +0900
|
||||||
|
Subject: [PATCH] netlink: do not fail when new interface name is already used
|
||||||
|
as an alternative name
|
||||||
|
|
||||||
|
When renaming a network interface, the new name may be used as an
|
||||||
|
alternative name. In that case, let's swap the current name and the
|
||||||
|
alternative name. That is, first drop the new name from the list of
|
||||||
|
alternative names, then rename the interface, finally set the old name
|
||||||
|
as an alternative name.
|
||||||
|
|
||||||
|
(cherry picked from commit 434a34838034347f45fb9a47df55b1a36e5addfd)
|
||||||
|
|
||||||
|
Related: #1850986
|
||||||
|
---
|
||||||
|
src/libsystemd/sd-netlink/netlink-util.c | 30 +++++++++++++++++++++---
|
||||||
|
1 file changed, 27 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/libsystemd/sd-netlink/netlink-util.c b/src/libsystemd/sd-netlink/netlink-util.c
|
||||||
|
index 7f09261981..4e42ef9e26 100644
|
||||||
|
--- a/src/libsystemd/sd-netlink/netlink-util.c
|
||||||
|
+++ b/src/libsystemd/sd-netlink/netlink-util.c
|
||||||
|
@@ -1,23 +1,40 @@
|
||||||
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
|
|
||||||
|
+#include <net/if.h>
|
||||||
|
+
|
||||||
|
#include "sd-netlink.h"
|
||||||
|
|
||||||
|
#include "netlink-internal.h"
|
||||||
|
#include "netlink-util.h"
|
||||||
|
+#include "socket-util.h"
|
||||||
|
+#include "string-util.h"
|
||||||
|
#include "strv.h"
|
||||||
|
|
||||||
|
int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name) {
|
||||||
|
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL;
|
||||||
|
+ _cleanup_strv_free_ char **alternative_names = NULL;
|
||||||
|
+ char old_name[IF_NAMESIZE + 1] = {};
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(rtnl);
|
||||||
|
assert(ifindex > 0);
|
||||||
|
assert(name);
|
||||||
|
|
||||||
|
- if (!*rtnl) {
|
||||||
|
- r = sd_netlink_open(rtnl);
|
||||||
|
+ if (!ifname_valid(name))
|
||||||
|
+ return -EINVAL;
|
||||||
|
+
|
||||||
|
+ r = rtnl_get_link_alternative_names(rtnl, ifindex, &alternative_names);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ log_debug_errno(r, "Failed to get alternative names on network interface %i, ignoring: %m",
|
||||||
|
+ ifindex);
|
||||||
|
+
|
||||||
|
+ if (strv_contains(alternative_names, name)) {
|
||||||
|
+ r = rtnl_delete_link_alternative_names(rtnl, ifindex, STRV_MAKE(name));
|
||||||
|
if (r < 0)
|
||||||
|
- return r;
|
||||||
|
+ return log_debug_errno(r, "Failed to remove '%s' from alternative names on network interface %i: %m",
|
||||||
|
+ name, ifindex);
|
||||||
|
+
|
||||||
|
+ if_indextoname(ifindex, old_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
r = sd_rtnl_message_new_link(*rtnl, &message, RTM_SETLINK, ifindex);
|
||||||
|
@@ -32,6 +49,13 @@ int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name) {
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
+ if (!isempty(old_name)) {
|
||||||
|
+ r = rtnl_set_link_alternative_names(rtnl, ifindex, STRV_MAKE(old_name));
|
||||||
|
+ if (r < 0)
|
||||||
|
+ log_debug_errno(r, "Failed to set '%s' as an alternative name on network interface %i, ignoring: %m",
|
||||||
|
+ old_name, ifindex);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
|||||||
|
From 817a707daf1e9fa4f20eba04ce1c52af7518e355 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||||
|
Date: Fri, 17 Jul 2020 21:36:05 +0900
|
||||||
|
Subject: [PATCH] udev: do not try to reassign alternative names
|
||||||
|
|
||||||
|
Setting alternative names may fail if some of them are already assigned.
|
||||||
|
|
||||||
|
(cherry picked from commit 97fdae33dfe8e7e0a4e5230564f6cdebc4450eec)
|
||||||
|
|
||||||
|
Related: #1850986
|
||||||
|
---
|
||||||
|
src/udev/net/link-config.c | 12 ++++++++++--
|
||||||
|
1 file changed, 10 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
|
||||||
|
index 8bd374d352..5220f247f0 100644
|
||||||
|
--- a/src/udev/net/link-config.c
|
||||||
|
+++ b/src/udev/net/link-config.c
|
||||||
|
@@ -350,7 +350,7 @@ static int get_mac(struct udev_device *device, bool want_random,
|
||||||
|
|
||||||
|
int link_config_apply(link_config_ctx *ctx, link_config *config,
|
||||||
|
struct udev_device *device, const char **name) {
|
||||||
|
- _cleanup_strv_free_ char **altnames = NULL;
|
||||||
|
+ _cleanup_strv_free_ char **altnames = NULL, **current_altnames = NULL;
|
||||||
|
bool respect_predictable = false;
|
||||||
|
struct ether_addr generated_mac;
|
||||||
|
struct ether_addr *mac = NULL;
|
||||||
|
@@ -514,9 +514,17 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
|
||||||
|
if (new_name)
|
||||||
|
strv_remove(altnames, new_name);
|
||||||
|
strv_remove(altnames, old_name);
|
||||||
|
+
|
||||||
|
+ r = rtnl_get_link_alternative_names(&ctx->rtnl, ifindex, ¤t_altnames);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ log_debug_errno(r, "Failed to get alternative names on %s, ignoring: %m", old_name);
|
||||||
|
+
|
||||||
|
+ char **p;
|
||||||
|
+ STRV_FOREACH(p, current_altnames)
|
||||||
|
+ strv_remove(altnames, *p);
|
||||||
|
+
|
||||||
|
strv_uniq(altnames);
|
||||||
|
strv_sort(altnames);
|
||||||
|
-
|
||||||
|
r = rtnl_set_link_alternative_names(&ctx->rtnl, ifindex, altnames);
|
||||||
|
if (r == -EOPNOTSUPP)
|
||||||
|
log_debug_errno(r, "Could not set AlternativeName= or apply AlternativeNamesPolicy= on %s, ignoring: %m", old_name);
|
37
SOURCES/0656-Fix-LGTM-build.patch
Normal file
37
SOURCES/0656-Fix-LGTM-build.patch
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
From 93c42f4da4563d225e3a2b9e72e8f9bb50d86bb1 Mon Sep 17 00:00:00 2001
|
||||||
|
From: David Tardon <dtardon@redhat.com>
|
||||||
|
Date: Fri, 17 Sep 2021 15:10:03 +0200
|
||||||
|
Subject: [PATCH] Fix LGTM build
|
||||||
|
|
||||||
|
Related: #1850986
|
||||||
|
---
|
||||||
|
src/network/netdev/netdev.c | 2 +-
|
||||||
|
src/network/networkd-network.c | 2 +-
|
||||||
|
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/network/netdev/netdev.c b/src/network/netdev/netdev.c
|
||||||
|
index 82ce88402f..e97cc07028 100644
|
||||||
|
--- a/src/network/netdev/netdev.c
|
||||||
|
+++ b/src/network/netdev/netdev.c
|
||||||
|
@@ -640,7 +640,7 @@ static int netdev_load_one(Manager *manager, const char *filename) {
|
||||||
|
netdev_raw->match_host, netdev_raw->match_virt,
|
||||||
|
netdev_raw->match_kernel_cmdline, netdev_raw->match_kernel_version,
|
||||||
|
netdev_raw->match_arch,
|
||||||
|
- NULL, NULL, NULL, NULL, NULL, NULL) <= 0)
|
||||||
|
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL) <= 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (netdev_raw->kind == _NETDEV_KIND_INVALID) {
|
||||||
|
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
|
||||||
|
index 429aac5e6c..7637d135a4 100644
|
||||||
|
--- a/src/network/networkd-network.c
|
||||||
|
+++ b/src/network/networkd-network.c
|
||||||
|
@@ -479,7 +479,7 @@ int network_get(Manager *manager, struct udev_device *device,
|
||||||
|
network->match_virt, network->match_kernel_cmdline,
|
||||||
|
network->match_kernel_version, network->match_arch,
|
||||||
|
address, path, parent_driver, driver,
|
||||||
|
- devtype, ifname)) {
|
||||||
|
+ devtype, ifname, NULL)) {
|
||||||
|
if (network->match_name && device) {
|
||||||
|
const char *attr;
|
||||||
|
uint8_t name_assign_type = NET_NAME_UNKNOWN;
|
33
SOURCES/0657-sd-hwdb-allow-empty-properties.patch
Normal file
33
SOURCES/0657-sd-hwdb-allow-empty-properties.patch
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
From cd407514366a2ec2c32ebc7a5b405d37005456fd Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||||
|
Date: Tue, 20 Oct 2020 17:12:42 +0200
|
||||||
|
Subject: [PATCH] sd-hwdb: allow empty properties
|
||||||
|
|
||||||
|
So far we didn't allow empty properties, but it makes sense to do so, for
|
||||||
|
example to distinguish empty data from lack of data. It also makes it easy to
|
||||||
|
override properties (back to the empty) value for specific cases.
|
||||||
|
|
||||||
|
(cherry picked from commit afe87974dd57741f74dd87165b251886f24c859f)
|
||||||
|
|
||||||
|
Related: #1930568
|
||||||
|
---
|
||||||
|
src/hwdb/hwdb.c | 5 ++---
|
||||||
|
1 file changed, 2 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/hwdb/hwdb.c b/src/hwdb/hwdb.c
|
||||||
|
index 317cad8a67..af085cdb75 100644
|
||||||
|
--- a/src/hwdb/hwdb.c
|
||||||
|
+++ b/src/hwdb/hwdb.c
|
||||||
|
@@ -462,10 +462,9 @@ static int insert_data(struct trie *trie, char **match_list, char *line,
|
||||||
|
while (isblank(line[0]) && isblank(line[1]))
|
||||||
|
line++;
|
||||||
|
|
||||||
|
- if (isempty(line + 1) || isempty(value))
|
||||||
|
+ if (isempty(line + 1))
|
||||||
|
return log_syntax(NULL, LOG_WARNING, filename, line_number, EINVAL,
|
||||||
|
- "Empty %s in \"%s=%s\", ignoring",
|
||||||
|
- isempty(line + 1) ? "key" : "value",
|
||||||
|
+ "Empty key in \"%s=%s\", ignoring",
|
||||||
|
line, value);
|
||||||
|
|
||||||
|
STRV_FOREACH(entry, match_list)
|
104589
SOURCES/0658-Update-hwdb.patch
Normal file
104589
SOURCES/0658-Update-hwdb.patch
Normal file
File diff suppressed because it is too large
Load Diff
@ -13,7 +13,7 @@
|
|||||||
Name: systemd
|
Name: systemd
|
||||||
Url: http://www.freedesktop.org/wiki/Software/systemd
|
Url: http://www.freedesktop.org/wiki/Software/systemd
|
||||||
Version: 239
|
Version: 239
|
||||||
Release: 50%{?dist}
|
Release: 51%{?dist}
|
||||||
# For a breakdown of the licensing, see README
|
# For a breakdown of the licensing, see README
|
||||||
License: LGPLv2+ and MIT and GPLv2+
|
License: LGPLv2+ and MIT and GPLv2+
|
||||||
Summary: System and Service Manager
|
Summary: System and Service Manager
|
||||||
@ -686,6 +686,28 @@ Patch0633: 0633-logind-improve-error-propagation-of-user_check_linge.patch
|
|||||||
Patch0634: 0634-logind-automatically-GC-lingering-users-for-who-now-.patch
|
Patch0634: 0634-logind-automatically-GC-lingering-users-for-who-now-.patch
|
||||||
Patch0635: 0635-pam_systemd-simplify-code-which-with-we-set-environm.patch
|
Patch0635: 0635-pam_systemd-simplify-code-which-with-we-set-environm.patch
|
||||||
Patch0636: 0636-logind-validate-run-user-1000-before-we-set-it.patch
|
Patch0636: 0636-logind-validate-run-user-1000-before-we-set-it.patch
|
||||||
|
Patch0637: 0637-define-newly-needed-constants.patch
|
||||||
|
Patch0638: 0638-sd-netlink-support-IFLA_PROP_LIST-and-IFLA_ALT_IFNAM.patch
|
||||||
|
Patch0639: 0639-sd-netlink-introduce-sd_netlink_message_read_strv.patch
|
||||||
|
Patch0640: 0640-sd-netlink-introduce-sd_netlink_message_append_strv.patch
|
||||||
|
Patch0641: 0641-test-add-a-test-for-sd_netlink_message_-append-read-.patch
|
||||||
|
Patch0642: 0642-util-introduce-ifname_valid_full.patch
|
||||||
|
Patch0643: 0643-rename-function.patch
|
||||||
|
Patch0644: 0644-udev-support-AlternativeName-setting-in-.link-file.patch
|
||||||
|
Patch0645: 0645-network-make-Name-in-Match-support-alternative-names.patch
|
||||||
|
Patch0646: 0646-udev-extend-the-length-of-ID_NET_NAME_XXX-to-ALTIFNA.patch
|
||||||
|
Patch0647: 0647-udev-do-not-fail-if-kernel-does-not-support-alternat.patch
|
||||||
|
Patch0648: 0648-udev-introduce-AlternativeNamesPolicy-setting.patch
|
||||||
|
Patch0649: 0649-network-set-AlternativeNamesPolicy-in-99-default.lin.patch
|
||||||
|
Patch0650: 0650-random-util-call-initialize_srand-after-fork.patch
|
||||||
|
Patch0651: 0651-sd-netlink-introduce-rtnl_resolve_link_alternative_n.patch
|
||||||
|
Patch0652: 0652-udev-sort-alternative-names.patch
|
||||||
|
Patch0653: 0653-netlink-introduce-rtnl_get-delete_link_alternative_n.patch
|
||||||
|
Patch0654: 0654-netlink-do-not-fail-when-new-interface-name-is-alrea.patch
|
||||||
|
Patch0655: 0655-udev-do-not-try-to-reassign-alternative-names.patch
|
||||||
|
Patch0656: 0656-Fix-LGTM-build.patch
|
||||||
|
Patch0657: 0657-sd-hwdb-allow-empty-properties.patch
|
||||||
|
Patch0658: 0658-Update-hwdb.patch
|
||||||
|
|
||||||
|
|
||||||
%ifarch %{ix86} x86_64 aarch64
|
%ifarch %{ix86} x86_64 aarch64
|
||||||
@ -1313,6 +1335,30 @@ fi
|
|||||||
%files tests -f .file-list-tests
|
%files tests -f .file-list-tests
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Sep 23 2021 systemd maintenance team <systemd-maint@redhat.com> - 239-51
|
||||||
|
- define newly needed constants (#1850986)
|
||||||
|
- sd-netlink: support IFLA_PROP_LIST and IFLA_ALT_IFNAME attributes (#1850986)
|
||||||
|
- sd-netlink: introduce sd_netlink_message_read_strv() (#1850986)
|
||||||
|
- sd-netlink: introduce sd_netlink_message_append_strv() (#1850986)
|
||||||
|
- test: add a test for sd_netlink_message_{append,read}_strv() (#1850986)
|
||||||
|
- util: introduce ifname_valid_full() (#1850986)
|
||||||
|
- rename function (#1850986)
|
||||||
|
- udev: support AlternativeName= setting in .link file (#1850986)
|
||||||
|
- network: make Name= in [Match] support alternative names of interfaces (#1850986)
|
||||||
|
- udev: extend the length of ID_NET_NAME_XXX= to ALTIFNAMSIZ (#1850986)
|
||||||
|
- udev: do not fail if kernel does not support alternative names (#1850986)
|
||||||
|
- udev: introduce AlternativeNamesPolicy= setting (#1850986)
|
||||||
|
- network: set AlternativeNamesPolicy= in 99-default.link (#1850986)
|
||||||
|
- random-util: call initialize_srand() after fork() (#1850986)
|
||||||
|
- sd-netlink: introduce rtnl_resolve_link_alternative_names() (#1850986)
|
||||||
|
- udev: sort alternative names (#1850986)
|
||||||
|
- netlink: introduce rtnl_get/delete_link_alternative_names() (#1850986)
|
||||||
|
- netlink: do not fail when new interface name is already used as an alternative name (#1850986)
|
||||||
|
- udev: do not try to reassign alternative names (#1850986)
|
||||||
|
- Fix LGTM build (#1850986)
|
||||||
|
- sd-hwdb: allow empty properties (#1930568)
|
||||||
|
- Update hwdb (#1930568)
|
||||||
|
|
||||||
* Fri Aug 27 2021 systemd maintenance team <systemd-maint@redhat.com> - 239-50
|
* Fri Aug 27 2021 systemd maintenance team <systemd-maint@redhat.com> - 239-50
|
||||||
- Added option --check-inhibitors for non-tty usage (#1269726)
|
- Added option --check-inhibitors for non-tty usage (#1269726)
|
||||||
- logind: Introduce RebootWithFlags and others (#1269726)
|
- logind: Introduce RebootWithFlags and others (#1269726)
|
||||||
|
Loading…
Reference in New Issue
Block a user