tools: ynl: use strerror() if no extack of note provided

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>
This commit is contained in:
Jakub Kicinski 2023-12-02 13:13:10 -08:00
parent e136735f0c
commit f2d4d9ad80
1 changed files with 5 additions and 1 deletions

View File

@ -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;
@ -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;
}