platform/linux: add support for /31 prefixes on IPv4 point-to-point links

Previously NetworkManager would wrongly add a broadcast address for the
network prefix that would collide with the IP address of the host on
the other end of the point-to-point link thus exhausting the IP address
space of the /31 network and preventing communication between the two
nodes.

Configuring a /31 address before this commit:
	IP addr -> 10.0.0.0/31, broadcast addr -> 10.0.0.1

If 10.0.0.1 is configured as a broadcast address the communication
with host 10.0.0.1 will not be able to take place.

Configuring a /31 address after this commit:
	IP addr -> 10.0.0.0/31, no broadcast address

Thus 10.0.0.0/31 and 10.0.0.1/31 are able to correctly communicate.

See RFC-3021. https://tools.ietf.org/html/rfc3021

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/295

https://bugzilla.redhat.com/show_bug.cgi?id=1764986
This commit is contained in:
Antonio Cardace
2019-12-24 15:17:16 +01:00
parent d964decbbd
commit fa144b5ae9

View File

@@ -3937,6 +3937,7 @@ _nl_msg_new_address (int nlmsg_type,
if ( family == AF_INET
&& nlmsg_type != RTM_DELADDR
&& plen < 31 /* RFC 3021 */
&& address
&& *((in_addr_t *) address) != 0) {
in_addr_t broadcast;