Skip to content

Commit

Permalink
reuse tcp_sendmsg_fastopen()
Browse files Browse the repository at this point in the history
In the following patches we will reuse modified tcp_sendmsg_fastopen().
We call it from mptcp_sendmsg().

Signed-off-by: Dmytro Shytyi <dmytro@shytyi.net>
  • Loading branch information
Dmytro Shytyi authored and intel-lab-lkp committed Sep 20, 2022
1 parent f6f285d commit 0196a0e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
3 changes: 3 additions & 0 deletions include/net/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,9 @@ struct sock *tcp_try_fastopen(struct sock *sk, struct sk_buff *skb,
struct request_sock *req,
struct tcp_fastopen_cookie *foc,
const struct dst_entry *dst);
int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
int *copied, size_t size,
struct ubuf_info *uarg);
void tcp_fastopen_init_key_once(struct net *net);
bool tcp_fastopen_cookie_check(struct sock *sk, u16 *mss,
struct tcp_fastopen_cookie *cookie);
Expand Down
18 changes: 13 additions & 5 deletions net/ipv4/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@
#include <asm/ioctls.h>
#include <net/busy_poll.h>

#include <net/mptcp.h>
#include "../mptcp/protocol.h"

/* Track pending CMSGs. */
enum {
TCP_CMSG_INQ = 1,
Expand Down Expand Up @@ -1162,9 +1165,9 @@ void tcp_free_fastopen_req(struct tcp_sock *tp)
}
}

static int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
int *copied, size_t size,
struct ubuf_info *uarg)
int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
int *copied, size_t size,
struct ubuf_info *uarg)
{
struct tcp_sock *tp = tcp_sk(sk);
struct inet_sock *inet = inet_sk(sk);
Expand Down Expand Up @@ -1197,8 +1200,13 @@ static int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
}
}
flags = (msg->msg_flags & MSG_DONTWAIT) ? O_NONBLOCK : 0;
err = __inet_stream_connect(sk->sk_socket, uaddr,
msg->msg_namelen, flags, 1);
if (!sk_is_mptcp(sk))
err = __inet_stream_connect(sk->sk_socket, uaddr,
msg->msg_namelen, flags, 1);
else
err = mptcp_stream_connect(sk->sk_socket, uaddr,
msg->msg_namelen, msg->msg_flags);

/* fastopen_req could already be freed in __inet_stream_connect
* if the connection times out or gets rst
*/
Expand Down
11 changes: 9 additions & 2 deletions net/mptcp/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1673,9 +1673,16 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
long timeo;

/* we don't support FASTOPEN yet */
if (msg->msg_flags & MSG_FASTOPEN)
return -EOPNOTSUPP;
if (msg->msg_flags & MSG_FASTOPEN) {
struct socket *ssock = __mptcp_nmpc_socket(msk);

if (ssock) {
int copied_syn_fastopen = 0;

ret = tcp_sendmsg_fastopen(ssock->sk, msg, &copied_syn_fastopen, len, NULL);
copied += copied_syn_fastopen;
}
}
/* silently ignore everything else */
msg->msg_flags &= MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL;

Expand Down

0 comments on commit 0196a0e

Please sign in to comment.