summaryrefslogtreecommitdiff
path: root/src/libsystemd
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-02-14 22:39:48 +0100
committerTom Gundersen <teg@jklm.no>2014-02-15 12:14:45 +0100
commitee3a6a51e5b098aa0c9641ed71d275c459ad2f5a (patch)
treeb97e0d80db759e2debacbe4a4a3f605f34520319 /src/libsystemd
parenta7b74db6e72f4f19f74eabc81c1ebb4cb8670f06 (diff)
sd-rtnl: message_open_container - don't take a 'size' argument
We can always know the size based on the type, so let's do this inside the library.
Diffstat (limited to 'src/libsystemd')
-rw-r--r--src/libsystemd/sd-rtnl/rtnl-message.c12
-rw-r--r--src/libsystemd/sd-rtnl/test-rtnl.c8
2 files changed, 12 insertions, 8 deletions
diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index 226329f314..096a32236c 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -699,7 +699,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, size_t extra) {
+int sd_rtnl_message_open_container(sd_rtnl_message *m, unsigned short type) {
uint16_t rtm_type;
assert_return(m, -EINVAL);
@@ -710,9 +710,13 @@ int sd_rtnl_message_open_container(sd_rtnl_message *m, unsigned short type, size
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) ||
- (type == VETH_INFO_PEER && m->n_containers == 2 && GET_CONTAINER(m, 1)->rta_type == IFLA_INFO_DATA))
- return add_rtattr(m, type, NULL, extra);
+ (type == IFLA_INFO_DATA && m->n_containers == 1 &&
+ GET_CONTAINER(m, 0)->rta_type == IFLA_LINKINFO))
+ return add_rtattr(m, type, NULL, 0);
+ else if (type == VETH_INFO_PEER && m->n_containers == 2 &&
+ GET_CONTAINER(m, 1)->rta_type == IFLA_INFO_DATA &&
+ GET_CONTAINER(m, 0)->rta_type == IFLA_LINKINFO)
+ return add_rtattr(m, type, NULL, sizeof(struct ifinfomsg));
}
return -ENOTSUP;
diff --git a/src/libsystemd/sd-rtnl/test-rtnl.c b/src/libsystemd/sd-rtnl/test-rtnl.c
index 9de3806251..53efed561a 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) >= 0);
- assert(sd_rtnl_message_open_container(m, IFLA_LINKINFO, 0) == -ENOTSUP);
+ assert(sd_rtnl_message_open_container(m, IFLA_LINKINFO) >= 0);
+ assert(sd_rtnl_message_open_container(m, IFLA_LINKINFO) == -ENOTSUP);
assert(sd_rtnl_message_append_string(m, IFLA_INFO_KIND, "kind") >= 0);
- 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_open_container(m, IFLA_INFO_DATA) >= 0);
+ assert(sd_rtnl_message_open_container(m, IFLA_INFO_DATA) == -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);