mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2026-01-26 22:02:46 +00:00
iproute: Fix errno propagation from rtnl_talk
Callers of rtnl_talk check errno value for their needs. In particular, the addrs and routes restoring code validly reports success if the EEXISTS is in there. However, the errno value can be sometimes screwed up by the perror call. Thus we should only set it _after_ the message was emitted. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
d89fbf3223
commit
b8cf1e9ae3
@ -360,13 +360,14 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
|
||||
if (l < sizeof(struct nlmsgerr)) {
|
||||
fprintf(stderr, "ERROR truncated\n");
|
||||
} else {
|
||||
errno = -err->error;
|
||||
if (errno == 0) {
|
||||
if (!err->error) {
|
||||
if (answer)
|
||||
memcpy(answer, h, h->nlmsg_len);
|
||||
return 0;
|
||||
}
|
||||
perror("RTNETLINK answers");
|
||||
|
||||
fprintf(stderr, "RTNETLINK answers: %s\n", strerror(-err->error));
|
||||
errno = -err->error;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user