Catch the original errno from netlink answer (#1526813)
This commit is contained in:
parent
b13670c411
commit
1f973020e9
@ -0,0 +1,80 @@
|
|||||||
|
From f8cff0808a24b1dd141e86cc8039108aa1763071 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Julian Anastasov <ja@ssi.bg>
|
||||||
|
Date: Sat, 5 Aug 2017 14:38:28 +0300
|
||||||
|
Subject: [PATCH 1/2] 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 <ema@wikimedia.org>
|
||||||
|
Signed-off-by: Julian Anastasov <ja@ssi.bg>
|
||||||
|
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
|
||||||
|
---
|
||||||
|
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.14.3
|
||||||
|
|
40
0002-libipvs-discrepancy-with-libnl-genlmsg_put.patch
Normal file
40
0002-libipvs-discrepancy-with-libnl-genlmsg_put.patch
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
From 76c1270148161242f240d9a00746cf06d916b3e3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Arthur Gautier <baloo@gandi.net>
|
||||||
|
Date: Wed, 27 Sep 2017 15:31:05 +0000
|
||||||
|
Subject: [PATCH 2/2] libipvs: discrepancy with libnl genlmsg_put
|
||||||
|
|
||||||
|
There is a mixup between NL_AUTO_PORT and NL_AUTO_PID. The
|
||||||
|
first should be used with genlmsg_put while the second with
|
||||||
|
nlmsg_put.
|
||||||
|
|
||||||
|
This is not a problem, because both NL_AUTO_PORT and NL_AUTO_PID
|
||||||
|
have the same value, but still a discrepancy with libnl documentation.
|
||||||
|
|
||||||
|
see documentation of genlmsg_put here:
|
||||||
|
http://www.infradead.org/~tgr/libnl/doc/api/group__genl.html#ga9a86a71bbba6961d41b8a75f62f9e946
|
||||||
|
|
||||||
|
Cc: Julian Anastasov <ja@ssi.bg>
|
||||||
|
Cc: Simon Horman <horms@verge.net.au>
|
||||||
|
Cc: Jesper Dangaard Brouer <brouer@redhat.com>
|
||||||
|
Signed-off-by: Arthur Gautier <baloo@gandi.net>
|
||||||
|
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
|
||||||
|
---
|
||||||
|
libipvs/libipvs.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/libipvs/libipvs.c b/libipvs/libipvs.c
|
||||||
|
index d271c48..a843243 100644
|
||||||
|
--- a/libipvs/libipvs.c
|
||||||
|
+++ b/libipvs/libipvs.c
|
||||||
|
@@ -63,7 +63,7 @@ struct nl_msg *ipvs_nl_message(int cmd, int flags)
|
||||||
|
if (!msg)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
- genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, family, 0, flags,
|
||||||
|
+ genlmsg_put(msg, NL_AUTO_PORT, NL_AUTO_SEQ, family, 0, flags,
|
||||||
|
cmd, IPVS_GENL_VERSION);
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
--
|
||||||
|
2.14.3
|
||||||
|
|
10
ipvsadm.spec
10
ipvsadm.spec
@ -1,7 +1,7 @@
|
|||||||
Name: ipvsadm
|
Name: ipvsadm
|
||||||
Summary: Utility to administer the Linux Virtual Server
|
Summary: Utility to administer the Linux Virtual Server
|
||||||
Version: 1.29
|
Version: 1.29
|
||||||
Release: 4%{?dist}
|
Release: 5%{?dist}
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
URL: https://kernel.org/pub/linux/utils/kernel/ipvsadm/
|
URL: https://kernel.org/pub/linux/utils/kernel/ipvsadm/
|
||||||
|
|
||||||
@ -9,6 +9,9 @@ Source0: https://kernel.org/pub/linux/utils/kernel/ipvsadm/%{name}-%{version}.ta
|
|||||||
Source1: ipvsadm.service
|
Source1: ipvsadm.service
|
||||||
Source2: ipvsadm-config
|
Source2: ipvsadm-config
|
||||||
|
|
||||||
|
Patch1: 0001-ipvsadm-catch-the-original-errno-from-netlink-answer.patch
|
||||||
|
Patch2: 0002-libipvs-discrepancy-with-libnl-genlmsg_put.patch
|
||||||
|
|
||||||
Buildrequires: libnl3-devel
|
Buildrequires: libnl3-devel
|
||||||
Buildrequires: popt-devel
|
Buildrequires: popt-devel
|
||||||
BuildRequires: systemd
|
BuildRequires: systemd
|
||||||
@ -33,6 +36,8 @@ services. Supported Features include:
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q
|
%setup -q
|
||||||
|
%patch1 -p1
|
||||||
|
%patch2 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
CFLAGS="%{optflags}" make
|
CFLAGS="%{optflags}" make
|
||||||
@ -71,6 +76,9 @@ CFLAGS="%{optflags}" make
|
|||||||
%{_mandir}/man8/%{name}-save.8*
|
%{_mandir}/man8/%{name}-save.8*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Feb 05 2018 Ryan O'Hara <rohara@redhat.com> - 1.29-5
|
||||||
|
- Catch the original errno from netlink answer (#1526813)
|
||||||
|
|
||||||
* Wed Aug 02 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.29-4
|
* Wed Aug 02 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.29-4
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user