Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eb92f76e authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'tcp-fastopen-new-API'



Wei Wang says:

====================
net/tcp-fastopen: Add new userspace API support

The patch series is to add support for new userspace API for TCP fastopen
sockets.
In the current code, user has to call sendto()/sendmsg() with special flag
MSG_FASTOPEN for TCP fastopen sockets. This API is quite different from the
normal TCP socket API and can be cumbersome for applications to make use
fastopen sockets.
So this new patch introduces a new way of using TCP fastopen sockets which
is similar to normal TCP sockets with a new sockopt TCP_FASTOPEN_CONNECT.
More details about it is described in the third patch.
(First 2 patches are preparations for the third patch.)
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents a9c54ad2 19f6d3f3
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -222,7 +222,8 @@ struct tcp_sock {
	u32	chrono_stat[3];	/* Time in jiffies for chrono_stat stats */
	u8	chrono_type:2,	/* current chronograph type */
		rate_app_limited:1,  /* rate_{delivered,interval_us} limited? */
		unused:5;
		fastopen_connect:1, /* FASTOPEN_CONNECT sockopt */
		unused:4;
	u8	nonagle     : 4,/* Disable Nagle algorithm?             */
		thin_lto    : 1,/* Use linear timeouts for thin streams */
		unused1	    : 1,
+5 −1
Original line number Diff line number Diff line
@@ -206,7 +206,11 @@ struct inet_sock {
				transparent:1,
				mc_all:1,
				nodefrag:1;
	__u8			bind_address_no_port:1;
	__u8			bind_address_no_port:1,
				defer_connect:1; /* Indicates that fastopen_connect is set
						  * and cookie exists so we defer connect
						  * until first data frame is written
						  */
	__u8			rcv_tos;
	__u8			convert_csum;
	int			uc_index;
+3 −0
Original line number Diff line number Diff line
@@ -1493,6 +1493,9 @@ struct sock *tcp_try_fastopen(struct sock *sk, struct sk_buff *skb,
			      struct tcp_fastopen_cookie *foc,
			      struct dst_entry *dst);
void tcp_fastopen_init_key_once(bool publish);
bool tcp_fastopen_cookie_check(struct sock *sk, u16 *mss,
			     struct tcp_fastopen_cookie *cookie);
bool tcp_fastopen_defer_connect(struct sock *sk, int *err);
#define TCP_FASTOPEN_KEY_LENGTH 16

/* Fastopen key context */
+1 −0
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ enum {
#define TCP_SAVE_SYN		27	/* Record SYN headers for new connections */
#define TCP_SAVED_SYN		28	/* Get SYN headers recorded for connection */
#define TCP_REPAIR_WINDOW	29	/* Get/set window parameters */
#define TCP_FASTOPEN_CONNECT	30	/* Attempt FastOpen with connect */

struct tcp_repair_opt {
	__u32	opt_code;
+24 −7
Original line number Diff line number Diff line
@@ -576,6 +576,16 @@ int __inet_stream_connect(struct socket *sock, struct sockaddr *uaddr,
	int err;
	long timeo;

	/*
	 * uaddr can be NULL and addr_len can be 0 if:
	 * sk is a TCP fastopen active socket and
	 * TCP_FASTOPEN_CONNECT sockopt is set and
	 * we already have a valid cookie for this socket.
	 * In this case, user can call write() after connect().
	 * write() will invoke tcp_sendmsg_fastopen() which calls
	 * __inet_stream_connect().
	 */
	if (uaddr) {
		if (addr_len < sizeof(uaddr->sa_family))
			return -EINVAL;

@@ -584,6 +594,7 @@ int __inet_stream_connect(struct socket *sock, struct sockaddr *uaddr,
			sock->state = err ? SS_DISCONNECTING : SS_UNCONNECTED;
			goto out;
		}
	}

	switch (sock->state) {
	default:
@@ -593,6 +604,9 @@ int __inet_stream_connect(struct socket *sock, struct sockaddr *uaddr,
		err = -EISCONN;
		goto out;
	case SS_CONNECTING:
		if (inet_sk(sk)->defer_connect)
			err = -EINPROGRESS;
		else
			err = -EALREADY;
		/* Fall out of switch with err, set for this state */
		break;
@@ -607,6 +621,9 @@ int __inet_stream_connect(struct socket *sock, struct sockaddr *uaddr,

		sock->state = SS_CONNECTING;

		if (!err && inet_sk(sk)->defer_connect)
			goto out;

		/* Just entered SS_CONNECTING state; the only
		 * difference is that return value in non-blocking
		 * case is EINPROGRESS, rather than EALREADY.
Loading