diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd/sd-rtnl/rtnl-message.c | 19 | ||||
-rw-r--r-- | src/libsystemd/sd-rtnl/test-rtnl.c | 8 | ||||
-rw-r--r-- | src/network/networkd-netdev.c | 4 | ||||
-rw-r--r-- | src/systemd/sd-rtnl.h | 2 |
4 files changed, 16 insertions, 17 deletions
diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c index bcfffeff04..c780f71881 100644 --- a/src/libsystemd/sd-rtnl/rtnl-message.c +++ b/src/libsystemd/sd-rtnl/rtnl-message.c @@ -24,6 +24,7 @@ #include <netinet/ether.h> #include <stdbool.h> #include <unistd.h> +#include <linux/veth.h> #include "util.h" #include "refcnt.h" @@ -32,7 +33,7 @@ #include "rtnl-util.h" #include "rtnl-internal.h" -#define GET_CONTAINER(m, i) (i < (m)->n_containers ? (struct rtattr*)((uint8_t*)(m)->hdr + (m)->container_offsets[i]) : NULL) +#define GET_CONTAINER(m, i) ((i) < (m)->n_containers ? (struct rtattr*)((uint8_t*)(m)->hdr + (m)->container_offsets[i]) : NULL) #define NEXT_RTA(m) ((struct rtattr*)((uint8_t*)(m)->hdr + (m)->next_rta_offset)) #define UPDATE_RTA(m, new) (m)->next_rta_offset = (uint8_t*)(new) - (uint8_t*)(m)->hdr; #define PUSH_CONTAINER(m, new) (m)->container_offsets[(m)->n_containers ++] = (uint8_t*)(new) - (uint8_t*)(m)->hdr; @@ -700,7 +701,7 @@ int sd_rtnl_message_append_ether_addr(sd_rtnl_message *m, unsigned short type, c return 0; } -int sd_rtnl_message_open_container(sd_rtnl_message *m, unsigned short type) { +int sd_rtnl_message_open_container(sd_rtnl_message *m, unsigned short type, size_t extra) { uint16_t rtm_type; assert_return(m, -EINVAL); @@ -709,16 +710,14 @@ int sd_rtnl_message_open_container(sd_rtnl_message *m, unsigned short type) { sd_rtnl_message_get_type(m, &rtm_type); if (rtnl_message_type_is_link(rtm_type)) { + if ((type == IFLA_LINKINFO && m->n_containers == 0) || - (type == IFLA_INFO_DATA && m->n_containers == 1 && - GET_CONTAINER(m, 0)->rta_type == IFLA_LINKINFO)) - return add_rtattr(m, type, NULL, 0); - else - return -ENOTSUP; - } else - return -ENOTSUP; + (type == IFLA_INFO_DATA && m->n_containers == 1 && GET_CONTAINER(m, 0)->rta_type == IFLA_LINKINFO) || + (type == VETH_INFO_PEER && m->n_containers == 2 && GET_CONTAINER(m, 1)->rta_type == IFLA_INFO_DATA)) + return add_rtattr(m, type, NULL, extra); + } - return 0; + return -ENOTSUP; } int sd_rtnl_message_close_container(sd_rtnl_message *m) { diff --git a/src/libsystemd/sd-rtnl/test-rtnl.c b/src/libsystemd/sd-rtnl/test-rtnl.c index 53efed561a..9de3806251 100644 --- a/src/libsystemd/sd-rtnl/test-rtnl.c +++ b/src/libsystemd/sd-rtnl/test-rtnl.c @@ -287,11 +287,11 @@ static void test_container(void) { assert(sd_rtnl_message_new_link(RTM_NEWLINK, 0, &m) >= 0); - assert(sd_rtnl_message_open_container(m, IFLA_LINKINFO) >= 0); - assert(sd_rtnl_message_open_container(m, IFLA_LINKINFO) == -ENOTSUP); + assert(sd_rtnl_message_open_container(m, IFLA_LINKINFO, 0) >= 0); + assert(sd_rtnl_message_open_container(m, IFLA_LINKINFO, 0) == -ENOTSUP); assert(sd_rtnl_message_append_string(m, IFLA_INFO_KIND, "kind") >= 0); - assert(sd_rtnl_message_open_container(m, IFLA_INFO_DATA) >= 0); - assert(sd_rtnl_message_open_container(m, IFLA_INFO_DATA) == -ENOTSUP); + assert(sd_rtnl_message_open_container(m, IFLA_INFO_DATA, 0) >= 0); + assert(sd_rtnl_message_open_container(m, IFLA_INFO_DATA, 0) == -ENOTSUP); assert(sd_rtnl_message_append_u16(m, IFLA_VLAN_ID, 100) >= 0); assert(sd_rtnl_message_close_container(m) >= 0); assert(sd_rtnl_message_append_string(m, IFLA_INFO_KIND, "kind") >= 0); diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c index 30eb77d4bc..a452e0d6d6 100644 --- a/src/network/networkd-netdev.c +++ b/src/network/networkd-netdev.c @@ -194,7 +194,7 @@ static int netdev_create(NetDev *netdev, Link *link, sd_rtnl_message_handler_t c return r; } - r = sd_rtnl_message_open_container(req, IFLA_LINKINFO); + r = sd_rtnl_message_open_container(req, IFLA_LINKINFO, 0); if (r < 0) { log_error_netdev(netdev, "Could not open IFLA_LINKINFO container: %s", @@ -217,7 +217,7 @@ static int netdev_create(NetDev *netdev, Link *link, sd_rtnl_message_handler_t c } if (netdev->vlanid <= VLANID_MAX) { - r = sd_rtnl_message_open_container(req, IFLA_INFO_DATA); + r = sd_rtnl_message_open_container(req, IFLA_INFO_DATA, 0); if (r < 0) { log_error_netdev(netdev, "Could not open IFLA_INFO_DATA container: %s", diff --git a/src/systemd/sd-rtnl.h b/src/systemd/sd-rtnl.h index 5506bfa4fa..93edbcbbc0 100644 --- a/src/systemd/sd-rtnl.h +++ b/src/systemd/sd-rtnl.h @@ -102,7 +102,7 @@ int sd_rtnl_message_append_in_addr(sd_rtnl_message *m, unsigned short type, cons int sd_rtnl_message_append_in6_addr(sd_rtnl_message *m, unsigned short type, const struct in6_addr *data); int sd_rtnl_message_append_ether_addr(sd_rtnl_message *m, unsigned short type, const struct ether_addr *data); -int sd_rtnl_message_open_container(sd_rtnl_message *m, unsigned short type); +int sd_rtnl_message_open_container(sd_rtnl_message *m, unsigned short type, size_t extra); int sd_rtnl_message_close_container(sd_rtnl_message *m); int sd_rtnl_message_read(sd_rtnl_message *m, unsigned short *type, void **data); |