Compare commits

...
Sign in to create a new pull request.

56 commits

Author SHA1 Message Date
Fedora Release Engineering
08a38ea64a Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild 2025-07-24 17:45:50 +00:00
Phil Sutter
3dd0bb4701 New version 7.24 2025-05-20 13:32:16 +02:00
Phil Sutter
506847bd39 New version 7.23 2025-05-07 16:39:33 +02:00
Fedora Release Engineering
e6e33e65e2 Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild 2025-01-17 07:21:42 +00:00
Phil Sutter
044838f10f ipset-7.22-1
- Turn absolute ipset-translate symlink into a relative one
- Rebase onto v7.22 plus fixes
2024-08-01 14:29:26 +02:00
Fedora Release Engineering
5cff36f454 Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild 2024-07-18 10:33:14 +00:00
Nicolas Chauvet
411d25f4a6 Update to 7.21 2024-02-12 13:17:00 +01:00
Nicolas Chauvet
d87bd16c2c Update to 7.20 2024-02-01 14:20:15 +01:00
Fedora Release Engineering
a657c361cb Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild 2024-01-24 22:53:46 +00:00
Fedora Release Engineering
10bf621d6d Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild 2024-01-20 23:14:58 +00:00
Nicolas Chauvet
1d4434c8b2 Update to 7.19 2023-10-23 13:53:29 +02:00
Phil Sutter
904bbed4dd Convert license to SPDX format
Signed-off-by: Phil Sutter <psutter@redhat.com>
2023-08-11 21:14:56 +02:00
Phil Sutter
ff45e749b2 Convert license to SPDX format
Signed-off-by: Phil Sutter <psutter@redhat.com>
2023-08-11 21:14:14 +02:00
Phil Sutter
3b8395e7e6 Convert license to SPDX format
Signed-off-by: Phil Sutter <psutter@redhat.com>
2023-08-11 21:13:57 +02:00
Phil Sutter
e39a6f6c54 Convert license to SPDX format
Signed-off-by: Phil Sutter <psutter@redhat.com>
2023-08-11 21:13:50 +02:00
Fedora Release Engineering
3ea856c0e0 Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2023-07-20 07:35:10 +00:00
Fedora Release Engineering
cbda24853d Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2023-01-19 13:18:58 +00:00
Nicolas Chauvet
22c1fd017f Update to 7.17 2023-01-02 11:14:59 +01:00
Nicolas Chauvet
ea2bf80271 Update to 7.16 2022-12-02 15:55:59 +01:00
Nicolas Chauvet
9c8c2ff4ef Update changelog 2022-08-23 09:09:56 +02:00
Nicolas Chauvet
6e97b0dc61 Apply upstream patches 2022-08-23 09:08:46 +02:00
Nicolas Chauvet
9b6e51ae7b Add upstream patches 2022-08-23 09:07:51 +02:00
Fedora Release Engineering
80a30e48f5 Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2022-07-21 14:48:58 +00:00
Phil Sutter
2c76e0d4d8 ipset-7.15-3
- Use the advanced init script from Centos9Stream

Resolves: rhbz#2052926
2022-03-15 19:08:07 +01:00
Fedora Release Engineering
11d86e40ec - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2022-01-20 13:25:14 +00:00
Nicolas Chauvet
000dbd0940 Update to 7.15 2021-08-16 15:56:09 +02:00
Nicolas Chauvet
3cb6e93113 Update to 7.14 2021-07-28 20:03:56 +02:00
Fedora Release Engineering
6bf608f3aa - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2021-07-22 08:42:09 +00:00
Zbigniew Jędrzejewski-Szmek
24f8d49622 Rebuilt for updated systemd-rpm-macros
See https://pagure.io/fesco/issue/2583.
2021-03-02 16:13:36 +01:00
Nicolas Chauvet
522137356f Update to 7.11 2021-03-01 21:35:10 +01:00
Fedora Release Engineering
0742e37439 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2021-01-26 14:27:56 +00:00
Nicolas Chauvet
b9164d90d8 Update to 7.10 2020-12-21 10:24:46 +01:00
Nicolas Chauvet
69dd066246 Fixup make BR 2020-12-21 10:23:43 +01:00
Tom Stellard
80410c56f5 Add BuildRequires: make
https://fedoraproject.org/wiki/Changes/Remove_make_from_BuildRoot
2020-12-19 00:54:20 +00:00
Nicolas Chauvet
99a4095dd7 Update to 7.9 2020-12-16 09:26:29 +01:00
Fedora Release Engineering
c937e6ad0a - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2020-07-28 01:55:43 +00:00
Nicolas Chauvet
64e0be575c Update to 7.6 2020-02-24 11:27:16 +01:00
Fedora Release Engineering
e48e9a1dd2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2020-01-29 05:36:09 +00:00
Nicolas Chauvet
98c9987835 Update to 7.5 2020-01-10 09:43:10 +01:00
Eric Garver
cd2727ae8f Update to 7.4
Resolves: rhbz 1767905
2019-11-04 15:09:00 -05:00
Nicolas Chauvet
eb982c9154 Update to 7.3 2019-08-19 12:15:41 +02:00
Fedora Release Engineering
7ad1b36931 - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2019-07-25 09:39:58 +00:00
Nicolas Chauvet
74a8b03f91 Add missing man 2019-07-11 18:23:42 +02:00
Nicolas Chauvet
dfbb15cf5b Bump abi - but no users 2019-07-11 18:16:38 +02:00
Nicolas Chauvet
7ae4b9eb67 Update to 7.2 2019-07-11 16:58:55 +02:00
Fedora Release Engineering
701b47134b - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2019-02-01 03:30:14 +00:00
Nicolas Chauvet
593bb710a2 Update to 6.38 2018-08-13 14:02:27 +02:00
Eric Garver
b39b90d0a4 Merge #1 Adds tests according to the CI 2018-07-17 14:53:20 +00:00
Fedora Release Engineering
81db011686 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2018-07-13 05:48:46 +00:00
Susant Sahani
4f5f54a6f7 Adds tests according to the CI
justification
Adds tests according to the CI wiki specifically the standard test interface in the spec.
The playbook includes Tier1 level test cases that have been tested in the following contexts and
is passing reliably: Classic. Test logs are stored in the artifacts directory.
The following steps are used to execute the tests using the standard test interface:

Test enveronment
Make sure you have installed packages from the spec
```
ansible-2.4.1.0-2.fc28.noarch
python2-dnf-2.7.5-1.fc28.noarch
libselinux-python-2.7-2.fc28.x86_64
standard-test-roles-2.5-1.fc28.noarch
Run tests for Classic
```

Snip of the example test run for Classic tests:

