|
|
a8c905 |
From b0b98085bb0b95395b686efca43980d463749f3d Mon Sep 17 00:00:00 2001
|
|
|
a8c905 |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
a8c905 |
Date: Sun, 15 Dec 2019 20:57:51 +0900
|
|
|
a8c905 |
Subject: [PATCH] sd-netlink: support IFLA_PROP_LIST and IFLA_ALT_IFNAME
|
|
|
a8c905 |
attributes
|
|
|
a8c905 |
|
|
|
a8c905 |
(cherry picked from commit ffeb16f5d832b1c65b8c8a1dd9bdd028bd76fc72)
|
|
|
a8c905 |
|
|
|
a8c905 |
Related: #1850986
|
|
|
a8c905 |
---
|
|
|
a8c905 |
src/libsystemd/sd-netlink/netlink-message.c | 2 +-
|
|
|
a8c905 |
src/libsystemd/sd-netlink/netlink-types.c | 13 +++++++++++++
|
|
|
a8c905 |
src/libsystemd/sd-netlink/netlink-util.h | 4 +++-
|
|
|
a8c905 |
src/libsystemd/sd-netlink/rtnl-message.c | 2 ++
|
|
|
a8c905 |
4 files changed, 19 insertions(+), 2 deletions(-)
|
|
|
a8c905 |
|
|
|
a8c905 |
diff --git a/src/libsystemd/sd-netlink/netlink-message.c b/src/libsystemd/sd-netlink/netlink-message.c
|
|
|
a8c905 |
index 23907c8224..db9101c163 100644
|
|
|
a8c905 |
--- a/src/libsystemd/sd-netlink/netlink-message.c
|
|
|
a8c905 |
+++ b/src/libsystemd/sd-netlink/netlink-message.c
|
|
|
a8c905 |
@@ -89,7 +89,7 @@ int sd_netlink_message_request_dump(sd_netlink_message *m, int dump) {
|
|
|
a8c905 |
assert_return(m, -EINVAL);
|
|
|
a8c905 |
assert_return(m->hdr, -EINVAL);
|
|
|
a8c905 |
|
|
|
a8c905 |
- assert_return(IN_SET(m->hdr->nlmsg_type, RTM_GETLINK, RTM_GETADDR, RTM_GETROUTE, RTM_GETNEIGH, RTM_GETRULE, RTM_GETADDRLABEL), -EINVAL);
|
|
|
a8c905 |
+ assert_return(IN_SET(m->hdr->nlmsg_type, RTM_GETLINK, RTM_GETLINKPROP, RTM_GETADDR, RTM_GETROUTE, RTM_GETNEIGH, RTM_GETRULE, RTM_GETADDRLABEL), -EINVAL);
|
|
|
a8c905 |
|
|
|
a8c905 |
SET_FLAG(m->hdr->nlmsg_flags, NLM_F_DUMP, dump);
|
|
|
a8c905 |
|
|
|
a8c905 |
diff --git a/src/libsystemd/sd-netlink/netlink-types.c b/src/libsystemd/sd-netlink/netlink-types.c
|
|
|
a8c905 |
index c93fe9cb4c..47d9c7f1c4 100644
|
|
|
a8c905 |
--- a/src/libsystemd/sd-netlink/netlink-types.c
|
|
|
a8c905 |
+++ b/src/libsystemd/sd-netlink/netlink-types.c
|
|
|
a8c905 |
@@ -451,6 +451,15 @@ static const NLTypeSystem rtnl_af_spec_type_system = {
|
|
|
a8c905 |
.types = rtnl_af_spec_types,
|
|
|
a8c905 |
};
|
|
|
a8c905 |
|
|
|
a8c905 |
+static const NLType rtnl_prop_list_types[] = {
|
|
|
a8c905 |
+ [IFLA_ALT_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = ALTIFNAMSIZ - 1 },
|
|
|
a8c905 |
+};
|
|
|
a8c905 |
+
|
|
|
a8c905 |
+static const NLTypeSystem rtnl_prop_list_type_system = {
|
|
|
a8c905 |
+ .count = ELEMENTSOF(rtnl_prop_list_types),
|
|
|
a8c905 |
+ .types = rtnl_prop_list_types,
|
|
|
a8c905 |
+};
|
|
|
a8c905 |
+
|
|
|
a8c905 |
static const NLType rtnl_link_types[] = {
|
|
|
a8c905 |
[IFLA_ADDRESS] = { .type = NETLINK_TYPE_ETHER_ADDR },
|
|
|
a8c905 |
[IFLA_BROADCAST] = { .type = NETLINK_TYPE_ETHER_ADDR },
|
|
|
a8c905 |
@@ -501,6 +510,7 @@ static const NLType rtnl_link_types[] = {
|
|
|
a8c905 |
/*
|
|
|
a8c905 |
[IFLA_PHYS_PORT_ID] = { .type = NETLINK_TYPE_BINARY, .len = MAX_PHYS_PORT_ID_LEN },
|
|
|
a8c905 |
*/
|
|
|
a8c905 |
+ [IFLA_PROP_LIST] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_prop_list_type_system },
|
|
|
a8c905 |
};
|
|
|
a8c905 |
|
|
|
a8c905 |
static const NLTypeSystem rtnl_link_type_system = {
|
|
|
a8c905 |
@@ -643,6 +653,9 @@ static const NLType rtnl_types[] = {
|
|
|
a8c905 |
[RTM_DELLINK] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
|
|
|
a8c905 |
[RTM_GETLINK] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
|
|
|
a8c905 |
[RTM_SETLINK] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
|
|
|
a8c905 |
+ [RTM_NEWLINKPROP] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
|
|
|
a8c905 |
+ [RTM_DELLINKPROP] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
|
|
|
a8c905 |
+ [RTM_GETLINKPROP] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
|
|
|
a8c905 |
[RTM_NEWADDR] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_address_type_system, .size = sizeof(struct ifaddrmsg) },
|
|
|
a8c905 |
[RTM_DELADDR] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_address_type_system, .size = sizeof(struct ifaddrmsg) },
|
|
|
a8c905 |
[RTM_GETADDR] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_address_type_system, .size = sizeof(struct ifaddrmsg) },
|
|
|
a8c905 |
diff --git a/src/libsystemd/sd-netlink/netlink-util.h b/src/libsystemd/sd-netlink/netlink-util.h
|
|
|
a8c905 |
index 7c35a2cfa7..882a616310 100644
|
|
|
a8c905 |
--- a/src/libsystemd/sd-netlink/netlink-util.h
|
|
|
a8c905 |
+++ b/src/libsystemd/sd-netlink/netlink-util.h
|
|
|
a8c905 |
@@ -19,7 +19,9 @@ static inline bool rtnl_message_type_is_route(uint16_t type) {
|
|
|
a8c905 |
}
|
|
|
a8c905 |
|
|
|
a8c905 |
static inline bool rtnl_message_type_is_link(uint16_t type) {
|
|
|
a8c905 |
- return IN_SET(type, RTM_NEWLINK, RTM_SETLINK, RTM_GETLINK, RTM_DELLINK);
|
|
|
a8c905 |
+ return IN_SET(type,
|
|
|
a8c905 |
+ RTM_NEWLINK, RTM_SETLINK, RTM_GETLINK, RTM_DELLINK,
|
|
|
a8c905 |
+ RTM_NEWLINKPROP, RTM_DELLINKPROP, RTM_GETLINKPROP);
|
|
|
a8c905 |
}
|
|
|
a8c905 |
|
|
|
a8c905 |
static inline bool rtnl_message_type_is_addr(uint16_t type) {
|
|
|
a8c905 |
diff --git a/src/libsystemd/sd-netlink/rtnl-message.c b/src/libsystemd/sd-netlink/rtnl-message.c
|
|
|
a8c905 |
index 4416e1720c..369c402986 100644
|
|
|
a8c905 |
--- a/src/libsystemd/sd-netlink/rtnl-message.c
|
|
|
a8c905 |
+++ b/src/libsystemd/sd-netlink/rtnl-message.c
|
|
|
a8c905 |
@@ -449,6 +449,8 @@ int sd_rtnl_message_new_link(sd_netlink *rtnl, sd_netlink_message **ret,
|
|
|
a8c905 |
|
|
|
a8c905 |
if (nlmsg_type == RTM_NEWLINK)
|
|
|
a8c905 |
(*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_EXCL;
|
|
|
a8c905 |
+ else if (nlmsg_type == RTM_NEWLINK)
|
|
|
a8c905 |
+ (*ret)->hdr->nlmsg_flags |= NLM_F_EXCL | NLM_F_CREATE | NLM_F_APPEND;
|
|
|
a8c905 |
|
|
|
a8c905 |
ifi = NLMSG_DATA((*ret)->hdr);
|
|
|
a8c905 |
|