Skip to content

Commit

Permalink
tools: ynl: use strerror() if no extack of note provided
Browse files Browse the repository at this point in the history
If kernel didn't give use any meaningful error - print
a strerror() to the ynl error message.

Reviewed-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Link: https://lore.kernel.org/r/20231202211310.342716-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Dec 6, 2023
1 parent e136735 commit f2d4d9a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tools/net/ynl/lib/ynl.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ ynl_ext_ack_check(struct ynl_sock *ys, const struct nlmsghdr *nlh,
const struct nlattr *attr;
const char *str = NULL;

if (!(nlh->nlmsg_flags & NLM_F_ACK_TLVS))
if (!(nlh->nlmsg_flags & NLM_F_ACK_TLVS)) {
yerr_msg(ys, "%s", strerror(ys->err.code));
return MNL_CB_OK;
}

mnl_attr_for_each(attr, nlh, hlen) {
unsigned int len, type;
Expand Down Expand Up @@ -249,6 +251,8 @@ ynl_ext_ack_check(struct ynl_sock *ys, const struct nlmsghdr *nlh,
yerr_msg(ys, "Kernel %s: %s%s",
ys->err.code ? "error" : "warning",
bad_attr, miss_attr);
else
yerr_msg(ys, "%s", strerror(ys->err.code));

return MNL_CB_OK;
}
Expand Down

0 comments on commit f2d4d9a

Please sign in to comment.