]> git.ipfire.org Git - thirdparty/ipset.git/commit
tests: cidr.sh: Fix for quirks in RHEL's ipcalc
authorPhil Sutter <phil@nwl.cc>
Thu, 12 Dec 2024 12:47:32 +0000 (13:47 +0100)
committerJozsef Kadlecsik <kadlec@netfilter.org>
Sun, 15 Dec 2024 16:08:39 +0000 (17:08 +0100)
commit37f77108fd6cd314690e2c59d7f04825441d9c20
tree9196b1cb2edfd59ad2991d3222a5282aa9365438
parent61d78c20377e602de2759b58c3abb0d14ca50f7b
tests: cidr.sh: Fix for quirks in RHEL's ipcalc

RHEL ships a special ipset[1] tool with different output in corner-cases
than the common one[2]:

* Reduced output with /32 netmasks:

| # ipcalc 255.255.255.254/32
| Address: 255.255.255.254
| Address space: Reserved

To cover for this, make net_last_addr() fall back to the 'Address:'
line. Simply adding this keyword is fine as in normal output it appears
first and thus the other recognized keywords' values take precedence.

* No "Address:" line with all-zero addresses:

| # ipcalc 0.0.0.0/1
| Network: 0.0.0.0/1
| Netmask: 128.0.0.0 = 1
| Broadcast: 127.255.255.255
|
| Address space: This host on this network
| HostMin: 0.0.0.1
| HostMax: 127.255.255.254
| Hosts/Net: 2147483646

Have net_first_addr() fall back to the 'HostMin:' line in this case.

[1] https://gitlab.com/ipcalc/ipcalc
[2] http://jodies.de/ipcalc

Fixes: e24e7656b3dd9 ("tests: cidr.sh: Add ipcalc fallback")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org>
tests/cidr.sh