Compare commits

..

No commits in common. "c8" and "c9s" have entirely different histories.
c8 ... c9s

12 changed files with 410 additions and 12 deletions

7
.gitignore vendored
View File

@ -1 +1,6 @@
SOURCES/ipvsadm-1.31.tar.gz
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

View File

@ -1 +0,0 @@
2d6fa5fe01f8aa9dd4fc272855c8fc12aea3c06b SOURCES/ipvsadm-1.31.tar.gz

6
gating.yaml Normal file
View File

@ -0,0 +1,6 @@
--- !Policy
product_versions:
- rhel-9
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

189
ipvsadm.init Normal file
View File

@ -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

View File

@ -1,7 +1,7 @@
Name: ipvsadm
Summary: Utility to administer the Linux Virtual Server
Version: 1.31
Release: 1%{?dist}
Release: 8%{?dist}
License: GPLv2+
URL: https://kernel.org/pub/linux/utils/kernel/ipvsadm/
@ -9,12 +9,13 @@ Source0: https://kernel.org/pub/linux/utils/kernel/ipvsadm/%{name}-%{version}.ta
Source1: ipvsadm.service
Source2: ipvsadm-config
Patch3: 0003-ipvsadm-use-CFLAGS-and-LDFLAGS-environment-variables.patch
Patch0: 0003-ipvsadm-use-CFLAGS-and-LDFLAGS-environment-variables.patch
BuildRequires: gcc
Buildrequires: libnl3-devel
Buildrequires: popt-devel
BuildRequires: systemd
BuildRequires: make
Requires(post): systemd
Requires(preun): systemd
@ -36,7 +37,7 @@ services. Supported Features include:
%prep
%setup -q
%patch3 -p1
%patch0 -p1
%build
%set_build_flags
@ -61,7 +62,6 @@ services. Supported Features include:
%systemd_postun_with_restart %{name}.service
%files
%defattr(-,root,root,-)
%doc MAINTAINERS README
%{_unitdir}/%{name}.service
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}-config
@ -73,14 +73,39 @@ services. Supported Features include:
%{_mandir}/man8/%{name}-save.8*
%changelog
* Mon Jan 06 2020 Ryan O'Hara <rohara@redhat.com> - 1.31-1
- Update to 1.31 (#1777995)
* Tue Aug 17 2021 Ryan O'Hara <rohara@redhat.com> - 1.31-8
- Ignore badfuncs error in rpminspect (#1994617)
* Tue Dec 03 2019 Ryan O'Hara <rohara@redhat.com> - 1.30-1
- Update to 1.30 (#1777995)
* Tue Aug 17 2021 Ryan O'Hara <rohara@redhat.com> - 1.31-7
- Add gating tests (#1994617)
* Mon Oct 21 2019 Ryan O'Hara <rohara@redhat.com> - 1.29-9
- Add gating tests (#1682107)
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 1.31-6
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 1.31-5
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.31-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.31-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.31-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Thu Jan 02 2020 Ryan O'Hara <rohara@redhat.com> - 1.31-1
- Update to 1.31 (#1726210)
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.29-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.29-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.29-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Tue Feb 27 2018 Ryan O'Hara <rohara@redhat.com> - 1.29-8
- Use CFLAGS and LDFLAGS environment variables (#1543790)

3
rpminspect.yaml Normal file
View File

@ -0,0 +1,3 @@
---
inspections:
badfuncs: off

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (ipvsadm-1.31.tar.gz) = c02cc54c6c44ac94de632b087a1f95ba9cd4e622e48471e2643900905cd84fa2335496c955ee6507497c7252227575cf309ed97924e062c61d719218bfc25a07

161
tests/run_tests.sh Executable file
View File

@ -0,0 +1,161 @@
#!/bin/sh
set -o pipefail
echo -ne "[debug]: getting IP address ... "
IP_ADDR=$( ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1 )
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
echo -ne "[debug]: adding virtual service ${IP_ADDR}:80 ... "
ipvsadm -A -t ${IP_ADDR}:80 -s rr
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
for i in {1..3}; do
echo -ne "[debug]: adding real server 192.168.100.10${i}:80 ... "
ipvsadm -a -t ${IP_ADDR}:80 -r 192.168.100.10${i}:80 -w 1 -m
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
done
echo -ne "[debug]: checking ipvs is populated ... "
ipvsadm -l -n | grep -q -E "(${IP_ADDR}|192.168.100.10)"
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
for mod in ip_vs_rr ip_vs; do
echo -ne "[debug]: checking for module ${mod} ... "
grep -q "^${mod} " /proc/modules
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
done
echo -ne "[debug]: saving ipvsadm configuration ... "
ipvsadm-save -n > /etc/sysconfig/ipvsadm
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
echo -ne "[debug]: clearing ipvsadm configuration ... "
ipvsadm -C
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
echo -ne "[debug]: checking ipvs is clear ... "
ipvsadm -l -n | grep -E "(${IP_ADDR}|192.168.100.10)"
if [ $? -eq 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
for mod in ip_vs_rr ip_vs; do
echo -ne "[debug]: removing module ${mod} ... "
modprobe -r ${mod}
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
done
for mod in ip_vs_rr ip_vs; do
echo -ne "[debug]: checking for no ${mod} module ... "
grep -q "^${mod} " /proc/modules
if [ $? -eq 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
done
echo -ne "[debug]: restoring ipvsadm configuration ... "
ipvsadm-restore < /etc/sysconfig/ipvsadm
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
echo -ne "[debug]: checking ipvs is populated ... "
ipvsadm -l -n | grep -q -E "(${IP_ADDR}|192.168.100.10)"
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
for mod in ip_vs_rr ip_vs; do
echo -ne "[debug]: checking for module ${mod} ... "
grep -q "^${mod} " /proc/modules
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
done
for i in {3..1}; do
echo -ne "[debug]: removing real server 192.168.100.10${i}:80 ... "
ipvsadm -d -t ${IP_ADDR}:80 -r 192.168.100.10${i}:80
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
done
echo -ne "[debug]: removing virtual service ${IP_ADDR}:80 ... "
ipvsadm -D -t ${IP_ADDR}:80
if [ $? -ne 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
echo -ne "[debug]: checking ipvs is clear ... "
ipvsadm -l -n | grep -E "(${IP_ADDR}|192.168.100.10)"
if [ $? -eq 0 ] ; then
echo "FAIL"
exit 1
else
echo "OK"
fi
exit 0

9
tests/tests.yml Normal file
View File

@ -0,0 +1,9 @@
- hosts: localhost
roles:
- role: standard-test-basic
tags:
- classic
tests:
- simple:
dir: .
run: ./run_tests.sh