]> git.ipfire.org Git - thirdparty/man-pages.git/blobdiff - man7/ip.7
err.3: EXAMPLES: use EXIT_FAILURE rather than 1 as exit status
[thirdparty/man-pages.git] / man7 / ip.7
index 4561b2fb6539f4c5461d04fc34da00def6f9cdc3..06f47715e6d8939336bc58976d48affff795c580 100644 (file)
--- a/man7/ip.7
+++ b/man7/ip.7
@@ -1,15 +1,51 @@
 '\" t
-.\" Don't change the line above. it tells man that tbl is needed.
 .\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
+.\"
+.\" %%%LICENSE_START(VERBATIM_ONE_PARA)
 .\" Permission is granted to distribute possibly modified copies
 .\" of this page provided the header is included verbatim,
 .\" and in case of nontrivial modification author and date
 .\" of the modification is added to the header.
+.\" %%%LICENSE_END
+.\"
 .\" $Id: ip.7,v 1.19 2000/12/20 18:10:31 ak Exp $
 .\"
-.\" FIXME: Document IP_MINTTL, added in Linux 2.6.34
+.\" FIXME The following socket options are yet to be documented
+.\"
+.\"    IP_XFRM_POLICY (2.5.48)
+.\"        Needs CAP_NET_ADMIN
+.\"
+.\"    IP_IPSEC_POLICY (2.5.47)
+.\"        Needs CAP_NET_ADMIN
+.\"
+.\"    IP_PASSSEC (2.6.17)
+.\"        Boolean
+.\"        commit 2c7946a7bf45ae86736ab3b43d0085e43947945c
+.\"        Author: Catherine Zhang <cxzhang@watson.ibm.com>
+.\"
+.\"    IP_MINTTL (2.6.34)
+.\"        commit d218d11133d888f9745802146a50255a4781d37a
+.\"        Author: Stephen Hemminger <shemminger@vyatta.com>
+.\"
+.\"    MCAST_JOIN_GROUP (2.4.22 / 2.6)
+.\"
+.\"    MCAST_BLOCK_SOURCE (2.4.22 / 2.6)
+.\"
+.\"    MCAST_UNBLOCK_SOURCE (2.4.22 / 2.6)
+.\"
+.\"    MCAST_LEAVE_GROUP (2.4.22 / 2.6)
 .\"
-.TH IP  7 2010-10-24 "Linux" "Linux Programmer's Manual"
+.\"    MCAST_JOIN_SOURCE_GROUP (2.4.22 / 2.6)
+.\"
+.\"    MCAST_LEAVE_SOURCE_GROUP (2.4.22 / 2.6)
+.\"
+.\"    MCAST_MSFILTER (2.4.22 / 2.6)
+.\"
+.\"    IP_UNICAST_IF (3.4)
+.\"        commit 76e21053b5bf33a07c76f99d27a74238310e3c71
+.\"        Author: Erich E. Hoover <ehoover@mines.edu>
+.\"
+.TH IP  7 2019-03-06 "Linux" "Linux Programmer's Manual"
 .SH NAME
 ip \- Linux IPv4 protocol implementation
 .SH SYNOPSIS
@@ -20,7 +56,7 @@ ip \- Linux IPv4 protocol implementation
 .B #include <netinet/in.h>
 .br
 .B #include <netinet/ip.h>        \fR/* superset of previous */
-.sp
+.PP
 .IB tcp_socket " = socket(AF_INET, SOCK_STREAM, 0);"
 .br
 .IB udp_socket " = socket(AF_INET, SOCK_DGRAM, 0);"
@@ -32,49 +68,64 @@ described in RFC\ 791 and RFC\ 1122.
 .B ip
 contains a level 2 multicasting implementation conforming to RFC\ 1112.
 It also contains an IP router including a packet filter.
-.\" FIXME has someone verified that 2.1 is really 1812 compliant?
 .PP
 The programming interface is BSD-sockets compatible.
 For more information on sockets, see
 .BR socket (7).
 .PP
-An IP socket is created by calling the
-.BR socket (2)
-function as
-.BI "socket(AF_INET, " socket_type ", " protocol ) \fR.
-Valid socket types are
+An IP socket is created using
+.BR socket (2):
+.PP
+    socket(AF_INET, socket_type, protocol);
+.PP
+Valid socket types include
 .B SOCK_STREAM
-to open a
-.BR tcp (7)
-socket,
+to open a stream socket,
 .B SOCK_DGRAM
