diff --git a/.gitignore b/.gitignore index e69de29..7334550 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,6 @@ +ipvsadm-1.25.tar.gz +/ipvsadm-1.26.tar.gz +/ipvsadm-1.27.tar.gz +/ipvsadm-1.28.tar.gz +/ipvsadm-1.29.tar.gz +/ipvsadm-1.31.tar.gz diff --git a/0003-ipvsadm-use-CFLAGS-and-LDFLAGS-environment-variables.patch b/0003-ipvsadm-use-CFLAGS-and-LDFLAGS-environment-variables.patch new file mode 100644 index 0000000..20e0cbe --- /dev/null +++ b/0003-ipvsadm-use-CFLAGS-and-LDFLAGS-environment-variables.patch @@ -0,0 +1,52 @@ +From 25d7aa2faef0c36f053ee1ba418fe14022ef6f7c Mon Sep 17 00:00:00 2001 +From: Ryan O'Hara +Date: Tue, 27 Feb 2018 11:49:44 -0600 +Subject: [PATCH] ipvsadm: use CFLAGS and LDFLAGS environment variables + +Signed-off-by: Ryan O'Hara +--- + Makefile | 6 +++--- + libipvs/Makefile | 2 +- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/Makefile b/Makefile +index 91a2991..2a1d179 100644 +--- a/Makefile ++++ b/Makefile +@@ -46,9 +46,9 @@ INSTALL = install + STATIC_LIBS = libipvs/libipvs.a + + ifeq "${ARCH}" "sparc64" +- CFLAGS = -Wall -Wunused -Wstrict-prototypes -g -m64 -pipe -mcpu=ultrasparc -mcmodel=medlow ++ CFLAGS += -Wall -Wunused -Wstrict-prototypes -g -m64 -pipe -mcpu=ultrasparc -mcmodel=medlow + else +- CFLAGS = -Wall -Wunused -Wstrict-prototypes -g ++ CFLAGS += -Wall -Wunused -Wstrict-prototypes -g + endif + + +@@ -87,7 +87,7 @@ libs: + make -C libipvs + + ipvsadm: $(OBJS) $(STATIC_LIBS) +- $(CC) $(CFLAGS) -o $@ $^ $(LIBS) ++ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) + + install: all + if [ ! -d $(SBIN) ]; then $(MKDIR) -p $(SBIN); fi +diff --git a/libipvs/Makefile b/libipvs/Makefile +index f845c8b..780f3f3 100644 +--- a/libipvs/Makefile ++++ b/libipvs/Makefile +@@ -1,7 +1,7 @@ + # Makefile for libipvs + + CC = gcc +-CFLAGS = -Wall -Wunused -Wstrict-prototypes -g -fPIC ++CFLAGS += -Wall -Wunused -Wstrict-prototypes -g -fPIC + ifneq (0,$(HAVE_NL)) + CFLAGS += -DLIBIPVS_USE_NL + CFLAGS += $(shell \ +-- +2.14.3 + diff --git a/ipvsadm-config b/ipvsadm-config new file mode 100644 index 0000000..34251a3 --- /dev/null +++ b/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/ipvsadm.init b/ipvsadm.init new file mode 100644 index 0000000..804b9b7 --- /dev/null +++ b/ipvsadm.init @@ -0,0 +1,189 @@ +#!/bin/bash +# +# Startup script handle the initialisation of LVS +# chkconfig: - 28 72 +# description: Initialise the Linux Virtual Server +# config: /etc/sysconfig/ipvsadm +# +### BEGIN INIT INFO +# Provides: ipvsadm +# Required-Start: $local_fs $network $named +# Required-Stop: $local_fs $remote_fs $network +# Short-Description: Initialise the Linux Virtual Server +# Description: The Linux Virtual Server is a highly scalable and highly +# available server built on a cluster of real servers, with the load +# balancer running on Linux. +### END INIT INFO + +# Source function library +. /etc/rc.d/init.d/functions + +IPVSADM=ipvsadm +IPVSADMRESTORE=${IPVSADM}-restore +IPVSADMSAVE=${IPVSADM}-save +# Saved IPVS data +IPVSADM_DATA=/etc/sysconfig/$IPVSADM +# Configuration +IPVSADM_CONFIG=/etc/sysconfig/${IPVSADM}-config +IPVS=ip_vs +PROC_IPVS=/proc/net/$IPVS +VAR_SUBSYS_IPVSADM=/var/lock/subsys/$IPVSADM + +if [ ! -x /sbin/$IPVSADM ]; then + echo -n $"${IPVSADM}: /sbin/$IPVSADM does not exist."; warning; echo + exit 5 +fi + +# Old or new modutils +/sbin/modprobe --version 2>&1 | grep -q module-init-tools \ + && NEW_MODUTILS=1 \ + || NEW_MODUTILS=0 + +# Default IPVSADM configuration: +IPVS_MODULES_UNLOAD="yes" +IPVS_SAVE_ON_STOP="no" +IPVS_SAVE_ON_RESTART="no" +IPVS_STATUS_NUMERIC="yes" + +# Load IPVSADM configuration. +[ -f "$IPVSADM_CONFIG" ] && . "$IPVSADM_CONFIG" + +rmmod_r() { + # Unload module with all referring modules. + # At first all referring modules will be unloaded, then the module itself. + local mod=$1 + local ret=0 + local ref= + + # Get referring modules. + # New modutils have another output format. + [ $NEW_MODUTILS = 1 ] \ + && ref=$(lsmod | awk "/^${mod}[[:space:]]/ { print \$4; }" | tr ',' ' ') \ + || ref=$(lsmod | grep ^${mod} | cut -d "[" -s -f 2 | cut -d "]" -s -f 1) + + # recursive call for all referring modules + for i in $ref; do + rmmod_r $i + let ret+=$?; + done + + # Unload module. + # The extra test is for 2.6: The module might have autocleaned, + # after all referring modules are unloaded. + if grep -q "^${mod}" /proc/modules ; then + modprobe -r $mod > /dev/null 2>&1 + res=$? + [ $res -eq 0 ] || echo -n " $mod" + let ret+=$res; + fi + + return $ret +} + +start() { + # Do not start if there is no config file. + [ ! -f "$IPVSADM_DATA" ] && return 6 + + # If we don't clear these first, we might be adding to pre-existing rules. + action $"${IPVSADM}: Clearing the current IPVS table:" $IPVSADM -C + + echo -n $"${IPVSADM}: Applying IPVS configuration: " + $IPVSADMRESTORE < ${IPVSADM_DATA} + if [ $? -eq 0 ];then success; echo; else failure; echo; return 1;fi + + touch $VAR_SUBSYS_IPVSADM +} + +stop() { + # Do not stop if ipvs module is not loaded. + [ ! -e "$PROC_IPVS" ] && return 0 + + action $"${IPVSADM}: Clearing the current IPVS table:" $IPVSADM -C + + ret=0 + + if [ "x$IPVS_MODULES_UNLOAD" = "xyes" ]; then + action $"${IPVSADM}: Unloading modules:" rmmod_r $IPVS + [ $? -ne 0 ] && ret=1 + fi + + rm -f $VAR_SUBSYS_IPVSADM + + return $ret +} + +status() { + # Do not print status if lockfile is missing and ipvs modules are not + # loaded. + if [ ! -f "$VAR_SUBSYS_IPVSADM" -a ! -e "$PROC_IPVS" ]; then + echo $"${IPVSADM}: IPVS is not running." + return 3 + fi + + # Do show status if ipvs module is not loaded. + if [ ! -e "$PROC_IPVS" ];then + echo $"${IPVSADM}: IPVS module is not loaded." + return 3 + fi + + NUM="" + [ "x$IPVS_STATUS_NUMERIC" = "xyes" ] && NUM="-n" + + $IPVSADM -L $NUM && echo +} + +save() { + # Check if module is loaded + [ ! -e "$PROC_IPVS" ] && return 0 + + echo -n $"${IPVSADM}: Saving IPVS table to ${IPVSADM_DATA}: " + $IPVSADMSAVE -n > ${IPVSADM_DATA} 2>/dev/null + if [ $? -eq 0 ];then success; echo; else failure; echo; return 1;fi + + return 0 +} + +restart() { + [ "x$IPVS_SAVE_ON_RESTART" = "xyes" ] && save + stop + start +} + +# See how we were called. +case "$1" in + start) + [ -f "$VAR_SUBSYS_IPVSADM" ] && exit 0 + + # If we have no configuration, save the current one + [ -f ${IPVSADM_DATA} ] || save + start + RETVAL=$? + ;; + stop) + [ "x$IPVS_SAVE_ON_STOP" = "xyes" ] && save + stop + RETVAL=$? + ;; + restart|force-reload) + restart + RETVAL=$? + ;; + reload) + # Start will flush everything, so it counts as a reload + start + RETVAL=$? + ;; + status) + status + RETVAL=$? + ;; + save) + save + RETVAL=$? + ;; + *) + echo "Usage: $0 {start|stop|restart|force-reload|reload|status|save}" + RETVAL=2 +esac + +exit $RETVAL diff --git a/ipvsadm.service b/ipvsadm.service new file mode 100644 index 0000000..a1d497f --- /dev/null +++ b/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/ipvsadm.spec b/ipvsadm.spec new file mode 100644 index 0000000..6cba9a4 --- /dev/null +++ b/ipvsadm.spec @@ -0,0 +1,313 @@ +Name: ipvsadm +Summary: Utility to administer the Linux Virtual Server +Version: 1.31 +Release: 3%{?dist} +License: GPLv2+ +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: 0003-ipvsadm-use-CFLAGS-and-LDFLAGS-environment-variables.patch + +BuildRequires: gcc +Buildrequires: libnl3-devel +Buildrequires: popt-devel +BuildRequires: systemd + +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd + +%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 + +%build +%set_build_flags +%{__make} + +%install +%{__rm} -rf %{buildroot} +%{__mkdir_p} %{buildroot}%{_sysconfdir}/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 + +%{__rm} -f %{buildroot}%{_sysconfdir}/rc.d/init.d/%{name} +%{__install} -p -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service +%{__install} -p -D -m 0600 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/%{name}-config + +%post +%systemd_post %{name}.service + +%preun +%systemd_preun %{name}.service + +%postun +%systemd_postun_with_restart %{name}.service + +%files +%doc MAINTAINERS README +%{_unitdir}/%{name}.service +%config(noreplace) %{_sysconfdir}/sysconfig/%{name}-config +%{_sbindir}/%{name} +%{_sbindir}/%{name}-restore +%{_sbindir}/%{name}-save +%{_mandir}/man8/%{name}.8* +%{_mandir}/man8/%{name}-restore.8* +%{_mandir}/man8/%{name}-save.8* + +%changelog +* Tue Jul 28 2020 Fedora Release Engineering - 1.31-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Wed Jan 29 2020 Fedora Release Engineering - 1.31-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Thu Jan 02 2020 Ryan O'Hara - 1.31-1 +- Update to 1.31 (#1726210) + +* Thu Jul 25 2019 Fedora Release Engineering - 1.29-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Fri Feb 01 2019 Fedora Release Engineering - 1.29-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Fri Jul 13 2018 Fedora Release Engineering - 1.29-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Tue Feb 27 2018 Ryan O'Hara - 1.29-8 +- Use CFLAGS and LDFLAGS environment variables (#1543790) + +* Fri Feb 23 2018 Ryan O'Hara - 1.29-7 +- Add %set_build_flags (#1543790) + +* Wed Feb 07 2018 Fedora Release Engineering - 1.29-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Mon Feb 05 2018 Ryan O'Hara - 1.29-5 +- Catch the original errno from netlink answer (#1526813) + +* Wed Aug 02 2017 Fedora Release Engineering - 1.29-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Wed Jul 26 2017 Fedora Release Engineering - 1.29-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Fri Feb 10 2017 Fedora Release Engineering - 1.29-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Thu Dec 29 2016 Ryan O'Hara - 1.29-1 +- Update to 1.29 (#1408437) + +* Thu Feb 04 2016 Fedora Release Engineering - 1.28-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Wed Jun 17 2015 Fedora Release Engineering - 1.28-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Mon Feb 09 2015 Ryan O'Hara - 1.28-1 +- Update to 1.28 + +* Sat Aug 16 2014 Fedora Release Engineering - 1.27-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Sat Jun 07 2014 Fedora Release Engineering - 1.27-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Wed May 21 2014 Ryan O'Hara - 1.27-5 +- Fix ipvsadm to show backup sync daemon + +* Tue May 20 2014 Ryan O'Hara - 1.27-4 +- Fix compiler warnings + +* Mon May 19 2014 Ryan O'Hara - 1.27-3 +- Update spec file and fix install paths + +* Fri Nov 22 2013 Xose Vazquez Perez - 1.27-2 +- Link with libnl3 + +* Fri Sep 06 2013 Ryan O'Hara - 1.27-1 +- Update to 1.27 + +* Sat Aug 03 2013 Fedora Release Engineering - 1.26-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* 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.opeland +- 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 + diff --git a/sources b/sources new file mode 100644 index 0000000..189522c --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (ipvsadm-1.31.tar.gz) = c02cc54c6c44ac94de632b087a1f95ba9cd4e622e48471e2643900905cd84fa2335496c955ee6507497c7252227575cf309ed97924e062c61d719218bfc25a07