mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
sd-rtnl: fix creation of synthetic error replies
This commit is contained in:
parent
1c25683e0f
commit
b621bfd231
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user