Skip to content

mctp-netlink: Return -errno from mctp_nl_send() on send failure - #184

Merged
jk-ozlabs merged 1 commit into
CodeConstruct:mainfrom
Kenny-PH-Hsieh:netlink-send-errno
Nov 12, 2026
Merged

jk-ozlabs merged 1 commit into
CodeConstruct:mainfrom
Kenny-PH-Hsieh:netlink-send-errno

Conversation

@Kenny-PH-Hsieh

Copy link
Copy Markdown
Contributor

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.

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>
@jk-ozlabs

Copy link
Copy Markdown
Member

Looks reasonable, but is there some issue that this is causing?

@Kenny-PH-Hsieh

Copy link
Copy Markdown
Contributor Author

Looks reasonable, but is there some issue that this is causing?

No observed failure in mctpd, it's a consistency fix.
I found it while writing a downstream daemon that uses mctp-netlink and logs strerror(-rc) on failure, which is the same pattern mctpd uses after mctp_nl_route_add()/mctp_nl_route_del().

@Kenny-PH-Hsieh
Kenny-PH-Hsieh deleted the netlink-send-errno branch November 11, 2026 09:51
@Kenny-PH-Hsieh
Kenny-PH-Hsieh restored the netlink-send-errno branch November 11, 2026 09:52
@jk-ozlabs
jk-ozlabs merged commit 0b7fb74 into CodeConstruct:main Nov 12, 2026
7 checks passed
@jk-ozlabs

Copy link
Copy Markdown
Member

Merged, thanks!

Out of curiosity, can you share details of this downstream daemon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants