Revised documentation patch in ip.7 was accepted

This commit is contained in:
Seth Schoen
2023-04-14 12:44:07 -07:00
parent 94d97c4f6f
commit 3b43ff5aa4
6 changed files with 130 additions and 241 deletions
+4
View File
@@ -25,6 +25,10 @@ freebsd/subnet_addr.diff
occur after that date. (I'm not sure about FreeBSD 12 releases after
that date, such as FreeBSD 12.3.)
linux/0001-Add-special-and-reserved-addresses-section.patch
This documentation patch was accepted on April 14, 2023.
linux/0001-Allow-0.0.0.0-8-and-reduce-localnet-and-enable-225-2.patch
The 0/8 part of this patch was merged in 96125bf9985a7, approved
@@ -0,0 +1,126 @@
From 175e3e35426cf820bcb65a03d9d9c22c46e2fb89 Mon Sep 17 00:00:00 2001
From: Seth Schoen <schoen@loyalty.org>
Date: Fri, 14 Apr 2023 11:40:31 -0700
Subject: [PATCH v5] ip.7: Add "special and reserved addresses" section
Break out the discussion of special and reserved IPv4 addresses into
a subsection, formatted as a pair of definition lists, and briefly
describing three cases in which Linux no longer treats addresses
specially, where other systems do or did.
Also add a specific example to the NOTES paragraph that discourages
the use of IP broadcasting, so people can more easily understand
what they are supposed to do instead.
---
man7/ip.7 | 83 +++++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 75 insertions(+), 8 deletions(-)
diff --git a/man7/ip.7 b/man7/ip.7
index 6c50d0281..6f1ee4dbe 100644
--- a/man7/ip.7
+++ b/man7/ip.7
@@ -237,19 +237,82 @@ In particular, this means that you need to call
on the number that is assigned to a port.
All address/port manipulation
functions in the standard library work in network byte order.
-.PP
+.SS Special and reserved addresses
There are several special addresses:
-.B INADDR_LOOPBACK
-(127.0.0.1)
+.TP
+.BR INADDR_LOOPBACK " (127.0.0.1)"
always refers to the local host via the loopback device;
+.TP
+.BR INADDR_ANY " (0.0.0.0)"
+means any address for socket binding;
+.TP
+.BR INADDR_BROADCAST " (255.255.255.255)"
+has the same effect on
+.BR bind (2)
+as
.B INADDR_ANY
-(0.0.0.0)
-means any address for binding;
+for historical reasons.
+A packet addressed to
.B INADDR_BROADCAST
-(255.255.255.255)
-means any host and has the same effect on bind as
+through a socket which has
+.B SO_BROADCAST
+set will be broadcast to all hosts on the local network segment,
+as long as the link is broadcast-capable.
+
+.TP
+Highest-numbered address
+.TQ
+Lowest-numbered address
+On any locally-attached non-point-to-point IP subnet
+with a link type that supports broadcasts,
+the highest-numbered address
+(e.g., the .255 address on a subnet with netmask 255.255.255.0)
+is designated as a broadcast address.
+It cannot usefully be assigned to an individual interface,
+and can only be addressed with a socket on which the
+.B SO_BROADCAST
+option has been set.
+Internet standards have historically
+also reserved the lowest-numbered address
+(e.g., the .0 address on a subnet with netmask 255.255.255.0)
+for broadcast, though they call it "obsolete" for this purpose.
+(Some sources also refer to this as the "network address.")
+Since Linux 5.14,
+.\" commit 58fee5fc83658aaacf60246aeab738946a9ba516
+it is treated as an ordinary unicast address
+and can be assigned to an interface.
+
+.PP
+Internet standards have traditionally also reserved various addresses
+for particular uses, though Linux no longer treats
+some of these specially.
+
+.TP
+[0.0.0.1, 0.255.255.255]
+.TQ
+[240.0.0.0, 255.255.255.254]
+Addresses in these ranges (0/8 and 240/4) are reserved globally.
+Since Linux 5.3
+.\" commit 96125bf9985a75db00496dd2bc9249b777d2b19b
+and Linux 2.6.25,
+.\" commit 1e637c74b0f84eaca02b914c0b8c6f67276e9697
+respectively,
+the 0/8 and 240/4 addresses, other than
.B INADDR_ANY
-for historical reasons.
+and
+.BR INADDR_BROADCAST ,
+are treated as ordinary unicast addresses.
+Systems that follow the traditional behaviors may not
+interoperate with these historically reserved addresses.
+.TP
+[127.0.0.1, 127.255.255.254]
+Addresses in this range (127/8) are treated as loopback addresses
+akin to the standardized local loopback address
+.B INADDR_LOOPBACK
+(127.0.0.1);
+.TP
+[224.0.0.0, 239.255.255.255]
+Addresses in this range (224/4) are dedicated to multicast use.
.SS Socket options
IP supports some protocol-specific socket options that can be set with
.BR setsockopt (2)
@@ -1343,6 +1406,10 @@ with careless broadcasts.
For new application protocols
it is better to use a multicast group instead of broadcasting.
Broadcasting is discouraged.
+See RFC 6762 for an example of a protocol (mDNS)
+using the more modern multicast approach
+to communicating with an open-ended
+group of hosts on the local network.
.PP
Some other BSD sockets implementations provide
.B IP_RCVDSTADDR
--
2.25.1
-18
View File
@@ -51,24 +51,6 @@ iproute2/0001-Use-SCOPE_HOST-default-only-for-127-16-not-127-8.patch
This patch is meant to be used in conjunction with a Linux kernel
patch. It has been tested successfully.
linux/0001-ip.7-Add-special-and-reserved-addresses-section.patch
linux/0001-ip.7-Describe-lowest-host-behavior-change.patch
linux/0001-PATCH-v3-ip.7-Add-Special-and-reserved-addresses-sec.patch
The first two patches against the man-pages tree are new as of
2021-03-12 and have not been merged yet.
The former patch (documenting existing kernel behavior) was
submitted to linux-man on 2021-03-19, and a revised version based
on comments was resubmitted on 2021-03-29.
The third patch combines the former two, on the occasion of the
release of Linux 5.14, and is meant as an alternative to them.
It also cites specific commits in which special address behaviors
were merged in the Linux kernel. It is new as of 2021-08-30 and
has not been merged yet. It was submitted to linux-man on
2021-08-31.
linux/0001-Reduce-local-loopback-network-to-16-updated.patch
This patch has not been merged as of 2021-01-08. It is a more
@@ -1,109 +0,0 @@
From ba9a3172b7dc80dac4f5b9182fd9fb7521a00462 Mon Sep 17 00:00:00 2001
From: Seth Schoen <schoen@loyalty.org>
Date: Tue, 31 Aug 2021 11:29:57 -0700
Subject: [PATCH v3] ip.7: Add "Special and reserved addresses" section
Add a new section with a more detailed description of the IPv4 addresses
that have a special meaning in Internet standards, and how these affect
Linux.
The occasion for this update is the inclusion of our patch in Linux 5.14,
which changes Linux's subnet broadcast address behavior.
The divergences in Linux's behavior mentioned in this patch were
introduced at
unicast 240/4 (since 2.6.25):
commit 1e637c74b0f84eaca02b914c0b8c6f67276e9697
Author: Jan Engelhardt <jengelh@computergmbh.de>
Date: Mon Jan 21 03:18:08 2008 -0800
unicast 0/8 (since 5.3):
commit 96125bf9985a75db00496dd2bc9249b777d2b19b
Author: Dave Taht <dave.taht@gmail.com>
Date: Sat Jun 22 10:07:34 2019 -0700
unicast subnet lowest address (since 5.14):
commit 58fee5fc83658aaacf60246aeab738946a9ba516
Merge: 77091933e453 6101ca0384e3
Author: David S. Miller <davem@davemloft.net>
Date: Mon May 17 13:47:58 2021 -0700
Signed-off-by: Seth David Schoen <schoen@loyalty.org>
Suggested-by: John Gilmore <gnu@toad.com>
---
man7/ip.7 | 48 +++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 45 insertions(+), 3 deletions(-)
diff --git a/man7/ip.7 b/man7/ip.7
index 7eee2811e..0c228a9c2 100644
--- a/man7/ip.7
+++ b/man7/ip.7
@@ -232,6 +232,7 @@ In particular, this means that you need to call
on the number that is assigned to a port.
All address/port manipulation
functions in the standard library work in network byte order.
+.SS Special and reserved addresses
.PP
There are several special addresses:
.B INADDR_LOOPBACK
@@ -239,12 +240,53 @@ There are several special addresses:
always refers to the local host via the loopback device;
.B INADDR_ANY
(0.0.0.0)
-means any address for binding;
+means any address for socket binding;
.B INADDR_BROADCAST
(255.255.255.255)
-means any host and has the same effect on bind as
+has the same effect on socket binding as
.B INADDR_ANY
-for historical reasons.
+for historical reasons. A packet addressed to
+.B INADDR_BROADCAST
+through a socket which has
+.B SO_BROADCAST
+set will be broadcast to all hosts on the local network segment, as
+long as the link is broadcast-capable.
+.PP
+Internet standards have also traditionally reserved various
+addresses for particular uses. (Some reserved addresses are no longer
+treated specially by Linux kernels, as described below.) The addresses
+in the ranges 0.0.0.1 through 0.255.255.255 and 240.0.0.0 through
+255.255.255.254 (0/8 and 240/4, in CIDR notation) are reserved globally.
+All addresses from 127.0.0.1 through 127.255.255.254
+are treated as loopback addresses akin to the standardized
+local loopback address 127.0.0.1, while addresses in 224.0.0.0 through
+239.255.255.255 (224/4) are dedicated to multicast use.
+.PP
+On any locally-attached IP subnet with a link type that supports
+broadcasts, the highest-numbered address (e.g., the .255 address on a
+subnet with netmask 255.255.255.0) is designated as a broadcast address.
+This "broadcast address" cannot usefully be assigned to an interface, and
+can only be addressed
+with a socket on which the
+.B SO_BROADCAST
+option has been set.
+Internet standards have historically also reserved the lowest-numbered
+address (e.g., the .0 address on a subnet with netmask 255.255.255.0)
+for broadcast, though they call it "obsolete" for this purpose.
+.IP \(bu 2
+Since Linux 2.6.25, 240/4 addresses (except 255.255.255.255) are treated
+as ordinary unicast addresses, and can therefore be assigned to an interface.
+.IP \(bu
+Since Linux 5.3, this is also true for 0/8 addresses (except 0.0.0.0).
+.IP \(bu
+Since Linux 5.14, this is also true for the lowest address on a subnet
+(e.g., the .0 address in a /24 network).
+.PP
+Operating systems that follow the traditional behaviors may not
+interoperate with a system using these historically reserved addresses.
+However, distant hosts will interoperate with the lowest address on a
+subnet, as long as the local router and the host to which it is assigned
+both treat it as a unicast address.
.SS Socket options
IP supports some protocol-specific socket options that can be set with
.BR setsockopt (2)
--
2.25.1
@@ -1,65 +0,0 @@
From 44f703ca17e90d1f2a18f2b999ece38cbd13c0db Mon Sep 17 00:00:00 2001
From: Seth David Schoen <schoen@loyalty.org>
Date: Fri, 12 Mar 2021 16:28:26 -0800
Subject: [PATCH 1/1] ip.7: Add "special and reserved addresses" section
Add a more detailed description of the IP addresses that have
a special meaning in Internet standards, and how these affect
Linux.
Signed-off-by: Seth David Schoen <schoen@loyalty.org>
Suggested-by: John Gilmore <gnu@toad.com>
---
man7/ip.7 | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/man7/ip.7 b/man7/ip.7
index d9299eb9e..478cda269 100644
--- a/man7/ip.7
+++ b/man7/ip.7
@@ -39,7 +39,7 @@
.\" commit 76e21053b5bf33a07c76f99d27a74238310e3c71
.\" Author: Erich E. Hoover <ehoover@mines.edu>
.\"
-.TH IP 7 2020-11-01 "Linux" "Linux Programmer's Manual"
+.TH IP 7 2021-03-10 "Linux" "Linux Programmer's Manual"
.SH NAME
ip \- Linux IPv4 protocol implementation
.SH SYNOPSIS
@@ -232,6 +232,7 @@ In particular, this means that you need to call
on the number that is assigned to a port.
All address/port manipulation
functions in the standard library work in network byte order.
+.SS Special and reserved addresses
.PP
There are several special addresses:
.B INADDR_LOOPBACK
@@ -245,6 +246,25 @@ means any address for binding;
means any host and has the same effect on bind as
.B INADDR_ANY
for historical reasons.
+.PP
+Internet standards have also traditionally reserved various
+addresses for particular uses. The addresses
+in the ranges 0.0.0.0 through 0.255.255.255 and 240.0.0.0 through
+255.255.255.254 (0/8 and 240/4 in CIDR notation) are reserved globally
+(but Linux permits addresses within these ranges, other than 0.0.0.0,
+to be assigned to an interface and used like other unicast addresses).
+All addresses in 127.0.0.0 through 127.255.255.255
+("127/8") are treated as loopback addresses akin to the standardized
+local loopback address 127.0.0.1, while addresses in 224.0.0.0 through
+239.255.255.255 ("224/4") are dedicated to multicast use.
+.PP
+On any locally-attached IP subnet, the lowest-numbered address and
+highest-numbered address (e.g., the .0 and .255 addresses on a subnet
+with netmask 255.255.255.0) are both designated as broadcast addresses.
+These cannot usefully be assigned to an interface, and can only be
+addressed with a socket on which the
+.B SO_BROADCAST
+option has been explicitly enabled.
.SS Socket options
IP supports some protocol-specific socket options that can be set with
.BR setsockopt (2)
--
2.25.1
@@ -1,49 +0,0 @@
From 30e80fe3c7d76e9bf14a61e76bb9cbf77946bf20 Mon Sep 17 00:00:00 2001
From: Seth David Schoen <schoen@loyalty.org>
Date: Fri, 12 Mar 2021 16:33:11 -0800
Subject: [PATCH] ip.7: Describe lowest-host behavior change
Update the reserved addresses documentation to describe the
behavior change that treats only the highest address, not the
lowest address, in an IPv4 subnet as a broadcast address.
Signed-off-by: Seth David Schoen <schoen@loyalty.org>
Suggested-by: John Gilmore <gnu@toad.com>
---
man7/ip.7 | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/man7/ip.7 b/man7/ip.7
index 478cda269..d51c09196 100644
--- a/man7/ip.7
+++ b/man7/ip.7
@@ -258,13 +258,21 @@ All addresses in 127.0.0.0 through 127.255.255.255
local loopback address 127.0.0.1, while addresses in 224.0.0.0 through
239.255.255.255 ("224/4") are dedicated to multicast use.
.PP
-On any locally-attached IP subnet, the lowest-numbered address and
-highest-numbered address (e.g., the .0 and .255 addresses on a subnet
-with netmask 255.255.255.0) are both designated as broadcast addresses.
-These cannot usefully be assigned to an interface, and can only be
-addressed with a socket on which the
+On any locally-attached IP subnet, the highest-numbered address
+(e.g., the .255 address on a subnet with netmask 255.255.255.0) is
+designated as a broadcast addresses. It cannot usefully be assigned
+to an interface, and can only be addressed with a socket on which the
.B SO_BROADCAST
option has been explicitly enabled.
+.PP
+Although Internet standards historically reserved the lowest-numbered
+address for broadcast as well, this behavior provides no benefit today
+and, since release x.y.z, Linux now allows this address (e.g., the .0 address
+in a /24 network) to be assigned to an interface and used for unicast
+purposes. This will not interoperate with other systems on the local
+network segment that follow the traditional behavior, but will work with
+traditional systems elsewhere on the network (not on the same segment), if
+the local router is willing to route this address.
.SS Socket options
IP supports some protocol-specific socket options that can be set with
.BR setsockopt (2)
--
2.25.1