-to open a
-.BR udp (7)
-socket, or
+to open a datagram socket, and
 .B SOCK_RAW
 to open a
 .BR raw (7)
 socket to access the IP protocol directly.
+.PP
 .I protocol
 is the IP protocol in the IP header to be received or sent.
-The only valid values for
+Valid values for
 .I protocol
-are 0 and
+include:
+.IP \(bu 2
+0 and
 .B IPPROTO_TCP
-for TCP sockets, and 0 and
+for
+.BR tcp (7)
+stream sockets;
+.IP \(bu
+0 and
 .B IPPROTO_UDP
-for UDP sockets.
+for
+.BR udp (7)
+datagram sockets;
+.IP \(bu
+.B IPPROTO_SCTP
+for
+.BR sctp (7)
+stream sockets; and
+.IP \(bu
+.B IPPROTO_UDPLITE
+for
+.BR udplite (7)
+datagram sockets.
+.PP
 For
 .B SOCK_RAW
 you may specify a valid IANA IP protocol defined in
 RFC\ 1700 assigned numbers.
 .PP
-.\" FIXME ip current does an autobind in listen, but I'm not sure
-.\" if that should be documented.
 When a process wants to receive new incoming packets or connections, it
 should bind a socket to a local interface address using
 .BR bind (2).
-Only one IP socket may be bound to any given local (address, port) pair.
+In this case, only one IP socket may be bound to any given local
+(address, port) pair.
 When
 .B INADDR_ANY
 is specified in the bind call, the socket will be bound to
@@ -82,18 +133,22 @@ is specified in the bind call, the socket will be bound to
 local interfaces.
 When
 .BR listen (2)
-or
+is called on an unbound socket, the socket is automatically bound
+to a random free port with the local address set to
+.BR INADDR_ANY .
+When
 .BR connect (2)
-are called on an unbound socket, it is automatically bound to a
-random free port with the local address set to
+is called on an unbound socket, the socket is automatically bound
+to a random free port or to a usable shared port with the local address
+set to
 .BR INADDR_ANY .
-
+.PP
 A TCP local socket address that has been bound is unavailable for
 some time after closing, unless the
 .B SO_REUSEADDR
 flag has been set.
 Care should be taken when using this flag as it makes TCP less reliable.
-.SS Address Format
+.SS Address format
 An IP socket address is defined as a combination of an IP interface
 address and a 16-bit port number.
 The basic IP protocol does not supply port numbers, they
@@ -106,7 +161,7 @@ On raw sockets
 is set to the IP protocol.
 .PP
 .in +4n
-.nf
+.EX
 struct sockaddr_in {
     sa_family_t    sin_family; /* address family: AF_INET */
     in_port_t      sin_port;   /* port in network byte order */
@@ -117,7 +172,7 @@ struct sockaddr_in {
 struct in_addr {
     uint32_t       s_addr;     /* address in network byte order */
 };
-.fi
+.EE
 .in
 .PP
 .I sin_family
@@ -132,13 +187,14 @@ The port numbers below 1024 are called
 .IR "privileged ports"
 (or sometimes:
 .IR "reserved ports" ).
-Only privileged processes (i.e., those having the
+Only a privileged process
+(on Linux: a process that has the
 .B CAP_NET_BIND_SERVICE
-capability) may
+capability in the user namespace governing its network namespace) may
 .BR bind (2)
 to these sockets.
 Note that the raw IPv4 protocol as such has no concept of a
-port, they are only implemented by higher protocols like
+port, they are implemented only by higher protocols like
 .BR tcp (7)
 and
 .BR udp (7).
@@ -153,27 +209,30 @@ contains the host interface address in network byte order.
 .I in_addr
 should be assigned one of the
 .BR INADDR_*
-values (e.g.,
-.BR INADDR_ANY )
+values
+(e.g.,
+.BR INADDR_LOOPBACK )
+using
+.BR htonl (3)
 or set using the
 .BR inet_aton (3),
 .BR inet_addr (3),
 .BR inet_makeaddr (3)
 library functions or directly with the name resolver (see
 .BR gethostbyname (3)).
-
-IPv4 addresses are divided into unicast, broadcast
+.PP
+IPv4 addresses are divided into unicast, broadcast,
 and multicast addresses.
 Unicast addresses specify a single interface of a host,
-broadcast addresses specify all hosts on a network and multicast
+broadcast addresses specify all hosts on a network, and multicast
 addresses address all hosts in a multicast group.
-Datagrams to broadcast addresses can be only sent or received when the
+Datagrams to broadcast addresses can be sent or received only when the
 .B SO_BROADCAST
 socket flag is set.
-In the current implementation, connection-oriented sockets are only allowed
-to use unicast addresses.
+In the current implementation, connection-oriented sockets are allowed
+to use only unicast addresses.
 .\" Leave a loophole for XTP @)
-
+.PP
 Note that the address and the port are always stored in
 network byte order.
 In particular, this means that you need to call
@@ -181,7 +240,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.
-
+.PP
 There are several special addresses:
 .B INADDR_LOOPBACK
 (127.0.0.1)
@@ -194,7 +253,7 @@ means any address for binding;
 means any host and has the same effect on bind as
 .B INADDR_ANY
 for historical reasons.
-.SS Socket Options
+.SS Socket options
 IP supports some protocol-specific socket options that can be set with
 .BR setsockopt (2)
 and read with
@@ -203,15 +262,22 @@ The socket option level for IP is
 .BR IPPROTO_IP .
 .\" or SOL_IP on Linux
 A boolean integer flag is zero when it is false, otherwise true.
+.PP
+When an invalid socket option is specified,
+.BR getsockopt (2)
+and
+.BR setsockopt (2)
+fail with the error
+.BR ENOPROTOOPT .
 .TP
 .BR IP_ADD_MEMBERSHIP " (since Linux 1.2)"
 Join a multicast group.
 Argument is an
 .I ip_mreqn
 structure.
-.sp
+.PP
 .in +4n
-.nf
+.EX
 struct ip_mreqn {
     struct in_addr imr_multiaddr; /* IP multicast group
                                      address */
@@ -219,9 +285,9 @@ struct ip_mreqn {
                                      interface */
     int            imr_ifindex;   /* interface index */
 };
-.fi
+.EE
 .in
-.sp
+.PP
 .I imr_multiaddr
 contains the address of the multicast group the application
 wants to join or leave.
@@ -234,7 +300,7 @@ fails with the error
 .I imr_address
 is the address of the local interface with which the system
 should join the multicast group; if it is equal to
-.B INADDR_ANY
+.BR INADDR_ANY ,
 an appropriate interface is chosen by the system.
 .I imr_ifindex
 is the interface index of the interface that should join/leave the
@@ -252,10 +318,80 @@ it differs from
 only by not including the
 .I imr_ifindex
 field.
-Only valid as a
+(The kernel determines which structure is being passed based
+on the size passed in
+.IR optlen .)
+.IP
+.B IP_ADD_MEMBERSHIP
+is valid only for
 .BR setsockopt (2).
 .\"
 .TP
+.BR IP_ADD_SOURCE_MEMBERSHIP " (since Linux 2.4.22 / 2.5.68)"
+Join a multicast group and allow receiving data only
+from a specified source.
+Argument is an
+.I ip_mreq_source
+structure.
+.PP
+.in +4n
+.EX
+struct ip_mreq_source {
+    struct in_addr imr_multiaddr;  /* IP multicast group
+                                      address */
+    struct in_addr imr_interface;  /* IP address of local
+                                      interface */
+    struct in_addr imr_sourceaddr; /* IP address of
+                                      multicast source */
+};
+.EE
+.in
+.PP
+The
+.I ip_mreq_source
+structure is similar to
+.I ip_mreqn
+described under
+.BR IP_ADD_MEMBERSHIP .
+The
+.I imr_multiaddr
+field contains the address of the multicast group the application
+wants to join or leave.
+The
+.I imr_interface
+field is the address of the local interface with which
+the system should join the multicast group.
+Finally, the
+.I imr_sourceaddr
+field contains the address of the source the
+application wants to receive data from.
+.IP
+This option can be used multiple times to allow
+receiving data from more than one source.
+.TP
+.BR IP_BIND_ADDRESS_NO_PORT " (since Linux 4.2)"
+.\" commit 90c337da1524863838658078ec34241f45d8394d
+Inform the kernel to not reserve an ephemeral port when using
+.BR bind (2)
+with a port number of 0.
+The port will later be automatically chosen at
+.BR connect (2)
+time,
+in a way that allows sharing a source port as long as the 4-tuple is unique.
+.TP
+.BR IP_BLOCK_SOURCE " (since Linux 2.4.22 / 2.5.68)"
+Stop receiving multicast data from a specific source in a given group.
+This is valid only after the application has subscribed
+to the multicast group using either
+.BR IP_ADD_MEMBERSHIP
+or
+.BR IP_ADD_SOURCE_MEMBERSHIP .
+.IP
+Argument is an
+.I ip_mreq_source
+structure as described under
+.BR IP_ADD_SOURCE_MEMBERSHIP .
+.TP
 .BR IP_DROP_MEMBERSHIP " (since Linux 1.2)"
 Leave a multicast group.
 Argument is an
@@ -265,6 +401,19 @@ or
 structure similar to
 .BR IP_ADD_MEMBERSHIP .
 .TP
+.BR IP_DROP_SOURCE_MEMBERSHIP " (since Linux 2.4.22 / 2.5.68)"
+Leave a source-specific group\(emthat is, stop receiving data from
+a given multicast group that come from a given source.
+If the application has subscribed to multiple sources within
+the same group, data from the remaining sources will still be delivered.
+To stop receiving data from all sources at once, use
+.BR IP_DROP_MEMBERSHIP .
+.IP
+Argument is an
+.I ip_mreq_source
+structure as described under
+.BR IP_ADD_SOURCE_MEMBERSHIP .
+.TP
 .BR IP_FREEBIND " (since Linux 2.4)"
 .\" Precisely: 2.4.0-test10
 If enabled, this boolean option allows binding to an IP address
@@ -281,88 +430,131 @@ interface described below.
 .BR IP_HDRINCL " (since Linux 2.0)"
 If enabled,
 the user supplies an IP header in front of the user data.
-Only valid for
+Valid only for
 .B SOCK_RAW
-sockets.
-See
+sockets; see
 .BR raw (7)
 for more information.
-When this flag is enabled the values set by
+When this flag is enabled, the values set by
 .BR IP_OPTIONS ,
-.B IP_TTL
+.BR IP_TTL ,
 and
 .B IP_TOS
 are ignored.
-.\"
-.\" FIXME Document IP_IPSEC_POLICY
-.\" Since Linux 2.5.47
-.\" Needs CAP_NET_ADMIN
+.TP
+.BR IP_MSFILTER " (since Linux 2.4.22 / 2.5.68)"
+This option provides access to the advanced full-state filtering API.
+Argument is an
+.I ip_msfilter
+structure.
+.PP
+.in +4n
+.EX
+struct ip_msfilter {
+    struct in_addr imsf_multiaddr; /* IP multicast group
+                                      address */
+    struct in_addr imsf_interface; /* IP address of local
+                                      interface */
+    uint32_t       imsf_fmode;     /* Filter-mode */
+
+    uint32_t       imsf_numsrc;    /* Number of sources in
+                                      the following array */
+    struct in_addr imsf_slist[1];  /* Array of source
+                                      addresses */
+};
+.EE
+.in
+.PP
+There are two macros,
+.BR MCAST_INCLUDE
+and
+.BR MCAST_EXCLUDE ,
+which can be used to specify the filtering mode.
+Additionally, the
+.BR IP_MSFILTER_SIZE (n)
+macro exists to determine how much memory is needed to store
+.I ip_msfilter
+structure with
+.I n
+sources in the source list.
+.IP
+For the full description of multicast source filtering
+refer to RFC 3376.
 .TP
 .BR IP_MTU " (since Linux 2.2)"
 .\" Precisely: 2.1.124
 Retrieve the current known path MTU of the current socket.
-Only valid when the socket has been connected.
 Returns an integer.
-Only valid as a
-.BR getsockopt (2).
+.IP
+.B IP_MTU
+is valid only for
+.BR getsockopt (2)
+and can be employed only when the socket has been connected.
 .TP
 .BR IP_MTU_DISCOVER " (since Linux 2.2)"
 .\" Precisely: 2.1.124
 Set or receive the Path MTU Discovery setting for a socket.
 When enabled, Linux will perform Path MTU Discovery
-as defined in RFC\ 1191
-on this socket.
-The don't-fragment flag is set on all outgoing datagrams.
-The system-wide default is controlled by the
-.I /proc/sys/net/ipv4/ip_no_pmtu_disc
-file for
+as defined in RFC\ 1191 on
 .B SOCK_STREAM
-sockets, and disabled on all others.
+sockets.
 For
 .RB non- SOCK_STREAM
-sockets, it is the user's responsibility to packetize the data
-in MTU sized chunks and to do the retransmits if necessary.
-The kernel will reject packets that are bigger than the known
-path MTU if this flag is set (with
-.B EMSGSIZE
-).
+sockets,
+.B IP_PMTUDISC_DO
+forces the don't-fragment flag to be set on all outgoing packets.
+It is the user's responsibility to packetize the data
+in MTU-sized chunks and to do the retransmits if necessary.
+The kernel will reject (with
+.BR EMSGSIZE )
+datagrams that are bigger than the known path MTU.
+.B IP_PMTUDISC_WANT
+will fragment a datagram if needed according to the path MTU,
+or will set the don't-fragment flag otherwise.
+.IP
+The system-wide default can be toggled between
+.B IP_PMTUDISC_WANT
+and
+.B IP_PMTUDISC_DONT
+by writing (respectively, zero and nonzero values) to the
+.I /proc/sys/net/ipv4/ip_no_pmtu_disc
+file.
 .TS
 tab(:);
 c l
 l l.
-Path MTU discovery flags:Meaning
+Path MTU discovery value:Meaning
 IP_PMTUDISC_WANT:Use per-route settings.
 IP_PMTUDISC_DONT:Never do Path MTU Discovery.
 IP_PMTUDISC_DO:Always do Path MTU Discovery.
 IP_PMTUDISC_PROBE:Set DF but ignore Path MTU.
 .TE
-
+.sp 1
 When PMTU discovery is enabled, the kernel automatically keeps track of
 the path MTU per destination host.
 When it is connected to a specific peer with
 .BR connect (2),
 the currently known path MTU can be retrieved conveniently using the
 .B IP_MTU
-socket option (e.g., after a
+socket option (e.g., after an
 .B EMSGSIZE
 error occurred).
-It may change over time.
+The path MTU may change over time.
 For connectionless sockets with many destinations,
 the new MTU for a given destination can also be accessed using the
 error queue (see
 .BR IP_RECVERR ).
 A new error will be queued for every incoming MTU update.
-
+.IP
 While MTU discovery is in progress, initial packets from datagram sockets
 may be dropped.
 Applications using UDP should be aware of this and not
 take it into account for their packet retransmit strategy.
-
+.IP
 To bootstrap the path MTU discovery process on unconnected sockets, it
 is possible to start with a big datagram size
-(up to 64K-headers bytes long) and let it shrink by updates of the path MTU.
-.\" FIXME this is an ugly hack
-
+(headers up to 64 kilobytes long) and let it shrink by updates of the path MTU.
+.IP
 To get an initial estimate of the
 path MTU, connect a datagram socket to the destination address using
 .BR connect (2)
@@ -371,7 +563,7 @@ and retrieve the MTU by calling
 with the
 .B IP_MTU
 option.
-
+.IP
 It is possible to implement RFC 4821 MTU probing with
 .B SOCK_DGRAM
 or
@@ -384,18 +576,44 @@ This is also particularly useful for diagnostic tools such as
 that wish to deliberately send probe packets larger than
 the observed Path MTU.
 .TP
+.BR IP_MULTICAST_ALL " (since Linux 2.6.31)"
+This option can be used to modify the delivery policy of multicast messages
+to sockets bound to the wildcard
+.B INADDR_ANY
+address.
+The argument is a boolean integer (defaults to 1).
+If set to 1,
+the socket will receive messages from all the groups that have been joined
+globally on the whole system.
+Otherwise, it will deliver messages only from
+the groups that have been explicitly joined (for example via the
+.B IP_ADD_MEMBERSHIP
+option) on this particular socket.
+.TP
 .BR IP_MULTICAST_IF " (since Linux 1.2)"
 Set the local device for a multicast socket.
-Argument is an
+The argument for
+.BR setsockopt (2)
+is an
 .I ip_mreqn
 or
+.\" net: IP_MULTICAST_IF setsockopt now recognizes struct mreq
+.\" Commit: 3a084ddb4bf299a6e898a9a07c89f3917f0713f7
+(since Linux 3.5)
 .I ip_mreq
 structure similar to
-.BR IP_ADD_MEMBERSHIP .
-.IP
-When an invalid socket option is passed,
-.B ENOPROTOOPT
-is returned.
+.BR IP_ADD_MEMBERSHIP ,
+or an
+.I in_addr
+structure.
+(The kernel determines which structure is being passed based
+on the size passed in
+.IR optlen .)
+For
+.BR getsockopt (2),
+the argument is an
+.I in_addr
+structure.
 .TP
 .BR IP_MULTICAST_LOOP " (since Linux 1.2)"
 Set or read a boolean integer argument that determines whether
@@ -412,10 +630,11 @@ Argument is an integer.
 .BR IP_NODEFRAG " (since Linux 2.6.36)"
 If enabled (argument is nonzero),
 the reassembly of outgoing packets is disabled in the netfilter layer.
-This option is only valid for
+The argument is an integer.
+.IP
+This option is valid only for
 .B SOCK_RAW
 sockets.
-The argument is an integer.
 .TP
 .BR IP_OPTIONS " (since Linux 2.0)"
 .\" Precisely: 1.3.30
@@ -445,11 +664,6 @@ Calling
 with
 .B IP_OPTIONS
 puts the current IP options used for sending into the supplied buffer.
-.\" FIXME Document IP_PASSSEC
-.\" Boolean
-.\" Since Linux 2.6.17
-.\" commit 2c7946a7bf45ae86736ab3b43d0085e43947945c
-.\" Author: Catherine Zhang <cxzhang@watson.ibm.com>
 .TP
 .BR IP_PKTINFO " (since Linux 2.2)"
 .\" Precisely: 2.1.68
@@ -469,17 +683,16 @@ or
 .BR sendmsg (2).
 .IP
 .in +4n
-.nf
+.EX
 struct in_pktinfo {
     unsigned int   ipi_ifindex;  /* Interface index */
     struct in_addr ipi_spec_dst; /* Local address */
     struct in_addr ipi_addr;     /* Header Destination
                                     address */
 };
-.fi
+.EE
 .in
 .IP
-.\" FIXME elaborate on that.
 .I ipi_ifindex
 is the unique index of the interface the packet was received on.
 .I ipi_spec_dst
@@ -531,8 +744,7 @@ control message contains a
 structure:
 .IP
 .in +4n
-.ne 18
-.nf
+.EX
 #define SO_EE_ORIGIN_NONE    0
 #define SO_EE_ORIGIN_LOCAL   1
 #define SO_EE_ORIGIN_ICMP    2
@@ -550,7 +762,7 @@ struct sock_extended_err {
 };
 
 struct sockaddr *SO_EE_OFFENDER(struct sock_extended_err *);
-.fi
+.EE
 .in
 .IP
 .I ee_errno
@@ -666,7 +878,7 @@ The ancillary message contains a
 .TP
 .BR IP_RECVTOS " (since Linux 2.2)"
 .\" Precisely: 2.1.68
-If enabled the
+If enabled, the
 .B IP_TOS
 ancillary message is passed with incoming packets.
 It contains a byte which specifies the Type of Service/Precedence
@@ -677,8 +889,8 @@ Expects a boolean integer flag.
 .\" Precisely: 2.1.68
 When this flag is set, pass a
 .B IP_TTL
-control message with the time to live
-field of the received packet as a byte.
+control message with the time-to-live
+field of the received packet as a 32 bit integer.
 Not supported for
 .B SOCK_STREAM
 sockets.
@@ -694,7 +906,7 @@ options not filled in for this hop.
 .\" Precisely: 2.1.68
 Pass all to-be forwarded packets with the
 IP Router Alert option set to this socket.
-Only valid for raw sockets.
+Valid only for raw sockets.
 This is useful, for instance, for user-space RSVP daemons.
 The tapped packets are not forwarded by the kernel; it is
 the user's responsibility to send them out again.
@@ -723,18 +935,13 @@ Linux sends
 datagrams first by default,
 but the exact behavior depends on the configured queueing discipline.
 .\" FIXME elaborate on this
-Some high priority levels may require superuser privileges (the
+Some high-priority levels may require superuser privileges (the
 .B CAP_NET_ADMIN
 capability).
-The priority can also be set in a protocol independent way by the
-.RB ( SOL_SOCKET ", " SO_PRIORITY )
-socket option (see
-.BR socket (7)).
-.\" Needs CAP_NET_ADMIN
-.\" Boolean
-.\" Since Linux 2.6.27
-.\" Author: KOVACS Krisztian <hidden@sch.bme.hu>
-.\" http://lwn.net/Articles/252545/
+.\" The priority can also be set in a protocol-independent way by the
+.\" .RB ( SOL_SOCKET ", " SO_PRIORITY )
+.\" socket option (see
+.\" .BR socket (7)).
 .TP
 .BR IP_TRANSPARENT " (since Linux 2.6.24)"
 .\" commit f5715aea4564f233767ea1d944b2637a5fd7cd2e
@@ -747,7 +954,10 @@ This socket option allows
 the calling application to bind to a nonlocal IP address and operate
 both as a client and a server with the foreign address as the local endpoint.
 NOTE: this requires that routing be set up in a way that
-packets going to the foreign address are routed through the TProxy box.
+packets going to the foreign address are routed through the TProxy box
+(i.e., the system hosting the application that employs the
+.B IP_TRANSPARENT
+socket option).
 Enabling this socket option requires superuser privileges
 (the
 .BR CAP_NET_ADMIN
@@ -759,9 +969,17 @@ this option be set on the redirected socket.
 .BR IP_TTL " (since Linux 1.0)"
 Set or retrieve the current time-to-live field that is used in every packet
 sent from this socket.
-.\" FIXME Document IP_XFRM_POLICY
-.\" Since Linux 2.5.48
-.\" Needs CAP_NET_ADMIN
+.TP
+.BR IP_UNBLOCK_SOURCE " (since Linux 2.4.22 / 2.5.68)"
+Unblock previously blocked multicast source.
+Returns
+.BR EADDRNOTAVAIL
+when given source is not being blocked.
+.IP
+Argument is an
+.I ip_mreq_source
+structure as described under
+.BR IP_ADD_SOURCE_MEMBERSHIP .
 .SS /proc interfaces
 The IP protocol
 supports a set of
@@ -770,8 +988,8 @@ interfaces to configure some global parameters.
 The parameters can be accessed by reading or writing files in the directory
 .IR /proc/sys/net/ipv4/ .
 .\" FIXME As at 2.6.12, 14 Jun 2005, the following are undocumented:
-.\"    ip_queue_maxlen
-.\"    ip_conntrack_max
+.\"  ip_queue_maxlen
+.\"  ip_conntrack_max
 Interfaces described as
 .I Boolean
 take an integer value, with a nonzero value ("true") meaning that
@@ -784,21 +1002,21 @@ meaning that the option is disabled.
 was controlled at compile time by the
 .B CONFIG_IP_ALWAYS_DEFRAG
 option; this option is not present in 2.4.x and later]
-
+.IP
 When this boolean flag is enabled (not equal 0), incoming fragments
 (parts of IP packets
 that arose when some host between origin and destination decided
 that the packets were too large and cut them into pieces) will be
 reassembled (defragmented) before being processed, even if they are
 about to be forwarded.
-
-Only enable if running either a firewall that is the sole link
+.IP
+Enable only if running either a firewall that is the sole link
 to your network or a transparent proxy; never ever use it for a
 normal router or host.
-Otherwise fragmented communication can be disturbed
+Otherwise, fragmented communication can be disturbed
 if the fragments travel over different links.
 Defragmentation also has a large memory and CPU time cost.
-
+.IP
 This is automagically turned on when masquerading or transparent
 proxying are configured.
 .\"
@@ -831,14 +1049,39 @@ IP forwarding can be also set on a per-interface basis.
 .TP
 .IR ip_local_port_range " (since Linux 2.2)"
 .\" Precisely: since 2.1.68
-Contains two integers that define the default local port range
-allocated to sockets.
-Allocation starts with the first number and ends with the second number.
-Note that these should not conflict with the ports used by masquerading
+This file contains two integers that define the default local port range
+allocated to sockets that are not explicitly bound to a port number\(emthat
+is, the range used for
+.IR "ephemeral ports" .
+An ephemeral port is allocated to a socket in the following circumstances:
+.RS
+.IP * 3
+the port number in a socket address is specified as 0 when calling
+.BR bind (2);
+.IP *
+.BR listen (2)
+is called on a stream socket that was not previously bound;
+.IP *
+.BR connect (2)
+was called on a socket that was not previously bound;
+.IP *
+.BR sendto (2)
+is called on a datagram socket that was not previously bound.
+.RE
+.IP
+Allocation of ephemeral ports starts with the first number in
+.IR ip_local_port_range
+and ends with the second number.
+If the range of ephemeral ports is exhausted,
+then the relevant system call returns an error (but see BUGS).
+.IP
+Note that the port range in
+.IR ip_local_port_range
+should not conflict with the ports used by masquerading
 (although the case is handled).
-Also arbitrary choices may cause problems with some firewall packet
+Also, arbitrary choices may cause problems with some firewall packet
 filters that make assumptions about the local ports in use.
-First number should be at least greater than 1024,
+The first number should be at least greater than 1024,
 or better, greater than 4096, to avoid clashes
 with well known ports and to minimize firewall problems.
 .\"
@@ -884,8 +1127,8 @@ Contains an integer with the number of bytes.
 See
 .BR arp (7).
 .\" FIXME Document the conf/*/* interfaces
+.\"
 .\" FIXME Document the route/* interfaces
-.\" FIXME document them all
 .SS Ioctls
 All ioctls described in
 .BR socket (7)
@@ -935,7 +1178,7 @@ address was not local.
 Operation on a nonblocking socket would block.
 .TP
 .B EALREADY
-An connection operation on a nonblocking socket is already in progress.
+A connection operation on a nonblocking socket is already in progress.
 .TP
 .B ECONNABORTED
 A connection was closed during an
@@ -943,7 +1186,7 @@ A connection was closed during an
 .TP
 .B EHOSTUNREACH
 No valid routing table entry matches the destination address.
-This error can be caused by a ICMP message from a remote router or
+This error can be caused by an ICMP message from a remote router or
 for the local routing table.
 .TP
 .B EINVAL
@@ -975,7 +1218,7 @@ A kernel subsystem was not configured.
 Invalid socket option passed.
 .TP
 .B ENOTCONN
-The operation is only defined on a connected socket, but the socket wasn't
+The operation is defined only on a connected socket, but the socket wasn't
 connected.
 .TP
 .B EPERM
@@ -991,11 +1234,12 @@ The socket is not configured or an unknown socket type was requested.
 Other errors may be generated by the overlaying protocols; see
 .BR tcp (7),
 .BR raw (7),
-.BR udp (7)
+.BR udp (7),
 and
 .BR socket (7).
 .SH NOTES
 .BR IP_FREEBIND ,
+.BR IP_MSFILTER ,
 .BR IP_MTU ,
 .BR IP_MTU_DISCOVER ,
 .BR IP_RECVORIGDSTADDR ,
@@ -1008,7 +1252,7 @@ are Linux-specific.
 .\" IP_PASSSEC is Linux-specific
 .\" IP_XFRM_POLICY is Linux-specific
 .\" IP_IPSEC_POLICY is a nonstandard extension, also present on some BSDs
-
+.PP
 Be very careful with the
 .B SO_BROADCAST
 option \- it is not privileged in Linux.
@@ -1037,11 +1281,19 @@ This is different from the
 .B IP_TTL
 option used in Linux.
 .PP
-Using
+Using the
 .B SOL_IP
-socket options level isn't portable, BSD-based stacks use
+socket options level isn't portable; BSD-based stacks use the
 .B IPPROTO_IP
 level.
+.PP
+.B INADDR_ANY
+(0.0.0.0) and
+.B INADDR_BROADCAST
+(255.255.255.255) are byte-order-neutral.
+ This means
+.BR htonl (3)
+has no effect on them.
 .SS Compatibility
 For compatibility with Linux 2.0, the obsolete
 .BI "socket(AF_INET, SOCK_PACKET, " protocol )
@@ -1058,12 +1310,20 @@ address structure for generic link layer information instead of the old
 .SH BUGS
 There are too many inconsistent error values.
 .PP
+The error used to diagnose exhaustion of the ephemeral port range differs
+across the various system calls
+.RB ( connect (2),
+.BR bind (2),
+.BR listen (2),
+.BR sendto (2))
+that can assign ephemeral ports.
+.PP
 The ioctls to configure IP-specific interface options and ARP tables are
 not described.
-.PP
-Some versions of glibc forget to declare
-.IR in_pktinfo .
-Workaround currently is to copy it into your program from this man page.
+.\" .PP
+.\" Some versions of glibc forget to declare
+.\" .IR in_pktinfo .
+.\" Workaround currently is to copy it into your program from this man page.
 .PP
 Receiving the original destination address with
 .B MSG_ERRQUEUE
@@ -1074,21 +1334,25 @@ by
 does not work in some 2.2 kernels.
 .\" .SH AUTHORS
 .\" This man page was written by Andi Kleen.
-.SH "SEE ALSO"
+.SH SEE ALSO
 .BR recvmsg (2),
 .BR sendmsg (2),
 .BR byteorder (3),
 .BR ipfw (4),
 .BR capabilities (7),
+.BR icmp (7),
+.BR ipv6 (7),
+.BR netdevice (7),
 .BR netlink (7),
 .BR raw (7),
 .BR socket (7),
 .BR tcp (7),
-.BR udp (7)
+.BR udp (7),
+.BR ip (8)
+.PP
+The kernel source file
+.IR Documentation/networking/ip-sysctl.txt .
 .PP
 RFC\ 791 for the original IP specification.
-.br
 RFC\ 1122 for the IPv4 host requirements.
-.br
 RFC\ 1812 for the IPv4 router requirements.
-.\" FIXME autobind INADDR REUSEADDR