Skip to contentSkip to conversation

send.2: Add MSG_FASTOPEN flag

PATCH Superseded Wei Wang 2 participants 3 messages Sep 15, 2021 – Sep 16, 2021

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wei Wang

author
#0 lore raw

PATCH 1/1 send.2: Add MSG_FASTOPEN flag

MSG_FASTOPEN flag is available since Linux 3.7. Add detailed description in the manpage according to RFC7413.

---
 man2/send.2 | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
man2/send.2 +27 -0
index fd28fed90..a40ae6214 100644
@@ -252,6 +252,33 @@ data on sockets that support this notion (e.g., of type
 the underlying protocol must also support
 .I out-of-band
 data.
+.TP
+.BR MSG_FASTOPEN " (since Linux 3.7)"
+Attempts TCP Fast Open (RFC7413) and sends data in the SYN like a
+combination of
+.BR connect (2)
+and
+.BR write (2)
+, by performing an implicit
+.BR connect (2)
+operation. It blocks until the data is buffered and the handshake
+has completed.
+For a non-blocking socket, it returns the number of bytes buffered
+and sent in the SYN packet. If the cookie is not available locally,
+it returns
+.B EINPROGRESS
+, and sends a SYN with a Fast Open cookie request automatically.
+The caller needs to write the data again when the socket is connected.
+On errors, it returns the same errno as
+.BR connect (2)
+if the handshake fails. This flag requires enabling TCP Fast Open
+client support on sysctl net.ipv4.tcp_fastopen.
+
+Refer to
+.B TCP_FASTOPEN_CONNECT
+socket option in
+.BR tcp (7)
+for an alternative approach.
 .SS sendmsg()
 The definition of the
 .I msghdr
Signature · 1 line
2.33.0.309.g3052b89438-goog
#1 lore raw

Hello, Wei!

Quoted 15 lines · Wei Wang

MSG_FASTOPEN flag is available since Linux 3.7. Add detailed description in the manpage according to RFC7413.

---
  man2/send.2 | 27 +++++++++++++++++++++++++++
  1 file changed, 27 insertions(+)
man2/send.2 +0 -0
index fd28fed90..a40ae6214 100644

man2/send.2 data on sockets that support this notion (e.g., of type · line 261

Quoted 10 lines
man2/send.2 +7 -0
@@ -252,6 +252,33 @@ data on sockets that support this notion (e.g., of type
  the underlying protocol must also support
  .I out-of-band
  data.
+.TP
+.BR MSG_FASTOPEN " (since Linux 3.7)"
+Attempts TCP Fast Open (RFC7413) and sends data in the SYN like a
+combination of
+.BR connect (2)
+and
+.BR write (2)

You should merge the comma with the above, to avoid an unwanted space:

.BR write (2),

man2/send.2 data on sockets that support this notion (e.g., of type · line 264

Quoted 3 lines
man2/send.2 +3 -0
+, by performing an implicit
+.BR connect (2)
+operation. It blocks until the data is buffered and the handshake

Please use semantic newlines. See man-pages(7):

Use semantic newlines
In the source of a manual page, new sentences should be started on new lines, and long sentences should be split into lines at clause breaks (commas, semicolons, colons, and so on). This convention, sometimes known as "semantic newlines", makes it easier to see the effect of patches, which often operate at the level of individual sentences or sentence clauses.

This is especially important after a period, since groff(1) will usually put 2 spaces after it, but if you hardcode it like above, it will only print 1 space.

man2/send.2 data on sockets that support this notion (e.g., of type · line 269

Quoted 5 lines
man2/send.2 +5 -0
+has completed.
+For a non-blocking socket, it returns the number of bytes buffered
+and sent in the SYN packet. If the cookie is not available locally,
+it returns
+.B EINPROGRESS

.BR EINPROGRESS ,

man2/send.2 data on sockets that support this notion (e.g., of type · line 272

Quoted 3 lines
man2/send.2 +3 -0
+, and sends a SYN with a Fast Open cookie request automatically.
+The caller needs to write the data again when the socket is connected.
+On errors, it returns the same errno as

errno should be highlighted:

.I errno

Also, errno is set, not returned (as far as user space is concerned); so something along the lines of "errno is set by connect(2)" or "it can fail for the same reasons that connect(2) can". Michael probably knows if there's a typical wording for this in the current manual pages, to add some consistency.

BTW, should anything be added to the ERRORS section?

man2/send.2 data on sockets that support this notion (e.g., of type · line 274

Quoted 2 lines
man2/send.2 +2 -0
+.BR connect (2) > +if the handshake fails. This flag requires enabling TCP Fast Open
+client support on sysctl net.ipv4.tcp_fastopen.

net.ipv4.tcp_fastopen should be highlighted:

.IR net.ipv4.tcp_fastopen .

man2/send.2 data on sockets that support this notion (e.g., of type · line 276

Quoted 1 line
man2/send.2 +1 -0
+

Also from man-pages(7):

Formatting conventions (general)
Paragraphs should be separated by suitable markers (usually either .PP or .IP). Do not separate paragraphs using blank lines, as this results in poor rendering in some output formats (such as PostScript and PDF).

Thanks!

Alex

Signature · 3 lines
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/
author
#2 lore raw
Quoted 97 lines · Alejandro Colomar (man-pages)

Hello, Wei!

Quoted 15 lines · Wei Wang

MSG_FASTOPEN flag is available since Linux 3.7. Add detailed description in the manpage according to RFC7413.

---
  man2/send.2 | 27 +++++++++++++++++++++++++++
  1 file changed, 27 insertions(+)
man2/send.2 +0 -0
index fd28fed90..a40ae6214 100644

man2/send.2 data on sockets that support this notion (e.g., of type · line 261

Quoted 10 lines
man2/send.2 +7 -0
@@ -252,6 +252,33 @@ data on sockets that support this notion (e.g., of type
  the underlying protocol must also support
  .I out-of-band
  data.
+.TP
+.BR MSG_FASTOPEN " (since Linux 3.7)"
+Attempts TCP Fast Open (RFC7413) and sends data in the SYN like a
+combination of
+.BR connect (2)
+and
+.BR write (2)

You should merge the comma with the above, to avoid an unwanted space:

.BR write (2),

man2/send.2 data on sockets that support this notion (e.g., of type · line 264

Quoted 3 lines
man2/send.2 +3 -0
+, by performing an implicit
+.BR connect (2)
+operation. It blocks until the data is buffered and the handshake

Please use semantic newlines. See man-pages(7):

Use semantic newlines
In the source of a manual page, new sentences should be started on new lines, and long sentences should be split into lines at clause breaks (commas, semicolons, colons, and so on). This convention, sometimes known as "semantic newlines", makes it easier to see the effect of patches, which often operate at the level of individual sentences or sentence clauses.

This is especially important after a period, since groff(1) will usually put 2 spaces after it, but if you hardcode it like above, it will only print 1 space.

man2/send.2 data on sockets that support this notion (e.g., of type · line 269

Quoted 5 lines
man2/send.2 +5 -0
+has completed.
+For a non-blocking socket, it returns the number of bytes buffered
+and sent in the SYN packet. If the cookie is not available locally,
+it returns
+.B EINPROGRESS

.BR EINPROGRESS ,

man2/send.2 data on sockets that support this notion (e.g., of type · line 272

Quoted 3 lines
man2/send.2 +3 -0
+, and sends a SYN with a Fast Open cookie request automatically.
+The caller needs to write the data again when the socket is connected.
+On errors, it returns the same errno as

errno should be highlighted:

.I errno

Also, errno is set, not returned (as far as user space is concerned); so something along the lines of "errno is set by connect(2)" or "it can fail for the same reasons that connect(2) can". Michael probably knows if there's a typical wording for this in the current manual pages, to add some consistency.

BTW, should anything be added to the ERRORS section?

man2/send.2 data on sockets that support this notion (e.g., of type · line 274

Quoted 2 lines
man2/send.2 +2 -0
+.BR connect (2) > +if the handshake fails. This flag requires enabling TCP Fast Open
+client support on sysctl net.ipv4.tcp_fastopen.

net.ipv4.tcp_fastopen should be highlighted:

.IR net.ipv4.tcp_fastopen .

man2/send.2 data on sockets that support this notion (e.g., of type · line 276

Quoted 1 line
man2/send.2 +1 -0
+

Also from man-pages(7):

Formatting conventions (general)
Paragraphs should be separated by suitable markers (usually either .PP or .IP). Do not separate paragraphs using blank lines, as this results in poor rendering in some output formats (such as PostScript and PDF).

Quoted 3 lines

Thanks!

Alex

Thanks Alex! Will address those and send out v2.

Quoted 7 lines

--
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/