Skip to contentSkip to conversation

send.2: Add MSG_FASTOPEN flag

PATCH In review Wei Wang 2 participants 2 messages Sep 17, 2021 – Sep 21, 2021

Subsystems (3)
lore
Share & tools
lore

Wei Wang

author
#0 lore raw

PATCH v2 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.

---
Change in v2: corrected some format issues

 man2/send.2 | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
man2/send.2 +32 -0
index fd28fed90..acaa05be9 100644
@@ -252,6 +252,38 @@ 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
+.BR 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 sets the same
+.I errno
+as
+.BR connect (2)
+if the handshake fails.
+This flag requires enabling TCP Fast Open client support on sysctl
+.IR net.ipv4.tcp_fastopen .
+.IP
+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.464.g1972c5931b-goog
#1 lore raw

Hi Wei,

Quoted 6 lines · Wei Wang

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

Patch applied!

Thanks (and to the reviewers too!),

Alex

Quoted 50 lines

---
Change in v2: corrected some format issues

  man2/send.2 | 32 ++++++++++++++++++++++++++++++++
  1 file changed, 32 insertions(+)
man2/send.2 +32 -0
index fd28fed90..acaa05be9 100644
@@ -252,6 +252,38 @@ 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
+.BR 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 sets the same
+.I errno
+as
+.BR connect (2)
+if the handshake fails.
+This flag requires enabling TCP Fast Open client support on sysctl
+.IR net.ipv4.tcp_fastopen .
+.IP
+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 · 3 lines
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/