summaryrefslogtreecommitdiff
path: root/src/libsystemd
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-02-06 11:49:07 +0100
committerTom Gundersen <teg@jklm.no>2015-02-06 11:49:39 +0100
commitb621bfd2311a13311a45ccd5e31a9ce3214895fe (patch)
tree0dd8f38e131a590a9416fcc5c852d0e55326f6a3 /src/libsystemd
parent1c25683e0f40c6169676cc44fa1897082597feec (diff)
sd-rtnl: fix creation of synthetic error replies
Diffstat (limited to 'src/libsystemd')
-rw-r--r--src/libsystemd/sd-rtnl/rtnl-message.c2
-rw-r--r--src/libsystemd/sd-rtnl/rtnl-util.c4
-rw-r--r--src/libsystemd/sd-rtnl/test-rtnl.c9
3 files changed, 10 insertions, 5 deletions
diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index 1f44c341aa..23253029e5 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -71,8 +71,6 @@ int message_new(sd_rtnl *rtnl, sd_rtnl_message **ret, uint16_t type) {
if (r < 0)
return r;
- assert(nl_type->type == NLA_NESTED);
-
r = message_new_empty(rtnl, &m);
if (r < 0)
return r;
diff --git a/src/libsystemd/sd-rtnl/rtnl-util.c b/src/libsystemd/sd-rtnl/rtnl-util.c
index 194a267b04..5666ea44cb 100644
--- a/src/libsystemd/sd-rtnl/rtnl-util.c
+++ b/src/libsystemd/sd-rtnl/rtnl-util.c
@@ -107,12 +107,10 @@ int rtnl_message_new_synthetic_error(int error, uint32_t serial, sd_rtnl_message
assert(error <= 0);
- r = message_new(NULL, ret, NLMSG_SPACE(sizeof(struct nlmsgerr)));
+ r = message_new(NULL, ret, NLMSG_ERROR);
if (r < 0)
return r;
- (*ret)->hdr->nlmsg_len = NLMSG_LENGTH(sizeof(struct nlmsgerr));
- (*ret)->hdr->nlmsg_type = NLMSG_ERROR;
(*ret)->hdr->nlmsg_seq = serial;
err = NLMSG_DATA((*ret)->hdr);
diff --git a/src/libsystemd/sd-rtnl/test-rtnl.c b/src/libsystemd/sd-rtnl/test-rtnl.c
index 72d8fe2273..ed60b3cb45 100644
--- a/src/libsystemd/sd-rtnl/test-rtnl.c
+++ b/src/libsystemd/sd-rtnl/test-rtnl.c
@@ -353,6 +353,13 @@ static void test_get_addresses(sd_rtnl *rtnl) {
}
}
+static void test_message(void) {
+ _cleanup_rtnl_message_unref_ sd_rtnl_message *m = NULL;
+
+ assert_se(rtnl_message_new_synthetic_error(-ETIMEDOUT, 1, &m) >= 0);
+ assert_se(sd_rtnl_message_get_errno(m) == -ETIMEDOUT);
+}
+
int main(void) {
sd_rtnl *rtnl;
sd_rtnl_message *m;
@@ -361,6 +368,8 @@ int main(void) {
int if_loopback;
uint16_t type;
+ test_message();
+
test_match();
test_multiple();