未验证 提交 82e74217 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!1414 ipv4, ebpf: modify sockops and connect

Merge Pull Request from: @zhang-mingyi66 
 
modify sockops.

change connect function to implement defer connect. 
 
Link:https://gitee.com/openeuler/kernel/pulls/1414 

Reviewed-by: Wei Li <liwei391@huawei.com> 
Signed-off-by: Wei Li <liwei391@huawei.com> 
......@@ -238,10 +238,11 @@ struct inet_sock {
nodefrag:1;
__u8 bind_address_no_port:1,
recverr_rfc4884:1,
defer_connect:1; /* Indicates that fastopen_connect is set
defer_connect:1, /* Indicates that fastopen_connect is set
* and cookie exists so we defer connect
* until first data frame is written
*/
bpf_defer_connect:1;
__u8 rcv_tos;
__u8 convert_csum;
int uc_index;
......
......@@ -332,6 +332,21 @@ DEFINE_EVENT(sock_msg_length, sock_recv_length,
TP_ARGS(sk, ret, flags)
);
#undef NET_DECLARE_TRACE
#ifdef DECLARE_TRACE_WRITABLE
#define NET_DECLARE_TRACE(call, proto, args, size) \
DECLARE_TRACE_WRITABLE(call, PARAMS(proto), PARAMS(args), size)
#else
#define NET_DECLARE_TRACE(call, proto, args, size) \
DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))
#endif
NET_DECLARE_TRACE(connect_ret,
TP_PROTO(int *err),
TP_ARGS(err),
sizeof(int));
#endif /* _TRACE_SOCK_H */
/* This part must be outside protection */
......
......@@ -6701,6 +6701,7 @@ enum {
* by the kernel or the
* earlier bpf-progs.
*/
BPF_SOCK_OPS_TCP_DEFER_CONNECT_CB,/* call ebpf to defer connect*/
};
/* List of TCP states. There is a build check in net/ipv4/tcp.c to detect
......
......@@ -5255,6 +5255,10 @@ static int sol_tcp_sockopt(struct sock *sk, int optname,
if (*optlen < 1)
return -EINVAL;
break;
case TCP_ULP:
if (getopt)
return -EINVAL;
break;
default:
if (getopt)
return -EINVAL;
......@@ -8970,7 +8974,7 @@ static bool sock_ops_is_valid_access(int off, int size,
if (type == BPF_WRITE) {
switch (off) {
case offsetof(struct bpf_sock_ops, reply):
case bpf_ctx_range_till(struct bpf_sock_ops, reply, replylong[3]):
case offsetof(struct bpf_sock_ops, sk_txhash):
if (size != size_default)
return false;
......
......@@ -728,6 +728,7 @@ int inet_stream_connect(struct socket *sock, struct sockaddr *uaddr,
lock_sock(sock->sk);
err = __inet_stream_connect(sock, uaddr, addr_len, flags, 0);
release_sock(sock->sk);
trace_connect_ret(&err);
return err;
}
EXPORT_SYMBOL(inet_stream_connect);
......
......@@ -582,7 +582,8 @@ __poll_t tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
if (urg_data & TCP_URG_VALID)
mask |= EPOLLPRI;
} else if (state == TCP_SYN_SENT && inet_sk(sk)->defer_connect) {
} else if (state == TCP_SYN_SENT &&
(inet_sk(sk)->defer_connect || inet_sk(sk)->bpf_defer_connect)) {
/* Active TCP fastopen socket with defer_connect
* Return EPOLLOUT so application can call write()
* in order for kernel to generate SYN+data
......
......@@ -6701,6 +6701,7 @@ enum {
* by the kernel or the
* earlier bpf-progs.
*/
BPF_SOCK_OPS_TCP_DEFER_CONNECT_CB,/* call ebpf to defer connect*/
};
/* List of TCP states. There is a build check in net/ipv4/tcp.c to detect
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册