From 3624fa5ac89d495f0960c9592138d64f651573d2 Mon Sep 17 00:00:00 2001 From: zhang-mingyi66 Date: Sat, 15 Jul 2023 00:09:12 +0800 Subject: [PATCH] net, bpf: Introduces a new ebpf delay connect flag hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7LE1H --------------------------------------------------- The bpf_defer_connect bit is added for inet_sock to indicate whether the current socket is changed to the bpf program to delay link establishment. Signed-off-by: zhang-mingyi66 --- include/net/inet_sock.h | 3 ++- net/ipv4/tcp.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h index caa20a905531..07b7e16b2dad 100644 --- a/include/net/inet_sock.h +++ b/include/net/inet_sock.h @@ -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; diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 8d20d9221238..5c8d7bf607ca 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -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 -- GitLab