```
test_ipset_add_bitmap_ip (__main__.IpsetTests) ... 192.168.11.12 is in set testnet.
192.168.11.13 is in set testnet.
192.168.11.14 is in set testnet.
192.168.11.15 is in set testnet.
ok
test_ipset_bitmap_ip_netfilter (__main__.IpsetTests) ... 192.168.225.32 is in set testnetiperf.
192.168.225.33 is in set testnetiperf.
Connecting to host 192.168.225.32, port 55555
[  5] local 192.168.225.32 port 54652 connected to 192.168.225.32 port 55555
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  7.79 GBytes  66.9 Gbits/sec    0    895 KBytes
[  5]   1.00-2.00   sec  7.99 GBytes  68.6 Gbits/sec    0    895 KBytes
[  5]   2.00-3.00   sec  7.99 GBytes  68.6 Gbits/sec    0   1.75 MBytes
[  5]   3.00-4.00   sec  7.79 GBytes  66.9 Gbits/sec    0   1.75 MBytes
[  5]   4.00-5.00   sec  8.03 GBytes  69.0 Gbits/sec    0   1.75 MBytes
[  5]   5.00-6.00   sec  7.94 GBytes  68.2 Gbits/sec    0   2.25 MBytes
[  5]   6.00-7.00   sec  7.88 GBytes  67.7 Gbits/sec    0   2.25 MBytes
[  5]   7.00-8.00   sec  8.06 GBytes  69.2 Gbits/sec    0   2.25 MBytes
[  5]   8.00-9.00   sec  7.89 GBytes  67.8 Gbits/sec    0   2.25 MBytes
[  5]   9.00-10.00  sec  7.85 GBytes  67.4 Gbits/sec    0   2.25 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  79.2 GBytes  68.0 Gbits/sec    0             sender
[  5]   0.00-10.04  sec  79.2 GBytes  67.8 Gbits/sec                  receiver

iperf Done.
iperf3: error - unable to connect to server: Connection timed out
ok
test_ipset_delete_bitmap_ip (__main__.IpsetTests) ... 192.168.11.12 is in set testnet.
192.168.11.13 is in set testnet.
192.168.11.12 is NOT in set testnet.
ok
test_ipset_hash_bitmap_ipport (__main__.IpsetTests) ... 192.168.1.1,udp:53 is in set testipport.
192.168.1.1,tcp:5555 is in set testipport.
192.168.1.1,tcp:5555 is NOT in set testipport.
ok
test_ipset_hash_bitmap_ipportip (__main__.IpsetTests) ... 192.168.1.1,tcp:80,10.0.0.1 is in set testipportip.
192.168.1.1,tcp:80,10.0.0.1 is in set testipportip.
192.168.1.1,tcp:80,10.0.0.1 is NOT in set testipportip.
ok
192.168.1.1,tcp:80,10.0.0.1 is NOT in set testipportip.
ok
test_ipset_hash_bitmap_mac (__main__.IpsetTests) ... 02:01:02:03:04:09 is in set testmac.
02:01:02:03:04:09 is NOT in set testmac.
ok
test_ipset_hash_bitmap_netiface (__main__.IpsetTests) ... 192.168.0.0/24,veth-test is in set testnetiface.
192.167.0.0/24,veth-peer is in set testnetiface.
192.168.0.0/24,veth-test is NOT in set testnetiface.
ok

----------------------------------------------------------------------
Ran 7 tests in 15.545s

OK
:: [ 16:37:57 ] :: [   PASS   ] :: Command '/usr/bin/python3 /usr/bin/ipset-tests.py' (Expected 0, got 0)
:: [ 16:37:57 ] :: [   PASS   ] :: Command '/usr/bin/python3 /usr/bin/ipset-tests.py' (Expected 0, got 0)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Duration: 15s
::   Duration: 15s
::   Assertions: 1 good, 0 bad
::   Assertions: 1 good, 0 bad
::   RESULT: PASS
::   RESULT: PASS

```
2018-06-24 16:41:06 +05:30
Eric Garver
cee010372f Patch for missing header file (RHBZ#1543596) 2018-02-12 12:28:36 -05:00
Fedora Release Engineering
54e38f567a - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2018-02-07 17:36:49 +00:00
Nicolas Chauvet
c03b2902c2 Bump soname (no downstream users so far) 2018-01-08 22:40:33 +01:00
Nicolas Chauvet
608536df36 Update to 6.35 2018-01-08 22:33:55 +01:00
Nicolas Chauvet
b033adb0b2 Update to 6.32 2017-07-31 14:55:54 +02:00
Fedora Release Engineering
bc20e66999 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild 2017-07-26 13:39:44 +00:00
11 changed files with 863 additions and 206 deletions

13
.gitignore vendored
View file

@ -1,12 +1 @@
/ipset-6.9.1.tar.bz2
/ipset-6.11.tar.bz2
/ipset-6.13.tar.bz2
/ipset-6.14.tar.bz2
/ipset-6.16.1.tar.bz2
/ipset-6.19.tar.bz2
/ipset-6.20.1.tar.bz2
/ipset-6.21.1.tar.bz2
/ipset-6.22.tar.bz2
/ipset-6.26.tar.bz2
/ipset-6.27.tar.bz2
/ipset-6.29.tar.bz2
ipset-*.tar.bz2

5
ipset-config Normal file
View file

@ -0,0 +1,5 @@
# Save current ipsets on stop.
# Value: yes|no, default: no
# Saves all ipsets to /etc/sysconfig/ipset.d/ if service gets stopped
# (e.g. on system shutdown).
IPSET_SAVE_ON_STOP="no"

View file

@ -9,10 +9,11 @@ RemainAfterExit=yes
ExecStart=/usr/libexec/ipset/ipset.start-stop start
ExecStop=/usr/libexec/ipset/ipset.start-stop stop
ExecReload=/usr/libexec/ipset/ipset.start-stop reload
# Save current ipset entries on stop/restart.
# Save current ipset entries on stop.
# Value: yes|no, default: no
# Saves all ipsets to /etc/ipset/ipset if ipset gets stopped
Environment=IPSET_SAVE_ON_STOP=no IPSET_SAVE_ON_RESTART=no
# Saves all ipsets to /etc/sysconfig/ipset if ipset gets stopped
Environment=IPSET_SAVE_ON_STOP=no
EnvironmentFile=-/etc/sysconfig/ipset-config
[Install]
WantedBy=basic.target

View file

@ -1,15 +1,21 @@
Name: ipset
Version: 6.29
Release: 3%{?dist}
Version: 7.24
Release: 2%{?dist}
Summary: Manage Linux IP sets
License: GPLv2
License: GPL-2.0-only
URL: http://ipset.netfilter.org/
Source0: http://ipset.netfilter.org/%{name}-%{version}.tar.bz2
Source0: %{url}/%{name}-%{version}.tar.bz2
Source1: %{name}.service
Source2: %{name}.start-stop
Source3: %{name}-config
BuildRequires: libmnl-devel
BuildRequires: automake
BuildRequires: autoconf
BuildRequires: make
BuildRequires: libtool
BuildRequires: libtool-ltdl-devel
# An explicit requirement is needed here, to avoid cases where a user would
# explicitly update only one of the two (e.g 'yum update ipset')
@ -65,10 +71,11 @@ out of the base package since it is not active by default.
%prep
%setup -q
%autosetup -p1
%build
./autogen.sh
%configure --enable-static=no --with-kmod=no
# Just to make absolutely sure we are not building the bundled kernel module
@ -79,11 +86,11 @@ rm -fr kernel
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
make %{?_smp_mflags}
%make_build
%install
make install DESTDIR=%{buildroot}
%make_install
find %{buildroot} -name '*.la' -exec rm -f '{}' \;
# install systemd unit file
@ -94,9 +101,16 @@ install -c -m 644 %{SOURCE1} %{buildroot}/%{_unitdir}
install -d -m 755 %{buildroot}%{_libexecdir}/%{name}
install -c -m 755 %{SOURCE2} %{buildroot}%{_libexecdir}/%{name}
# install ipset-config
install -d -m 755 %{buildroot}%{_sysconfdir}/sysconfig
install -c -m 600 %{SOURCE3} %{buildroot}%{_sysconfdir}/sysconfig/%{name}-config
# Create directory for configuration
mkdir -p %{buildroot}%{_sysconfdir}/%{name}
# Turn absolute symlink into a relative one
ln -sf %{name} %{buildroot}/%{_sbindir}/%{name}-translate
%preun
if [[ $1 -eq 0 && -n $(lsmod | grep "^xt_set ") ]]; then
@ -105,13 +119,23 @@ if [[ $1 -eq 0 && -n $(lsmod | grep "^xt_set ") ]]; then
fi
%post libs -p /sbin/ldconfig
%postun libs -p /sbin/ldconfig
%ldconfig_scriptlets libs
%post service
%systemd_post %{name}.service
if [[ -f /etc/ipset/ipset ]] && [[ ! -f /etc/sysconfig/ipset ]]; then
mv /etc/ipset/ipset /etc/sysconfig/ipset
ln -s /etc/sysconfig/ipset /etc/ipset/ipset
echo "Warning: ipset save location has moved to /etc/sysconfig"
fi
[[ -f /etc/sysconfig/iptables-config ]] && . /etc/sysconfig/iptables-config
[[ -f /etc/sysconfig/ip6tables-config ]] && . /etc/sysconfig/ip6tables-config
if [[ ${IPTABLES_SAVE_ON_STOP} == yes ]] || \
[[ ${IP6TABLES_SAVE_ON_STOP} == yes ]]; then
echo "Warning: ipset no longer saves automatically when iptables does"
echo " must enable explicitly in /etc/sysconfig/ipset-config"
fi
%preun service
if [[ $1 -eq 0 && -n $(lsmod | grep "^xt_set ") ]]; then
@ -125,27 +149,176 @@ fi
%files
%doc COPYING ChangeLog
%doc %{_mandir}/man8/%{name}.8.gz
%doc ChangeLog
%license COPYING
%{_mandir}/man8/%{name}*.8.*
%{_sbindir}/%{name}
%{_sbindir}/%{name}-translate
%files libs
%doc COPYING
%{_libdir}/lib%{name}.so.3*
%license COPYING
%{_libdir}/lib%{name}.so.13*
%files devel
%{_includedir}/lib%{name}
%{_libdir}/lib%{name}.so
%{_libdir}/pkgconfig/lib%{name}.pc
%{_mandir}/man3/libipset.3.*
%files service
%{_unitdir}/%{name}.service
%dir %{_libexecdir}/%{name}
%config(noreplace) %attr(0600,root,root) %{_sysconfdir}/sysconfig/ipset-config
%ghost %config(noreplace) %attr(0600,root,root) %{_sysconfdir}/sysconfig/ipset
%attr(0755,root,root) %{_libexecdir}/%{name}/%{name}.start-stop
%dir %{_sysconfdir}/%{name}
%changelog
* Thu Jul 24 2025 Fedora Release Engineering <releng@fedoraproject.org> - 7.24-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild
* Tue May 20 2025 Phil Sutter <psutter@redhat.com> - 7.24-1
- new version
* Wed May 07 2025 Phil Sutter <psutter@redhat.com> - 7.23-1
- new version
* Fri Jan 17 2025 Fedora Release Engineering <releng@fedoraproject.org> - 7.22-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild
* Thu Aug 01 2024 Phil Sutter <psutter@redhat.com> - 7.22-1
- Turn absolute ipset-translate symlink into a relative one
- Rebase onto v7.22 plus fixes
* Thu Jul 18 2024 Fedora Release Engineering <releng@fedoraproject.org> - 7.21-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild
* Mon Feb 12 2024 Nicolas Chauvet <kwizart@gmail.com> - 7.21-1
- Update to 7.21
* Thu Feb 01 2024 Nicolas Chauvet <kwizart@gmail.com> - 7.20-1
- Update to 7.20
* Wed Jan 24 2024 Fedora Release Engineering <releng@fedoraproject.org> - 7.19-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Sat Jan 20 2024 Fedora Release Engineering <releng@fedoraproject.org> - 7.19-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Mon Oct 23 2023 Nicolas Chauvet <kwizart@gmail.com> - 7.19-1
- Update to 7.19
* Fri Aug 11 2023 Phil Sutter <psutter@redhat.com> - 7.17-7
- Convert license to SPDX format
* Fri Aug 11 2023 Phil Sutter <psutter@redhat.com> - 7.17-6
- Convert license to SPDX format
* Fri Aug 11 2023 Phil Sutter <psutter@redhat.com> - 7.17-5
- Convert license to SPDX format
* Fri Aug 11 2023 Phil Sutter <psutter@redhat.com> - 7.17-4
- Convert license to SPDX format
* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 7.17-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 7.17-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Mon Jan 02 2023 Nicolas Chauvet <kwizart@gmail.com> - 7.17-1
- Update to 7.17
* Fri Dec 02 2022 Nicolas Chauvet <kwizart@gmail.com> - 7.16-1
- Update to 7.16
* Tue Aug 23 2022 Nicolas Chauvet <kwizart@gmail.com> - 7.15-5
- Backport upstream patches - rhbz#2117654
ipset-translate does not work with IPv6 sets
* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 7.15-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Tue Mar 15 2022 Phil Sutter <psutter@redhat.com> - 7.15-3
- Use the advanced init script from Centos9Stream
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 7.15-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Mon Aug 16 2021 Nicolas Chauvet <kwizart@gmail.com> - 7.15-1
- Update to 7.15
* Wed Jul 28 2021 Nicolas Chauvet <kwizart@gmail.com> - 7.14-1
- Update to 7.14
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 7.11-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Tue Mar 02 2021 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 7.11-2
- Rebuilt for updated systemd-rpm-macros
See https://pagure.io/fesco/issue/2583.
* Mon Mar 01 2021 Nicolas Chauvet <kwizart@gmail.com> - 7.11-1
- Update to 7.11
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 7.10-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Mon Dec 21 2020 Nicolas Chauvet <kwizart@gmail.com> - 7.10-1
- Update to 7.10
* Wed Dec 16 2020 Nicolas Chauvet <kwizart@gmail.com> - 7.9-1
- Update to 7.9
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 7.6-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Mon Feb 24 2020 Nicolas Chauvet <kwizart@gmail.com> - 7.6-1
- Update to 7.6
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 7.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Fri Jan 10 2020 Nicolas Chauvet <kwizart@gmail.com> - 7.5-1
- Update to 7.5
* Mon Nov 04 2019 Eric Garver <eric@garver.life> - 7.4-1
- Update to 7.4
* Mon Aug 19 2019 Nicolas Chauvet <kwizart@gmail.com> - 7.3-1
- Update to 7.3
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 7.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Thu Jul 11 2019 Nicolas Chauvet <kwizart@gmail.com> - 7.2-1
- Update to 7.2
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 6.38-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Mon Aug 13 2018 Nicolas Chauvet <kwizart@gmail.com> - 6.38-1
- Update to 6.38
- Clean-up spec
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 6.35-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Mon Feb 12 2018 Eric Garver <egarver@redhat.com> - 6.35-3
- Patch for missing header file (RHBZ#1543596)
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 6.35-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Mon Jan 08 2018 Nicolas Chauvet <kwizart@gmail.com> - 6.35-1
- Update to 6.35
* Mon Jul 31 2017 Nicolas Chauvet <kwizart@gmail.com> - 6.32-1
- Update to 6.32
* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 6.29-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Fri Apr 07 2017 Nicolas Chauvet <kwizart@gmail.com> - 6.29-3
- Userspace needs kernel-headers - rhbz#1420864

View file

@ -1,209 +1,359 @@
#!/bin/bash
#!/bin/sh
#
# ipset Start and stop ipset firewall sets
#
# config: /etc/ipset/ipset
#
# config: /etc/sysconfig/ipset-config
IPSET=ipset
IPSET_BIN=/usr/sbin/${IPSET}
IPSET_DATA=/etc/${IPSET}/${IPSET}
IPSET_BIN=/usr/sbin/ipset
IPSET_CONFIG=/etc/sysconfig/ipset-config
IPSET_DATA_COMPAT=/etc/sysconfig/ipset
IPSET_DATA_COMPAT_BACKUP=${IPSET_DATA_COMPAT}.save
IPSET_DATA_DIR=/etc/sysconfig/ipset.d
IPSET_DATA_DIR_BACKUP=${IPSET_DATA_DIR}.save
IPSET_DATA_SAVED_FLAG=${IPSET_DATA_DIR}/.saved
IPSET_LOCK=/run/ipset.lock
IPSET_RUN=/run/ipset.run
CLEAN_FILES=""
IPTABLES_CONFIG=/etc/sysconfig/iptables-config
IP6TABLES_CONFIG=${IPTABLES_CONFIG/iptables/ip6tables}
trap "rm -rf \${CLEAN_FILES}" EXIT
TMP_FIFO=/tmp/${IPSET}.$$
if [[ ! -x ${IPSET_BIN} ]]; then
echo "${IPSET_BIN} does not exist."
exit 5
fi
CLEAN_FILES=TMP_FIFO
trap "rm -f \$CLEAN_FILES" EXIT
# Default ipset configuration:
[[ -z $IPSET_SAVE_ON_STOP ]] && IPSET_SAVE_ON_STOP=no # Overridden by ip(6)tables IP(6)TABLES_SAVE_ON_STOP
[[ -z $IPSET_SAVE_ON_RESTART ]] && IPSET_SAVE_ON_RESTART=no # Overridden by ip(6)tables IP(6)TABLES_SAVE_ON_RESTART
# Load iptables configuration(s)
[[ -f "$IPTABLES_CONFIG" ]] && . "$IPTABLES_CONFIG"
[[ -f "$IP6TABLES_CONFIG" ]] && . "$IP6TABLES_CONFIG"
# It doesn't make sense to save iptables config and not our config
[[ ${IPTABLES_SAVE_ON_STOP} = yes || ${IP6TABLES_SAVE_ON_STOP} = yes ]] && IPSET_SAVE_ON_STOP=yes
[[ ${IPTABLES_SAVE_ON_RESTART} = yes || ${IP6TABLES_SAVE_ON_RESTART} = yes ]] && IPSET_SAVE_ON_RESTART=yes
check_can_unload() {
# If the xt_set module is loaded and can't be unloaded, then iptables is
# using ipsets, so refuse to stop the service.
if [[ -n $(lsmod | grep "^xt_set ") ]]; then
rmmod xt_set 2>/dev/null
[[ $? -ne 0 ]] && echo Current iptables configuration requires ipsets && return 1
fi
return 0
info() {
echo "ipset: ${*}" >&2
}
flush_n_delete() {
local ret=0 set
# Flush sets
${IPSET_BIN} flush
let ret+=$?
# Delete ipset sets. If we don't do them individually, then none
# will be deleted unless they all can be.
for set in $(${IPSET_BIN} list -name); do
${IPSET_BIN} destroy 2>/dev/null
[[ $? -ne 0 ]] && ret=1
done
return $ret
warn() {
echo "<4>ipset: ${*}" >&2
}
start_clean()
{
mkfifo -m go= "${TMP_FIFO}"
[[ $? -ne 0 ]] && return 1
# Get the lists of sets in current(old) config and new config
old_sets="$(${IPSET_BIN} list -name | sort -u)"
new_sets="$(grep ^create "${IPSET_DATA}" | cut -d " " -f 2 | sort -u)"
# List of sets no longer wanted
drop_sets="$( printf "%s\n" "${old_sets}" > "${TMP_FIFO}" &
printf "%s\n" "${new_sets}" | comm -23 "${TMP_FIFO}" -
)"
# Get rid of sets no longer needed
# Unfortunately -! doesn't work for destroy, so we have to do it a command at a time
for dset in $drop_sets; do
ipset destroy $dset 2>/dev/null
# If it won't go - ? in use by iptables, just clear it
[[ $? -ne 0 ]] && ipset flush $dset
done
# Now delete the set members no longer required
${IPSET_BIN} save | grep "^add " | sort >${TMP_FIFO} &
grep "^add " ${IPSET_DATA} | sort | comm -23 ${TMP_FIFO} - | sed -e "s/^add /del /" \
| ${IPSET_BIN} restore -!
# At last we can add the set members we haven't got
ipset restore -! <${IPSET_DATA}
rm ${TMP_FIFO}
return 0
err() {
echo "<3>ipset: ${*}" >&2
}
start() {
# Do not start if there is no config file.
[[ ! -f "$IPSET_DATA" ]] && echo "Loaded with no configuration" && return 0
[ -x ${IPSET_BIN} ] || { err "Cannot execute ${IPSET_BIN}"; exit 1; }
# We can skip the first bit and do a simple load if
# there is no current ipset configuration
res=1
if [[ -n $(${IPSET_BIN} list -name) ]]; then
# The following may fail for some bizarre reason
start_clean
res=$?
# Source ipset configuration
# shellcheck source=ipset-config
[ -f ${IPSET_CONFIG} ] && . ${IPSET_CONFIG}
[[ $res -ne 0 ]] && echo "Some old configuration may remain"
fi
set -f
# res -ne 0 => either start_clean failed, or we didn't need to run it
if [[ $res -ne 0 ]]; then
# This is the easy way to start but would leave any old
# entries still configured. Still, better than nothing -
# but fine if we had no config
${IPSET_BIN} restore -! <${IPSET_DATA}
res=$?
fi
if [[ $res -ne 0 ]]; then
return 1
fi
return 0
}
stop() {
# Nothing to stop if ip_set module is not loaded.
lsmod | grep -q "^ip_set "
[[ $? -ne 0 ]] && return 6
flush_n_delete
[[ $? -ne 0 ]] && echo Warning: Not all sets were flushed/deleted
return 0
lock() {
CLEAN_FILES="${CLEAN_FILES} ${IPSET_LOCK}"
until mkdir ${IPSET_LOCK} 2>/dev/null; do :; done
}
save() {
# Do not save if ip_set module is not loaded.
lsmod | grep -q "^ip_set "
[[ $? -ne 0 ]] && return 6
fail=0
[[ -z $(${IPSET_BIN} list -name) ]] && return 0
# Make backups of existing configuration first, if any
[ -d ${IPSET_DATA_DIR} ] && mv -Tf ${IPSET_DATA_DIR} ${IPSET_DATA_DIR_BACKUP}
[ -f ${IPSET_DATA_COMPAT} ] && mv -Tf ${IPSET_DATA_COMPAT} ${IPSET_DATA_COMPAT_BACKUP}
ret=0
TMP_FILE=$(/bin/mktemp -q /tmp/$IPSET.XXXXXX) \
&& CLEAN_FILES+=" $TMP_FILE" \
&& chmod 600 "$TMP_FILE" \
&& ${IPSET_BIN} save > $TMP_FILE 2>/dev/null \
&& [[ -s $TMP_FILE ]] \
|| ret=1
rm -f ${IPSET_DATA_SAVED_FLAG}
if [[ $ret -eq 0 ]]; then
# No need to do anything if the files are the same
if [[ ! -f $IPSET_DATA ]]; then
mv $TMP_FILE $IPSET_DATA && chmod 600 $IPSET_DATA || ret=1
else
diff -q $TMP_FILE $IPSET_DATA >/dev/null
if [[ $? -ne 0 ]]; then
if [[ -f $IPSET_DATA ]]; then
cp -f --preserve=timestamps $IPSET_DATA $IPSET_DATA.save \
&& chmod 600 $IPSET_DATA.save \
|| ret=1
# Save each set in a separate file
mkdir -p ${IPSET_DATA_DIR}
chmod 0700 ${IPSET_DATA_DIR}
IFS="
"
for set in $(${IPSET_BIN} list -n -t); do
# Empty name allowed, use ".set" as suffix. 'ipset save' doesn't
# quote set names with spaces: if we have a space in the name,
# work around this by quoting it ourselves in the output.
# shellcheck disable=SC2003 # No POSIX equivalent to expr index
if expr index "${set}" " " >/dev/null; then
:> "${IPSET_DATA_DIR}/${set}.set"
for line in $(${IPSET_BIN} save "${set}"); do
create=0
echo "${line}" | grep -q "^create " && create=1
if [ $create -eq 1 ]; then
line=${line#create *}
else
line=${line#add *}
fi
line=${line#${set} *}
set="$(echo "${set}" | sed 's/"/\\"/g')"
if [ $create -eq 1 ]; then
echo "create \"${set}\" ${line}" >> "${IPSET_DATA_DIR}/${set}.set"
else
echo "add \"${set}\" ${line}" >> "${IPSET_DATA_DIR}/${set}.set"
fi
done
else
${IPSET_BIN} save "${set}" > "${IPSET_DATA_DIR}/${set}.set" || fail=1
fi
if [[ $ret -eq 0 ]]; then
cp -f --preserve=timestamps $TMP_FILE $IPSET_DATA \
&& chmod 600 $IPSET_DATA \
|| ret=1
fi
fi
fi
fi
[ -f "${IPSET_DATA_DIR}/${set}.set" ] && chmod 600 "${IPSET_DATA_DIR}/${set}.set"
[ $fail -eq 1 ] && err "Cannot save set ${set}" && unset IFS && return 1
done
touch ${IPSET_DATA_SAVED_FLAG} || { unset IFS; return 1; }
unset IFS
rm -f $TMP_FILE
return $ret
# Done: remove backups
rm -rf ${IPSET_DATA_DIR_BACKUP}
rm -rf ${IPSET_DATA_COMPAT_BACKUP}
return 0
}
# Generate a grep regexp matching abbreviated command forms. E.g., for create:
# \(c\|cr\|cre\|crea\|creat\|create\)
cmd_short_expr() {
out=
cmd_len=1
while [ "${cmd_len}" -le "${#1}" ]; do
[ -z "${out}" ] && out='\(' || out="${out}"'\|'
# shellcheck disable=SC2003 # No POSIX equivalent to expr substr
out="${out}$(expr substr "${1}" 1 "${cmd_len}")"
cmd_len=$((cmd_len + 1))
done
echo "${out}"'\)'
}
ipset_restore() {
file="${1}"
retfile="$(mktemp -q /tmp/ipset.XXXXXX)"
CLEAN_FILES="${CLEAN_FILES} ${retfile}"
# If restore fails due to invalid lines, remove them and retry
while ! restore_err="$( (${IPSET_BIN} -f "${file}" -! restore 2>&1; echo $? >"${retfile}") | head -n1; exit "$(cat "${retfile}")" )"; do
warn "${restore_err}"
case ${restore_err#*: } in
"No command specified"*)
line="$(grep -m1 -n "^${restore_err##* }" "${file}")"
line="${line%:*}"
;;
"Missing second mandatory argument to command "*)
cmd="${restore_err##* }"
cmd_expr="$(cmd_short_expr "${cmd}")"
line="$(grep -n '^'"${cmd_expr}" "${file}" | grep -m1 -v '^[0-9]\+\:'"${cmd_expr}"'[[:blank:]]\+[^[:blank:]]\+[[:blank:]]\+[^[:blank:]]\+')"
line="${line%:*}"
;;
"Missing mandatory argument to command "*)
cmd="${restore_err##* }"
cmd_expr="$(cmd_short_expr "${cmd}")"
line="$(grep -n '^'"${cmd_expr}" "${file}" | grep -m1 -v '^[0-9]\+\:'"${cmd_expr}"'[[:blank:]]\+[^[:blank:]]\+')"
line="${line%:*}"
;;
"Command "*"is invalid in restore mode"*)
restore_err_cmd="${restore_err#*: }"
restore_err_cmd="${restore_err_cmd#*\`}"
restore_err_cmd="${restore_err_cmd%%\'*}"
cmd="${restore_err_cmd##* }"
cmd_expr="$(cmd_short_expr "${cmd}")"
line="$(grep -m1 -ne '^'"${cmd_expr}"'[[:blank:]]\+' -e '^'"${restore_err_cmd}"'$' "${file}")"
line="${line%:*}"
;;
"Error in line "*)
line="${restore_err%: *}"
line="${line##* }"
;;
*)
rm "${retfile}"
CLEAN_FILES="${CLEAN_FILES%* ${retfile}}"
return 1
;;
esac
[ -z "${line}" ] && return 1
warn "Skipped invalid entry: $(sed "${line}q;d" "${file}")"
sed -i -e "${line}d" "${file}"
[ -s "${file}" ] || return 1
done
rm "${retfile}"
CLEAN_FILES="${CLEAN_FILES%* ${retfile}}"
}
load() {
if [ -f ${IPSET_DATA_SAVED_FLAG} ]; then
# If we have a cleanly saved directory with all sets, we can
# delete any left-overs and use it
rm -rf ${IPSET_DATA_DIR_BACKUP}
rm -f ${IPSET_DATA_COMPAT_BACKUP}
else
# If sets weren't cleanly saved, restore from backups
[ -d ${IPSET_DATA_DIR_BACKUP} ] && rm -rf ${IPSET_DATA_DIR} && mv -Tf ${IPSET_DATA_DIR_BACKUP} ${IPSET_DATA_DIR}
[ -f ${IPSET_DATA_COMPAT_BACKUP} ] && rm -f ${IPSET_DATA_COMPAT} && mv -Tf ${IPSET_DATA_COMPAT_BACKUP} ${IPSET_DATA_COMPAT}
fi
if [ ! -d ${IPSET_DATA_DIR} ] && [ ! -f ${IPSET_DATA_COMPAT} ]; then
info "No existing configuration available, none loaded"
touch ${IPSET_RUN}
return
fi
# Merge all sets into temporary file
merged="$(mktemp -q /tmp/ipset.XXXXXX)"
CLEAN_FILES="${CLEAN_FILES} ${merged}"
chmod 600 "${merged}"
set +f
if [ -d ${IPSET_DATA_DIR} ]; then
# Copy create commands from each saved set first, then the rest:
# list:set entries depend on other sets, so make sure they all
# get created first
for f in "${IPSET_DATA_DIR}"/*; do
[ "${f}" = "${IPSET_DATA_DIR}/*" ] && break
[ -f "${f}" ] || continue
grep '^c' "${f}" >> "${merged}"
done
for f in "${IPSET_DATA_DIR}"/*; do
[ "${f}" = "${IPSET_DATA_DIR}/*" ] && break
[ -f "${f}" ] || continue
grep -v '^c' "${f}" >> "${merged}"
done
fi
set -f
[ -f ${IPSET_DATA_COMPAT} ] && cat ${IPSET_DATA_COMPAT} >> "${merged}"
# Drop sets that aren't in saved data, mark conflicts with existing sets
conflicts=""
IFS="
"
for set in $(${IPSET_BIN} list -n -t); do
grep -q "^create ${set} " "${merged}" && conflicts="${conflicts}|${set}" && continue
# We can't destroy the set if it's in use, flush it instead
if ! ${IPSET_BIN} destroy "${set}" 2>/dev/null; then
${IPSET_BIN} flush "${set}"
fi
done
unset IFS
conflicts="${conflicts#|*}"
# Common case: if we have no conflicts, just restore in one shot
if [ -z "${conflicts}" ]; then
if ! ipset_restore "${merged}"; then
err "Failed to restore configured sets"
exit 1
fi
rm "${merged}"
CLEAN_FILES="${CLEAN_FILES%* ${merged}}"
touch ${IPSET_RUN}
return
fi
# Find a salt for md5sum that makes names of saved sets unique
salt=0
while true; do
unique=1
IFS="
"
for set in $(${IPSET_BIN} list -n -t); do
if grep -q "^create $(echo "${salt}${set}" | md5sum | head -c31) " "${merged}"; then
unique=0
break
fi
done
unset IFS
[ ${unique} -eq 1 ] && break
salt=$((salt + 1))
done
# Add sets, mangling names for conflicting sets
mangled="$(mktemp -q /tmp/ipset.XXXXXX)"
CLEAN_FILES="${CLEAN_FILES} ${mangled}"
chmod 600 "${mangled}"
cat "${merged}" > "${mangled}"
IFS='|'
for set in ${conflicts}; do
new_name=$(echo "${salt}${set}" | md5sum | head -c31)
echo "s/^(add|create) $set /\1 $new_name /"
done | sed -i -r -f - "${mangled}"
unset IFS
if ! ipset_restore "${mangled}"; then
err "Failed to restore configured sets"
exit 1
fi
rm "${mangled}"
CLEAN_FILES="${CLEAN_FILES%* ${mangled}}"
# Swap and delete old sets
IFS='|'
for set in ${conflicts}; do
mangled="$(echo "${salt}${set}" | md5sum | head -c31)"
if ! ${IPSET_BIN} swap "${set}" "${mangled}" 2>/dev/null; then
# This fails if set types are different: try to destroy
# existing set
if ! ${IPSET_BIN} destroy "${set}" 2>/dev/null; then
# Conflicting set is in use, we can only warn
# and flush the existing set
err "Cannot load set \"${set}\", set with same name and conflicting type in use"
${IPSET_BIN} flush "${set}"
${IPSET_BIN} destroy "${mangled}"
else
${IPSET_BIN} rename "${mangled}" "${set}"
fi
else
${IPSET_BIN} destroy "${mangled}"
fi
done
unset IFS
rm "${merged}"
CLEAN_FILES="${CLEAN_FILES%* ${merged}}"
touch ${IPSET_RUN}
}
cleanup() {
${IPSET_BIN} flush || err "Failed to flush sets"
# Try to destroy all sets at once. This will fail if some are in use,
# destroy all the other ones in that case
${IPSET_BIN} destroy 2>/dev/null && return
IFS="
"
for set in $(${IPSET_BIN} list -n -t); do
if ! ${IPSET_BIN} destroy "${set}"; then
err "Failed to destroy set ${set}"
fi
done
unset IFS
}
stop() {
[ -f ${IPSET_RUN} ] || { info "Not running"; return 0; }
[ "${IPSET_SAVE_ON_STOP}" = "yes" ] && { save || err "Failed to save sets"; }
# Nothing to stop if the ip_set module is not loaded
lsmod | grep -q "^ip_set " || { info "Not running"; rm ${IPSET_RUN}; return 0; }
# If the xt_set module is in use, then iptables is using ipset, so
# refuse to stop the service
if mod="$(lsmod | grep ^xt_set)"; then
if [ "$(echo "${mod}" | tr -s ' ' | cut -d' ' -f3)" != "0" ]; then
err "Current iptables configuration requires ipset" && return 1
fi
fi
cleanup
rm ${IPSET_RUN}
return 0
}
lock
case "$1" in
start)
start
RETVAL=$?
start)
load
;;
stop)
check_can_unload || exit 1
[[ $IPSET_SAVE_ON_STOP = yes ]] && save
stop)
stop
RETVAL=$?
[[ $RETVAL -eq 6 ]] && echo "${IPSET}: not running" && exit 0
;;
reload)
[[ $IPSET_SAVE_ON_RESTART = yes ]] && save
stop
RETVAL=$?
[[ $RETVAL -eq 6 ]] && echo "${IPSET}: not running" && exit 0
start
RETVAL=$?
reload)
cleanup
load
;;
*)
echo "Usage: $IPSET {start|stop|reload}" >&2
save)
save
;;
*)
info "Usage: $0 {start|stop|reload|save}"
exit 1
esac
exit $RETVAL
exit $?

View file

@ -1 +1 @@
fd8ea35997115c5c630eee22f0beecec ipset-6.29.tar.bz2
SHA512 (ipset-7.24.tar.bz2) = 18ccb49bd38083f0556b11e1d17f43791c52a2b094c9a500b6f770796b17e8e70c3860a628eac2252eb672b1fc9de734d3a0e0823d61dd9be7b4188adc6dd214

View file

@ -0,0 +1,36 @@
# SPDX-License-Identifier: LGPL-2.1+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/ipset
# Description: Test if ipset working ok
# Author: Susant Sahani<susant@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/ipset
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Susant Sahani<susant@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test ipset sanity" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: ipset " >> $(METADATA)
@echo "Requires: ipset iperf3 python3 systemd python3-pyroute2 iptables" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
@echo "Releases: -Fedora 29" >> $(METADATA)
rhts-lint $(METADATA)

View file

@ -0,0 +1,10 @@
[Unit]
Description=iperf3d tests for ipset
After=multi-user.target network.target
[Service]
Type=simple
ExecStart=/usr/bin/iperf3 -s -d --bind 192.168.225.32 --port 55555 -V
[Install]
WantedBy=multi-user.target

228
tests/sanity-tests/ipset-tests.py Executable file
View file

@ -0,0 +1,228 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# Description: Tests for ipset
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
# ~~~
import errno
import os
import sys
import time
import unittest
import subprocess
import signal
import shutil
import socket
from pyroute2 import IPRoute
def setUpModule():
if shutil.which('ipset') is None:
raise OSError(errno.ENOENT, 'ipset not found')
if shutil.which('iperf3') is None:
raise OSError(errno.ENOENT, 'iperf3 not found')
def tearDownModule():
pass
class GenericUtilities():
def SetupVethInterface(self):
ip = IPRoute()
ip.link('add', ifname='veth-test', peer='veth-peer', kind='veth')
idx_veth_test = ip.link_lookup(ifname='veth-test')[0]
idx_veth_peer = ip.link_lookup(ifname='veth-peer')[0]
ip.link('set', index=idx_veth_test, address='02:01:02:03:04:08')
ip.link('set', index=idx_veth_peer, address='02:01:02:03:04:09')
ip.addr('add', index=idx_veth_test, address='192.168.225.32', mask=24)
ip.addr('add', index=idx_veth_peer, address='192.168.225.33', mask=24)
ip.link('set', index=idx_veth_test, state='up')
ip.link('set', index=idx_veth_peer, state='up')
ip.close()
def TearDownVethInterface(self):
ip = IPRoute()
ip.link('del', index=ip.link_lookup(ifname='veth-test')[0])
ip.close()
def AddAddress(self, interface, address):
ip = IPRoute()
idx_veth_peer = ip.link_lookup(ifname=interface)[0]
ip.close()
def IPSetAdd(self, hashset, address):
subprocess.check_output(['ipset', 'add', hashset, address])
def IPSetRemove(self, hashset, address):
subprocess.check_output(['ipset', 'del', hashset, address])
def IPSetCreateHashSet(self, hashset, hashtype):
subprocess.check_output(['ipset', 'create', hashset, hashtype])
def IPSetDestroyHashSet(self, hashset):
subprocess.check_output(['ipset', 'destroy', hashset])
class IpsetTests(unittest.TestCase, GenericUtilities):
def setUp(self):
self.SetupVethInterface()
def tearDown(self):
self.TearDownVethInterface()
def test_ipset_bitmap_ip_netfilter(self):
self.IPSetCreateHashSet('testnetiperf', 'hash:ip')
self.IPSetAdd('testnetiperf', '192.168.225.32')
self.IPSetAdd('testnetiperf', '192.168.225.33')
subprocess.check_output(['ipset', 'test','testnetiperf','192.168.225.32'])
subprocess.check_output(['ipset', 'test','testnetiperf','192.168.225.33'])
subprocess.check_output(['systemctl', 'start', 'iperf3d.service'])
time.sleep(5)
r = subprocess.call("iperf3" + " -c 192.168.225.32 -p 55555 --connect-timeout 5", shell=True)
self.assertEqual(r, 0)
r = subprocess.call("iptables" + " -I INPUT -m set --match-set testnetiperf src -j DROP", shell=True)
self.assertEqual(r, 0)
r = subprocess.call("iperf3" + " -c 192.168.225.32 -p 55555 --connect-timeout 5", shell=True)
self.assertNotEqual(r, 0)
subprocess.check_output(['systemctl', 'stop', 'iperf3d.service'])
subprocess.call("iptables" + " --delete INPUT -m set --match-set testnetiperf src -j DROP" , shell=True)
self.IPSetDestroyHashSet('testnetiperf')
def test_ipset_add_bitmap_ip(self):
self.IPSetCreateHashSet('testnet', 'hash:ip')
self.IPSetAdd('testnet', '192.168.11.12')
self.IPSetAdd('testnet', '192.168.11.13')
self.IPSetAdd('testnet', '192.168.11.14')
self.IPSetAdd('testnet', '192.168.11.15')
subprocess.check_output(['ipset', 'test','testnet','192.168.11.12'])
subprocess.check_output(['ipset', 'test','testnet','192.168.11.13'])
subprocess.check_output(['ipset', 'test','testnet','192.168.11.14'])
subprocess.check_output(['ipset', 'test','testnet','192.168.11.15'])
self.IPSetDestroyHashSet('testnet')
def test_ipset_delete_bitmap_ip(self):
self.IPSetCreateHashSet('testnet', 'hash:ip')
self.IPSetAdd('testnet', '192.168.11.12')
self.IPSetAdd('testnet', '192.168.11.13')
subprocess.check_output(['ipset', 'test','testnet','192.168.11.12'])
subprocess.check_output(['ipset', 'test','testnet','192.168.11.13'])
self.IPSetRemove('testnet', '192.168.11.12')
r = subprocess.call("ipset" + " test testnet 192.168.11.12", shell=True)
self.assertEqual(r, 1)
self.IPSetDestroyHashSet('testnet')
def test_ipset_hash_bitmap_mac(self):
self.IPSetCreateHashSet('testmac', 'hash:mac')
self.IPSetAdd('testmac', '02:01:02:03:04:09')
subprocess.check_output(['ipset', 'test','testmac','02:01:02:03:04:09'])
self.IPSetRemove('testmac', '02:01:02:03:04:09')
r = subprocess.call("ipset" + " test testmac 02:01:02:03:04:09", shell=True)
self.assertEqual(r, 1)
self.IPSetDestroyHashSet('testmac')
def test_ipset_hash_bitmap_ipport(self):
self.IPSetCreateHashSet('testipport', 'hash:ip,mac')
self.IPSetAdd('testipport', '1.1.1.1,02:01:02:03:04:09')
subprocess.check_output(['ipset', 'test','testipport','1.1.1.1,02:01:02:03:04:09'])
self.IPSetRemove('testipport', '1.1.1.1,02:01:02:03:04:09')
r = subprocess.call("ipset" + " test testipport 1.1.1.1,02:01:02:03:04:09", shell=True)
self.assertEqual(r, 1)
self.IPSetDestroyHashSet('testipport')
def test_ipset_hash_bitmap_ipport(self):
self.IPSetCreateHashSet('testipport', 'hash:ip,port')
self.IPSetAdd('testipport', '192.168.1.1,udp:53')
self.IPSetAdd('testipport', '192.168.1.1,5555')
subprocess.check_output(['ipset', 'test','testipport','192.168.1.1,udp:53'])
subprocess.check_output(['ipset', 'test','testipport','192.168.1.1,5555'])
self.IPSetRemove('testipport', '192.168.1.1,5555')
r = subprocess.call("ipset" + " test testipport 192.168.1.1,5555", shell=True)
self.assertEqual(r, 1)
self.IPSetDestroyHashSet('testipport')
def test_ipset_hash_bitmap_ipportip(self):
self.IPSetCreateHashSet('testipportip', 'hash:ip,port,ip')
self.IPSetAdd('testipportip', '192.168.1.1,80,10.0.0.1')
self.IPSetAdd('testipportip', '192.168.1.2,80,10.0.0.2')
subprocess.check_output(['ipset', 'test','testipportip','192.168.1.1,80,10.0.0.1'])
subprocess.check_output(['ipset', 'test','testipportip','192.168.1.1,80,10.0.0.1'])
self.IPSetRemove('testipportip', '192.168.1.1,80,10.0.0.1')
r = subprocess.call("ipset" + " test testipportip 192.168.1.1,80,10.0.0.1", shell=True)
self.assertEqual(r, 1)
self.IPSetDestroyHashSet('testipportip')
def test_ipset_hash_bitmap_netiface(self):
self.IPSetCreateHashSet('testnetiface', 'hash:net,iface')
self.IPSetAdd('testnetiface', '192.168.0/24,veth-test')
self.IPSetAdd('testnetiface', '192.167.0/24,veth-peer')
subprocess.check_output(['ipset', 'test','testnetiface','192.168.0/24,veth-test'])
subprocess.check_output(['ipset', 'test','testnetiface','192.167.0/24,veth-peer'])
self.IPSetRemove('testnetiface', '192.168.0/24,veth-test')
r = subprocess.call("ipset" + " test testnetiface 192.168.0/24,veth-test", shell=True)
self.assertEqual(r, 1)
self.IPSetDestroyHashSet('testnetiface')
if __name__ == '__main__':
unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, verbosity=3))

50
tests/sanity-tests/runtest.sh Executable file
View file

@ -0,0 +1,50 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# runtest.sh of ipset
# Description: ipset tests.
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
# ~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="ipset"
SERVICE_UNITDIR="/var/run/systemd/system"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "systemctl stop firewalld" 0,5
rlRun "setenforce 0" 0,1
rlRun "[ -e /sys/class/net/veth-test ] && ip link del veth-test" 0,1
rlRun "cp iperf3d.service $SERVICE_UNITDIR"
rlRun "cp ipset-tests.py /usr/bin/"
rlRun "systemctl daemon-reload"
rlPhaseEnd
rlPhaseStartTest
rlLog "Starting ipset tests ..."
rlRun "/usr/bin/python3 /usr/bin/ipset-tests.py"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm /usr/bin/ipset-tests.py"
rlRun "[ -e /sys/class/net/veth-test ] && ip link del veth-test" 0,1
rlRun "rm $SERVICE_UNITDIR/iperf3d.service"
rlRun "systemctl daemon-reload"
rlRun "setenforce 1" 0,1
rlLog "ipset tests done"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
rlGetTestState

15
tests/tests.yml Normal file
View file

@ -0,0 +1,15 @@
- hosts: localhost
roles:
- role: standard-test-beakerlib
tags:
- classic
tests:
- sanity-tests
required_packages:
- ipset
- iptables
- python3
- systemd
- iproute
- iperf3
- python3-pyroute2