diff --git a/SOURCES/ipvsadm-catch-netlink-errno.patch b/SOURCES/ipvsadm-catch-netlink-errno.patch new file mode 100644 index 0000000..216127a --- /dev/null +++ b/SOURCES/ipvsadm-catch-netlink-errno.patch @@ -0,0 +1,81 @@ +From f8cff0808a24b1dd141e86cc8039108aa1763071 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Julian Anastasov +Date: Sat, 5 Aug 2017 14:38:28 +0300 +Subject: [PATCH] ipvsadm: catch the original errno from netlink answer + +nl_recvmsgs_default() returns NLE_* error codes and not +errno values. As result, attempt to delete virtual service +returns NLE_OBJ_NOTFOUND (12) which matches the ENOMEM value. + +Problem as reported by Emanuele Rocca: + +ipvsadm -D -t example.org:80 +Memory allocation problem + +Fix it by providing generic error handler to catch the errno +value as returned in netlink answer. By this way all netlink +commands will get proper error string. The problem is present +only when ipvsadm is compiled with libnl. + +ipvsadm -D -t example.org:80 +No such service + +Reported-by: Emanuele Rocca +Signed-off-by: Julian Anastasov +Signed-off-by: Jesper Dangaard Brouer +--- + libipvs/libipvs.c | 22 +++++++++++++++++++++- + 1 file changed, 21 insertions(+), 1 deletion(-) + +diff --git a/libipvs/libipvs.c b/libipvs/libipvs.c +index 180ea42..d271c48 100644 +--- a/libipvs/libipvs.c ++++ b/libipvs/libipvs.c +@@ -74,9 +74,23 @@ static int ipvs_nl_noop_cb(struct nl_msg *msg, void *arg) + return NL_OK; + } + ++struct cb_err_data { ++ int err; ++}; ++ ++static int ipvs_nl_err_cb(struct sockaddr_nl *nla, struct nlmsgerr *nlerr, ++ void *arg) ++{ ++ struct cb_err_data *data = arg; ++ ++ data->err = nlerr->error; ++ return -nl_syserr2nlerr(nlerr->error); ++} ++ + int ipvs_nl_send_message(struct nl_msg *msg, nl_recvmsg_msg_cb_t func, void *arg) + { + int err = EINVAL; ++ struct cb_err_data err_data = { .err = 0 }; + + sock = nl_socket_alloc(); + if (!sock) { +@@ -100,12 +114,18 @@ int ipvs_nl_send_message(struct nl_msg *msg, nl_recvmsg_msg_cb_t func, void *arg + + if (nl_socket_modify_cb(sock, NL_CB_VALID, NL_CB_CUSTOM, func, arg) != 0) + goto fail_genl; ++ if (nl_socket_modify_err_cb(sock, NL_CB_CUSTOM, ipvs_nl_err_cb, ++ &err_data) != 0) ++ goto fail_genl; + + if (nl_send_auto_complete(sock, msg) < 0) + goto fail_genl; + +- if ((err = -nl_recvmsgs_default(sock)) > 0) ++ if (nl_recvmsgs_default(sock) < 0) { ++ if (err_data.err) ++ err = -err_data.err; + goto fail_genl; ++ } + + nlmsg_free(msg); + +-- +2.20.1 + diff --git a/SPECS/ipvsadm.spec b/SPECS/ipvsadm.spec index 9a63068..470ca0f 100644 --- a/SPECS/ipvsadm.spec +++ b/SPECS/ipvsadm.spec @@ -1,7 +1,7 @@ Name: ipvsadm Summary: Utility to administer the Linux Virtual Server Version: 1.27 -Release: 7%{?dist} +Release: 8%{?dist} License: GPLv2+ Group: Applications/System URL: https://kernel.org/pub/linux/utils/kernel/ipvsadm/ @@ -12,6 +12,7 @@ Source2: ipvsadm-config Patch0: ipvsadm-show-backup-daemon.patch Patch1: ipvsadm-fix-compile-warnings.patch +Patch2: ipvsadm-catch-netlink-errno.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root Buildrequires: libnl3-devel @@ -42,6 +43,7 @@ services. Supported Features include: %setup -q %patch0 -p1 %patch1 -p0 +%patch2 -p1 %build # Don't use _smp_mflags as it makes the build fail (1.2.4) @@ -97,6 +99,9 @@ CFLAGS="%{optflags}" make %changelog +* Tue Aug 20 2019 Ryan O'Hara - 1.27-8 +- Catch the orignal errno from netlink answer (#1696123) + * Tue Sep 30 2014 Ryan O'Hara - 1.27-7 - Improve package description (#1067144)