genl_add_mcast_grp doesn't set errno in all cases.
On kernels that support mptcp but lack event support (all kernels <= 5.11)
MPTCP_PM_EV_GRP_NAME won't be found and ip will exit with
"can't subscribe to mptcp events: Success"
Set errno to a meaningful value (ENOENT) when the group name isn't found
and also cover other spots where it returns nonzero with errno unset.
Fixes: ff619e4fd370 ("mptcp: add support for event monitoring")
Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
* libgenl.c GENL library
*/
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
}
}
+ errno = ENOENT;
return -1;
}
ghdr = NLMSG_DATA(answer);
len = answer->nlmsg_len;
- if (answer->nlmsg_type != GENL_ID_CTRL)
+ if (answer->nlmsg_type != GENL_ID_CTRL) {
+ errno = EINVAL;
goto err_free;
+ }
len -= NLMSG_LENGTH(GENL_HDRLEN);
- if (len < 0)
+ if (len < 0) {
+ errno = EINVAL;
goto err_free;
+ }
attrs = (struct rtattr *) ((char *) ghdr + GENL_HDRLEN);
parse_rtattr(tb, CTRL_ATTR_MAX, attrs, len);
if (tb[CTRL_ATTR_MCAST_GROUPS] == NULL) {
+ errno = ENOENT;
fprintf(stderr, "Missing mcast groups TLV\n");
goto err_free;
}