summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAkhmat Karakotov <hmukos@yandex-team.ru>2022-01-28 22:26:21 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-07-05 09:14:41 +0200
commit57a1a06755e27f10fecd40d73245bc5ade86bbe3 (patch)
tree9e806b2268c5f670ece62e9590a912d812d7d8f5 /include
parent1d3e3b3aa2cbe9bc7db9a7f8673a9fa6d2990d54 (diff)
downloadlinux-57a1a06755e27f10fecd40d73245bc5ade86bbe3.tar.gz
linux-57a1a06755e27f10fecd40d73245bc5ade86bbe3.tar.bz2
linux-57a1a06755e27f10fecd40d73245bc5ade86bbe3.zip
tcp: Use BPF timeout setting for SYN ACK RTO
[ Upstream commit 5903123f662ed18483f05cac3f9e800a074c29ff ] When setting RTO through BPF program, some SYN ACK packets were unaffected and continued to use TCP_TIMEOUT_INIT constant. This patch adds timeout option to struct request_sock. Option is initialized with TCP_TIMEOUT_INIT and is reassigned through BPF using tcp_timeout_init call. SYN ACK retransmits now use newly added timeout option. Signed-off-by: Akhmat Karakotov <hmukos@yandex-team.ru> Acked-by: Martin KaFai Lau <kafai@fb.com> v2: - Add timeout option to struct request_sock. Do not call tcp_timeout_init on every syn ack retransmit. v3: - Use unsigned long for min. Bound tcp_timeout_init to TCP_RTO_MAX. v4: - Refactor duplicate code by adding reqsk_timeout function. Signed-off-by: David S. Miller <davem@davemloft.net> Stable-dep-of: ff46e3b44219 ("Fix race for duplicate reqsk on identical SYN") Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/net/inet_connection_sock.h8
-rw-r--r--include/net/request_sock.h2
-rw-r--r--include/net/tcp.h2
3 files changed, 11 insertions, 1 deletions
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
index b6b7e210f9d7..7794cf2b5ef5 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -284,6 +284,14 @@ static inline int inet_csk_reqsk_queue_is_full(const struct sock *sk)
bool inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req);
void inet_csk_reqsk_queue_drop_and_put(struct sock *sk, struct request_sock *req);
+static inline unsigned long
+reqsk_timeout(struct request_sock *req, unsigned long max_timeout)
+{
+ u64 timeout = (u64)req->timeout << req->num_timeout;
+
+ return (unsigned long)min_t(u64, timeout, max_timeout);
+}
+
static inline void inet_csk_prepare_for_destroy_sock(struct sock *sk)
{
/* The below has to be done to allow calling inet_csk_destroy_sock */
diff --git a/include/net/request_sock.h b/include/net/request_sock.h
index 29e41ff3ec93..144c39db9898 100644
--- a/include/net/request_sock.h
+++ b/include/net/request_sock.h
@@ -70,6 +70,7 @@ struct request_sock {
struct saved_syn *saved_syn;
u32 secid;
u32 peer_secid;
+ u32 timeout;
};
static inline struct request_sock *inet_reqsk(const struct sock *sk)
@@ -104,6 +105,7 @@ reqsk_alloc(const struct request_sock_ops *ops, struct sock *sk_listener,
sk_node_init(&req_to_sk(req)->sk_node);
sk_tx_queue_clear(req_to_sk(req));
req->saved_syn = NULL;
+ req->timeout = 0;
req->num_timeout = 0;
req->num_retrans = 0;
req->sk = NULL;
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 08923ed4278f..30f8111f750b 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -2362,7 +2362,7 @@ static inline u32 tcp_timeout_init(struct sock *sk)
if (timeout <= 0)
timeout = TCP_TIMEOUT_INIT;
- return timeout;
+ return min_t(int, timeout, TCP_RTO_MAX);
}
static inline u32 tcp_rwnd_init_bpf(struct sock *sk)