Bug 30084 - IP address enforcement is hopelessly broken
Summary: IP address enforcement is hopelessly broken
Status: CLOSED FIXED
Alias: None
Product: Sisyphus
Classification: Development
Component: alterator-net-functions (show other bugs)
Version: unstable
Hardware: all Linux
: P3 normal
Assignee: Mikhail Efremov
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-19 14:42 MSK by Matt Lewandowsky (lewellyn)
Modified: 2022-02-17 15:27 MSK (History)
10 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Lewandowsky (lewellyn) 2014-05-19 14:42:15 MSK
Right now, alterator-net-eth is enforcing that the final octet of the IP address is not 0 or 255. This assumption is only valid on a /24 network (netmask of 255.255.255.0).

In most home environments, this will be the case. Otherwise, it will be an incorrect assumption. For example, a public-facing server will almost never be on a /24 network. Likewise, on a corporate network, the address space may be subnetted in such a way that X.X.X.0 and X.X.X.255 are not the network/broadcast addresses but are just additional available addresses. In both of these examples, the address may be assigned as opposed to chosen and getting a replacement may not be trivial.

The proper solution would be to enforce the available addresses based upon the netmask. The easy solution would be to just remove that enforcement altogether, as it's only correct for one particular network mask. I would have provided a patch to do one or both, but I failed to determine exactly where this check is being done. I assumed it was in /usr/bin/alterator-net-functions or /bin/shell-ip-address, but it seems that neither is correct.

For now, the workaround I've found is to add the correct address/bits to /etc/net/ifaces/ethX/ipv4address as alterator does not re-validate the address once it's been stored.
Comment 1 Mikhail Efremov 2014-05-31 01:50:02 MSK
Alterator-net-eth uses valid_ipv4addr() from alterator-net-function. This function should be fixed as you described, of course. And apparently valid_ipv4() in libshell should be fixed too.
Thanks for your report!
Comment 2 Alexey Shabalin 2022-02-17 14:18:16 MSK
есть планы по исправлению?
Comment 3 Mikhail Efremov 2022-02-17 14:40:41 MSK
commit f59a68de59fbc2b5d00ca3e416bf85df657cae10
Author: Evgeny Sinelnikov <sin@altlinux.ru>
Date:   Wed Aug 23 13:27:31 2017 +0300

    valid_ipv4addr: Allow 0 in last byte
    
    IP 198.168.1.0 in subnet 198.168.0.0 is a valid IPv4 address.

Well, 255 should be allowed too.
Comment 4 Repository Robot 2022-02-17 15:27:09 MSK
alterator-net-functions-2.1.1-alt1 -> sisyphus:

 Thu Feb 17 2022 Mikhail Efremov <sem@altlinux> 2.1.1-alt1
 - tests: Add test for valid x.x.x.255 ipv4 address.
 - valid_ipv4addr: Allow 255 in a last byte (closes: #30084).