Skip to content

Commit 0b7fb74

Browse files
mctp-netlink: Return -errno from mctp_nl_send() on send failure
mctp_nl_send() has two error paths. When the kernel rejects the request, handle_nlmsg_ack() returns a negative errno. When sendto() itself fails, mctp_nl_send() returns sendto()'s -1 and leaves the reason in errno. Callers expect a negative errno. For example, mctpd prints strerror(-rc) when mctp_nl_route_add() or mctp_nl_route_del() fails, so a failed sendto() is logged as "Operation not permitted" (EPERM) whatever the real error was. Return -errno from the sendto() path too, so both paths report errors the same way. Signed-off-by: Kenny PH Hsieh <Kenny_Hsieh@jabil.com>
1 parent e48506b commit 0b7fb74

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎src/mctp-netlink.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ int mctp_nl_send(mctp_nl *nl, struct nlmsghdr *msg)
594594
rc = mctp_ops.nl.sendto(nl->sd, msg, msg->nlmsg_len, 0,
595595
(struct sockaddr *)&addr, sizeof(addr));
596596
if (rc < 0)
597-
return rc;
597+
return -errno;
598598

599599
if (rc != (int)msg->nlmsg_len)
600600
warnx("sendto: short send (%d, expected %d)", rc,

0 commit comments

Comments
 (0)