Unverified Commit 82e74217 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!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: default avatarWei Li <liwei391@huawei.com>
Signed-off-by: default avatarWei Li <liwei391@huawei.com>
parents 5d7f8933 01d81b16
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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;
+15 −0
Original line number Diff line number Diff line
@@ -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 */
+1 −0
Original line number Diff line number Diff line
@@ -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
+5 −1
Original line number Diff line number Diff line
@@ -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;
+1 −0
Original line number Diff line number Diff line
@@ -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);
Loading