diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e4faea0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/ipvsadm-1.27.tar.gz diff --git a/.ipvsadm.metadata b/.ipvsadm.metadata new file mode 100644 index 0000000..a872cd7 --- /dev/null +++ b/.ipvsadm.metadata @@ -0,0 +1 @@ +998ff461b53ac31a68f570d02a17e6e76fc6060a SOURCES/ipvsadm-1.27.tar.gz 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/SOURCES/ipvsadm-config b/SOURCES/ipvsadm-config new file mode 100644 index 0000000..34251a3 --- /dev/null +++ b/SOURCES/ipvsadm-config @@ -0,0 +1,23 @@ +# Unload modules on restart and stop +# Value: yes|no, default: yes +# This option has to be 'yes' to get to a sane state for a ipvs +# restart or stop. Only set to 'no' if there are problems unloading ipvs +# modules. +IPVS_MODULES_UNLOAD="yes" + +# Save current ipvs rules on stop. +# Value: yes|no, default: no +# Saves all ipvs rules to /etc/sysconfig/ipvsadm if ipvsadm gets stopped +# (e.g. on system shutdown). +IPVS_SAVE_ON_STOP="no" + +# Save current ipvs rules on restart. +# Value: yes|no, default: no +# Saves all ipvs rules to /etc/sysconfig/ipvsadm if ipvsadm gets +# restarted. +IPVS_SAVE_ON_RESTART="no" + +# Numeric status output +# Value: yes|no, default: yes +# Print IP addresses and port numbers in numeric format in the status output. +IPVS_STATUS_NUMERIC="yes" diff --git a/SOURCES/ipvsadm-fix-compile-warnings.patch b/SOURCES/ipvsadm-fix-compile-warnings.patch new file mode 100644 index 0000000..35f7617 --- /dev/null +++ b/SOURCES/ipvsadm-fix-compile-warnings.patch @@ -0,0 +1,27 @@ +--- ipvsadm.c.orig 2013-09-06 04:37:27.000000000 -0400 ++++ ipvsadm.c 2014-02-21 03:10:36.117000000 -0500 +@@ -1240,14 +1240,13 @@ + char *argv[] = { "/sbin/modprobe", "--", "ip_vs", NULL }; + int child; + int status; +- int rc; + + if (!(child = fork())) { + execv(argv[0], argv); + exit(1); + } + +- rc = waitpid(child, &status, 0); ++ waitpid(child, &status, 0); + + if (!WIFEXITED(status) || WEXITSTATUS(status)) { + return 1; +@@ -1429,7 +1428,7 @@ + static void print_largenum(unsigned long long i, unsigned int format) + { + char mytmp[32]; +- size_t len; ++ int len; + + if (format & FMT_EXACT) { + len = snprintf(mytmp, 32, "%llu", i); diff --git a/SOURCES/ipvsadm-show-backup-daemon.patch b/SOURCES/ipvsadm-show-backup-daemon.patch new file mode 100644 index 0000000..cb591f2 --- /dev/null +++ b/SOURCES/ipvsadm-show-backup-daemon.patch @@ -0,0 +1,33 @@ +From 8ca22ba019c0b4d72a54a0954fcc04848dba4579 Mon Sep 17 00:00:00 2001 +From: Ryan O'Hara +Date: Tue, 20 May 2014 22:04:09 -0500 +Subject: [PATCH] ipvsadm: Fix list daemon to show backup daemon + +The list_daemon function in ipvsadm.c will show the master daemon +twice, but never the backup daemon. This patch replaces the redundant +check for IP_VS_STATE_MASTER with a check for IP_VS_STATE_BACKUP, then +prints the appropriate message. + +Signed-off-by: Ryan O'Hara +--- + ipvsadm.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/ipvsadm.c b/ipvsadm.c +index 4c83a8b..755827f 100644 +--- a/ipvsadm.c ++++ b/ipvsadm.c +@@ -1732,8 +1732,8 @@ static void list_daemon(void) + if (u[i].state & IP_VS_STATE_MASTER) + printf("master sync daemon (mcast=%s, syncid=%d)\n", + u[i].mcast_ifn, u[i].syncid); +- if (u[i].state & IP_VS_STATE_MASTER) +- printf("master sync daemon (mcast=%s, syncid=%d)\n", ++ if (u[i].state & IP_VS_STATE_BACKUP) ++ printf("backup sync daemon (mcast=%s, syncid=%d)\n", + u[i].mcast_ifn, u[i].syncid); + } + free(u); +-- +1.9.0 + diff --git a/SOURCES/ipvsadm.service b/SOURCES/ipvsadm.service new file mode 100644 index 0000000..a1d497f --- /dev/null +++ b/SOURCES/ipvsadm.service @@ -0,0 +1,14 @@ +[Unit] +Description=Initialise the Linux Virtual Server +After=syslog.target network.target + +[Service] +Type=oneshot +ExecStart=/bin/bash -c "exec /sbin/ipvsadm-restore < /etc/sysconfig/ipvsadm" +ExecStop=/bin/bash -c "exec /sbin/ipvsadm-save -n > /etc/sysconfig/ipvsadm" +ExecStop=/sbin/ipvsadm -C +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target + diff --git a/SPECS/ipvsadm.spec b/SPECS/ipvsadm.spec new file mode 100644 index 0000000..470ca0f --- /dev/null +++ b/SPECS/ipvsadm.spec @@ -0,0 +1,289 @@ +Name: ipvsadm +Summary: Utility to administer the Linux Virtual Server +Version: 1.27 +Release: 8%{?dist} +License: GPLv2+ +Group: Applications/System +URL: https://kernel.org/pub/linux/utils/kernel/ipvsadm/ + +Source0: https://kernel.org/pub/linux/utils/kernel/ipvsadm/%{name}-%{version}.tar.gz +Source1: ipvsadm.service +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 +Buildrequires: popt-devel +BuildRequires: systemd +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd +# For triggerun +Requires(post): systemd-sysv + +%description +ipvsadm is used to setup, maintain, and inspect the virtual server +table in the Linux kernel. The Linux Virtual Server can be used to +build scalable network services based on a cluster of two or more +nodes. The active node of the cluster redirects service requests to a +collection of server hosts that will actually perform the +services. Supported Features include: + - two transport layer (layer-4) protocols (TCP and UDP) + - three packet-forwarding methods (NAT, tunneling, and direct routing) + - eight load balancing algorithms (round robin, weighted round robin, + least-connection, weighted least-connection, locality-based + least-connection, locality-based least-connection with + replication, destination-hashing, and source-hashing) + + +%prep +%setup -q +%patch0 -p1 +%patch1 -p0 +%patch2 -p1 + +%build +# Don't use _smp_mflags as it makes the build fail (1.2.4) +CFLAGS="%{optflags}" make + + +%install +%{__rm} -rf %{buildroot} +%{__mkdir_p} %{buildroot}/etc/rc.d/init.d +%{__make} install BUILD_ROOT=%{buildroot}%{_prefix} SBIN=%{buildroot}%{_sbindir} MANDIR=%{buildroot}%{_mandir} MAN=%{buildroot}%{_mandir}/man8 INIT=%{buildroot}%{_sysconfdir}/rc.d/init.d +# Remove the provided init script +%{__rm} -f %{buildroot}%{_sysconfdir}/rc.d/init.d/ipvsadm +%{__install} -D -p -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/ipvsadm.service +# Install config file which controls the service behavior +%{__install} -D -p -m 0600 %{SOURCE2} %{buildroot}/etc/sysconfig/ipvsadm-config + + +%clean +%{__rm} -rf %{buildroot} + + +%post +%systemd_post ipvsadm.service + +%preun +%systemd_preun ipvsadm.service + +%postun +%systemd_postun_with_restart ipvsadm.service + + +%triggerun -- ipvsadm < 1.26-4 +# Save the current service runlevel info +# User must manually run systemd-sysv-convert --apply ipvsadm +# to migrate them to systemd targets +/usr/bin/systemd-sysv-convert --save ipvsadm >/dev/null 2>&1 ||: + +# Run these because the SysV package being removed won't do them +/sbin/chkconfig --del ipvsadm >/dev/null 2>&1 || : +/bin/systemctl try-restart ipvsadm.service >/dev/null 2>&1 || : + +%files +%defattr(-,root,root,-) +%doc README +%{_unitdir}/ipvsadm.service +%config(noreplace) /etc/sysconfig/ipvsadm-config +%{_sbindir}/ipvsadm +%{_sbindir}/ipvsadm-restore +%{_sbindir}/ipvsadm-save +%{_mandir}/man8/ipvsadm.8* +%{_mandir}/man8/ipvsadm-restore.8* +%{_mandir}/man8/ipvsadm-save.8* + + +%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) + +* Tue Sep 30 2014 Ryan O'Hara - 1.27-6 +- Cleanup specfile and install to _sbindir (#1067674) + +* Tue Jul 08 2014 Ryan O'Hara - 1.27-5 +- Fix list_daemon to show backup daemon (#1099689) + +* Mon Jan 27 2014 Ryan O'Hara - 1.27-4 +- Link with libnl3 (#1054970) + +* Fri Jan 24 2014 Daniel Mach - 1.27-3 +- Mass rebuild 2014-01-24 + +* Fri Dec 27 2013 Daniel Mach - 1.27-2 +- Mass rebuild 2013-12-27 + +* Fri Sep 06 2013 Ryan O'Hara - 1.27-1 +- Update to 1.27 + +* Wed Mar 20 2013 Ryan O'Hara - 1.26-8 +- Use new systemd-rpm macros in ipvsadm spec file (#850168). + +* Thu Feb 14 2013 Fedora Release Engineering - 1.26-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Thu Jul 19 2012 Fedora Release Engineering - 1.26-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Mon Jul 9 2012 Ryan O'Hara - 1.26-5 +- Fix list_daemon to not assume sync daemon status is ordered (#805208). + +* Thu Apr 19 2012 Jon Ciesla - 1.26-4 +- Migrate to systemd, BZ 720175. + +* Fri Jan 13 2012 Fedora Release Engineering - 1.26-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Mon Jul 11 2011 Matthias Saou 1.26-2 +- Backport the init script from RHEL6, which contains lots of changes to make + it behave simlarly to the iptables init script (#593276). + +* Sat Jul 9 2011 Matthias Saou 1.26-1 +- Update to 1.26 (#676167). +- Remove upstreamed Makefile and activeconns patchs, rebase popt patch. + +* Wed Feb 09 2011 Fedora Release Engineering - 1.25-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Thu Apr 29 2010 Matthias Saou 1.25-5 +- Include patch to fix activeconns when using the netlink interface (#573921). + +* Fri Jul 24 2009 Fedora Release Engineering - 1.25-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Wed Feb 25 2009 Fedora Release Engineering - 1.25-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Wed Dec 24 2008 Matthias Saou 1.25-2 +- Fork the included init script to be (mostly) LSB compliant (#246955). + +* Mon Dec 22 2008 Matthias Saou 1.25-1 +- Prepare update to 1.25 for when devel will update to kernel 2.6.28. +- Build require libnl-devel and popt-devel (+ patch to fix popt detection). + +* Tue Feb 19 2008 Fedora Release Engineering +- Autorebuild for GCC 4.3 + +* Mon Oct 22 2007 Matthias Saou 1.24-10 +- Update to latest upstream sources. Same filename, but updated content! +- Update kernhdr patch for it to still apply, update ip_vs.h from 1.2.0 to + 1.2.1 from kernel 2.6.23.1. + +* Fri Aug 24 2007 Matthias Saou 1.24-9 +- Spec file cleanup. +- Update License field. +- Don't "chkconfig --del" upon update. +- Add missing kernel-headers build requirement. +- Update URL and Source locations. +- Remove outdated piranha obsoletes, it has never been part of any Fedora. +- No longer mark init script as config. +- Include Makefile patch to prevent stripping and install init script. +- The init script could use a rewrite... leave that one for later. + +* Wed Jul 12 2006 Jesse Keating - 1.24-8.1 +- rebuild + +* Mon May 15 2006 Phil Knirsch - 1.24-8 +- Added missing prereq to chkconfig + +* Fri Feb 10 2006 Jesse Keating - 1.24-7.2.1 +- bump again for double-long bug on ppc(64) + +* Tue Feb 07 2006 Jesse Keating - 1.24-7.2 +- rebuilt for new gcc4.1 snapshot and glibc changes + +* Fri Dec 09 2005 Jesse Keating +- rebuilt + +* Mon Mar 14 2005 Lon Hohberger 1.24-7 +- rebuilt + +* Tue Jun 15 2004 Elliot Lee +- rebuilt + +* Tue Mar 16 2004 Mike McLean 1.24-4.2.ipvs120 +- bump release + +* Tue Mar 02 2004 Mike McLean 1.24-4.1.ipvs120 +- update to new version for 2.6 kernel + +* Thu Jan 08 2004 Mike McLean 1.21-10.ipvs108 +- fixing a minor bug/typo in output format processing + +* Wed Aug 06 2003 Mike McLean 1.21-9.ipvs108 +- Dropping kernel-source BuildRequires and including a local copy of + net/ip_vs.h to compensate. +- Incorporating some upstream changes, most notably the --sort option. + +* Fri Jun 13 2003 Mike McLean 1.21-8 +- dropping ppc from excluded arches + +* Fri Apr 4 2003 Mike McLean 1.21-7 +- changing %%ExcludeArch + +* Fri Apr 4 2003 Mike McLean 1.21-6 +- added BuildRequires: kernel-source +- escaped all %% characters in %%changelog + +* Mon Dec 2 2002 Mike McLean 1.21-5 +- Improved the description in the ipvsadm initscript. +- fixed Buildroot to use _tmppath + +* Wed Aug 21 2002 Philip Copeland 1.21-4 +- Argh,.. %%docdir was defined which overrode what I'd + intended to happen + +* Thu Aug 1 2002 Philip Copeland +- Ah... the manuals were being pushed into /usr/man + instead of /usr/share/man. Fixed. + +* Tue Jul 16 2002 Philip Copeland +- Minor Makefile tweak so that we do a minimal hunt for to find + the ip_vs.h file location + +* Sun Dec 16 2001 Wensong Zhang +- Changed to install ipvsadm man pages according to the %%{_mandir} + +* Sat Dec 30 2000 Wensong Zhang +- update the %%file section + +* Sun Dec 17 2000 Wensong Zhang +- Added a if-condition to keep both new or old rpm utility building + the package happily. + +* Tue Dec 12 2000 P.Copeland +- Small modifications to make the compiler happy in RH7 and the Alpha +- Fixed the documentation file that got missed off in building + the rpm +- Made a number of -pedantic mods though popt will not compile with + -pedantic + +* Wed Aug 9 2000 Horms +- Removed Obseletes tag as ipvsadm is back in /sbin where it belongs + as it is more or less analogous to both route and ipchains both of + which reside in /sbin. +- Create directory to install init script into. Init scripts won't install + into build directory unless this is done + +* Thu Jul 6 2000 Wensong Zhang +- Changed to build rpms on the ipvsadm tar ball directly + +* Wed Jun 21 2000 P.Copeland +- fixed silly install permission settings + +* Mon Jun 19 2000 P.Copeland +- Added 'dist' and 'rpms' to the Makefile +- Added Obsoletes tag since there were early versions + of ipvsadm-*.rpm that installed in /sbin +- Obsolete tag was a bit vicious re: piranha + +* Mon Apr 10 2000 Horms +- created for version 1.9 +