X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;ds=sidebyside;f=src%2Flibsystemd%2Fsd-rtnl%2Frtnl-message.c;h=c780f71881abf407b447ab2ac30ec916fa363091;hb=31a4e15384b3819621dd5648e18148c2edea72d3;hp=bcfffeff041753f43416b2687636c2a9ecd84c46;hpb=5a1aece58142023d407afae797bb0ffb05b34732;p=elogind.git diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c index bcfffeff0..c780f7188 100644 --- a/src/libsystemd/sd-rtnl/rtnl-message.c +++ b/src/libsystemd/sd-rtnl/rtnl-message.c @@ -24,6 +24,7 @@ #include #include #include +#include #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) {