From patchwork Sat Mar 1 20:14:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13997665 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f73.google.com (mail-qv1-f73.google.com [209.85.219.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F5941C5D77 for ; Sat, 1 Mar 2025 20:14:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740860070; cv=none; b=YbQbC02L8WGUtcUXEDFaO3kOA+PMMTIpxJuafzbgYJ+CQwBjH4IWje6pQFAos7CVC2SbzO2p2jysaCZg9d02hXjB1M8/06YNJSWeYLQ/uLbxzYh03Nv7YLYOPoofpkhl4DD/pwSclJbfM0KalAGVlpvXoCc8W2/qtPv9lXvNLKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740860070; c=relaxed/simple; bh=aB13b280MIcVuRc0VxldBo9bZY8SatpOVnXV+GjnvM0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=pxkxwsKndnng5TF7ckn++ZI7/2jlyBHZrxgiXJS8p3jqK9cDpZHN1OEJv5tu019lKa5kxBo5H6BZe/UokP64lTew8xNIkA57UFm+tUGEXjzXAfYZAyNHdAGuG4sPalkyOtR/z5FUxwlLjE3ltYVHmMa2zl1KvVbgyrIzpubh7KA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=bUvUx7Cl; arc=none smtp.client-ip=209.85.219.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bUvUx7Cl" Received: by mail-qv1-f73.google.com with SMTP id 6a1803df08f44-6e2378169a4so69501046d6.2 for ; Sat, 01 Mar 2025 12:14:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1740860068; x=1741464868; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=J+sHfABVNcOpkFnI0atmQ4P/qaUHSlV5OBnOnZJOtrk=; b=bUvUx7ClSBsxHAyzIR8gg20swkVovXcCvbmpOvUKZ2nDt0T9tUvUEPGXUmA78WlyPz +REuG45sYxorc6bZ8D1gJ8DmI/3Sw5vS93VwO/uYrahriHxmPcx+aOVJ+sTQtCBJ3F8J JzpGNY3g40PRXZg9K7biVHXoOkF4zpnYCj2Va+x3CAwQrHKBNptT/eAzAneRujaSxaab qtkaC7ufF1k8xnlIYbbOjtGHemsfk+tRj4FiS6B88bvB5bx/GM2Jt2XrReGdidUmBOQN ptZDbCZdeux6tBHfzjMEuXLn5d6Q2gI7bwgPLLUXHGgsi1YnsroChWjP07ipUKNr2keX LlOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740860068; x=1741464868; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=J+sHfABVNcOpkFnI0atmQ4P/qaUHSlV5OBnOnZJOtrk=; b=FhsVSZtnf+IeZxQ6FpElaO5ND8cu/cd524ZnGjXpa9n623OSGaOIVkLsx8XThIXRpX 25hqGav7Gi3c4wZB6EYyGLvVtqM6PPq+MN/AYsKTHXbO8Bjgd4DNbO4TDhVaZogTP6tx vtClDjAQy78+Am5SjCwHppbFMgDcX8sry5IbFoBMVRzuONaF9FTCTHFWydHIkzVl78P7 DUlKA4h27GLxr45y5nKC7BxZg7yhAoIwvemSCxPGFRn760H6yR0HIijtYp6StV4AIOpL oLhvmOyrh2QYqYeMHgG1Z+IOBEXCCdI6tc6G905E/ZX9AyKx5dcVeoHql1RUqeY2gg9G IBGw== X-Forwarded-Encrypted: i=1; AJvYcCUfW2B1izdeh9IqigKCSMB9tWD3VF8l5UceDdUqZj1MntW5GAe1LPLXvWMmrc/msdW/jJWkBPg=@vger.kernel.org X-Gm-Message-State: AOJu0YwAfyQv09KnmVV18ZczpXmanMbcaAm1/ww5MaN0chwxyFk2H2x3 wcMfKiA1LzcF7CLLdP9x559a6tfna67+aSd8JoXxOqacmHOaOW57Z0ZUj5OSkGKnUbCYbYVXn4T +P+c3g6f7AQ== X-Google-Smtp-Source: AGHT+IHvwiIsFODfxSLy5j6cIxrSIBGWL71eXs+PUcfIigp3QmReeaZoPOp0SVZY0Vrag1HeCSSvbe18yqCnew== X-Received: from qtbhh4.prod.google.com ([2002:a05:622a:6184:b0:471:f1e9:e151]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6214:2a8c:b0:6e6:61a5:aa4c with SMTP id 6a1803df08f44-6e8a0d6d798mr128658276d6.31.1740860068108; Sat, 01 Mar 2025 12:14:28 -0800 (PST) Date: Sat, 1 Mar 2025 20:14:19 +0000 In-Reply-To: <20250301201424.2046477-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250301201424.2046477-1-edumazet@google.com> X-Mailer: git-send-email 2.48.1.711.g2feabab25a-goog Message-ID: <20250301201424.2046477-2-edumazet@google.com> Subject: [PATCH v2 net-next 1/6] tcp: add a drop_reason pointer to tcp_check_req() From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni , Neal Cardwell Cc: Kuniyuki Iwashima , Simon Horman , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org We want to add new drop reasons for packets dropped in 3WHS in the following patches. tcp_rcv_state_process() has to set reason to TCP_FASTOPEN, because tcp_check_req() will conditionally overwrite the drop_reason. Signed-off-by: Eric Dumazet Reviewed-by: Jason Xing --- include/net/tcp.h | 2 +- net/ipv4/tcp_input.c | 5 ++--- net/ipv4/tcp_ipv4.c | 3 ++- net/ipv4/tcp_minisocks.c | 3 ++- net/ipv6/tcp_ipv6.c | 3 ++- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index f9b9377a289740b907594a0993fc5d70ed36aaac..a9bc959fb102fc6697b4a664b3773b47b3309f13 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -392,7 +392,7 @@ enum tcp_tw_status tcp_timewait_state_process(struct inet_timewait_sock *tw, u32 *tw_isn); struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, struct request_sock *req, bool fastopen, - bool *lost_race); + bool *lost_race, enum skb_drop_reason *drop_reason); enum skb_drop_reason tcp_child_process(struct sock *parent, struct sock *child, struct sk_buff *skb); void tcp_enter_loss(struct sock *sk); diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index d22ad553b45b17218d5362ea58a4f82559afb851..4e221234808898131a462bc93ee4c9c0ae04309e 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -6812,10 +6812,9 @@ tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) WARN_ON_ONCE(sk->sk_state != TCP_SYN_RECV && sk->sk_state != TCP_FIN_WAIT1); - if (!tcp_check_req(sk, skb, req, true, &req_stolen)) { - SKB_DR_SET(reason, TCP_FASTOPEN); + SKB_DR_SET(reason, TCP_FASTOPEN); + if (!tcp_check_req(sk, skb, req, true, &req_stolen, &reason)) goto discard; - } } if (!th->ack && !th->rst && !th->syn) { diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 7900855237d929d8260e65fe95e367345bb3ecd2..218f01a8cc5f6c410043f07293e9e51840c1f1cb 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -2265,7 +2265,8 @@ int tcp_v4_rcv(struct sk_buff *skb) th = (const struct tcphdr *)skb->data; iph = ip_hdr(skb); tcp_v4_fill_cb(skb, iph, th); - nsk = tcp_check_req(sk, skb, req, false, &req_stolen); + nsk = tcp_check_req(sk, skb, req, false, &req_stolen, + &drop_reason); } else { drop_reason = SKB_DROP_REASON_SOCKET_FILTER; } diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 29b54ade757231dc264fd8a2c357eff1b2ccbb6b..46c86c4f80e9f450834c72f28e3d16b0cffbbd1d 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -657,7 +657,8 @@ EXPORT_SYMBOL(tcp_create_openreq_child); struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, struct request_sock *req, - bool fastopen, bool *req_stolen) + bool fastopen, bool *req_stolen, + enum skb_drop_reason *drop_reason) { struct tcp_options_received tmp_opt; struct sock *child; diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index a806082602985fd351c5184f52dc3011c71540a9..d01088ab80d24eb0f829166faae791221d95bf9e 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -1828,7 +1828,8 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) th = (const struct tcphdr *)skb->data; hdr = ipv6_hdr(skb); tcp_v6_fill_cb(skb, hdr, th); - nsk = tcp_check_req(sk, skb, req, false, &req_stolen); + nsk = tcp_check_req(sk, skb, req, false, &req_stolen, + &drop_reason); } else { drop_reason = SKB_DROP_REASON_SOCKET_FILTER; } From patchwork Sat Mar 1 20:14:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13997666 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f202.google.com (mail-qt1-f202.google.com [209.85.160.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4373D1E8339 for ; Sat, 1 Mar 2025 20:14:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740860071; cv=none; b=g9hUlv553t9Ntbe9Ycp1i2G7io4Ey3ed44naFhfazwiPFz/6duT9C5wbIZ0p/SGV3kkZs/t8n7rXDGqsNic6K0jSiNkshVJOpwEP09LiM70CsISCfNdeAfwtfI7jlj4aQa5EhBelI7Xz+4pwW2Xb34rTupIJVvRA1c910Epli/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740860071; c=relaxed/simple; bh=2DBmuZPxm89N49KoZNLlsJjBc5JAdlLsTJTH8L+5GAA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=JQggmxV+wKUjXgFZvANyUCzAI81E/4QmDeJ+sjemgljxjJkBxioreiHiSeHyI3uEu0xBEkcw/dLNUOAFi8uiMpzLI8WCFETnl3NirULfmCVVtdlf4Gc1X2An/YXFSUJIkoDME2V/X/GWWkZ2PN0HPEdn8XjDlZg0N0qqts8VZew= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=nboJ73E+; arc=none smtp.client-ip=209.85.160.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="nboJ73E+" Received: by mail-qt1-f202.google.com with SMTP id d75a77b69052e-472051849acso59399771cf.0 for ; Sat, 01 Mar 2025 12:14:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1740860069; x=1741464869; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=4nJSXPCHCYyFPg2zigqXBKrcmYgDBLIpc2vQxNNA29o=; b=nboJ73E+//g0KB1viQ62fk99SFTBJfAz66CNgWzj2PWsabofLLZJpOTyN5G1P/8n0g 0miTT+sNcNyf5mhqUQJnOybhsfkUitCtDkXzBPO+WUtzDOFWqjhMPL9kfnpuZoMBeifU U0dFz4/9EK2Q74IbQlITOVoOK5gPmmtMI1azrPiL7Xpj57VYu43zH2NjrXZBXdWpSqh3 eqLlZg3xQqUo8S2U4AnABEGqSNuDF6z5lwZlmWeXVUkdMXSf9NJ3hQj9truI/VmardDl D/5Kbie4zf6fmIg5BLlzsmvXUFDUWsKbPoVo0QVOz95wMiH5mF+F1Ac4f6/CgCx+qRql ueeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740860069; x=1741464869; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4nJSXPCHCYyFPg2zigqXBKrcmYgDBLIpc2vQxNNA29o=; b=hFwV+/YSoDnFQAuJZa0LjX0jkkjWY/QIRjBt/Tr6gMNmFaUh3kxtBaYFtpGJbGGMvO cDUBvOtryKN25nkByfnfxytpINIL0NwRKPovzBIwhM88abFtBJ7LsU4AC9xmfNRlhzRY ZmTlZpqTSGhvfsHq+0gpGDnqsb+Go6vNln4NhTQkPXbxFGbiBBNM4S+aNMcsqWgfoKfq WRO7mU3ThYZMSGVCC5pEqneskxtwwEEFOBdpPQ+lBswjcV56yHPiWtt1x2PxuVHQ7Ale AvxN7qtMsIwQwchm7thbMdXZQDntLzxtceRkrZYYkkfe/KbbjW3WUq+evwdmTaZOnJYt zILA== X-Forwarded-Encrypted: i=1; AJvYcCWHw+u0aTVKutVRjSLknBwfyjtMtoj418f02Fw9hxgY0AyvbRgEG4Z6lrBa/+MbNp/lHzSSuJc=@vger.kernel.org X-Gm-Message-State: AOJu0Yz6rvPBLPyEi3X5Yuhm9BPGNamXXEf1OIm0IfQmLEBoMBzW6G+J W2NYXxzO81r66AdYnkEKXNhK/5O8OnaVUqoGk/2ZQeRGc7BAm6qvLYM2vwdwv4xR9pX39xQNBKr 7QOAE+g2xpg== X-Google-Smtp-Source: AGHT+IGx7dXq9WyxMETPGyQYQEnmMhgllGymNfXegzbvlLdT+Ss6MR0miF4UQnPW77FkhKp33e5RG1OZaX8/Kg== X-Received: from qtbhg22.prod.google.com ([2002:a05:622a:6116:b0:471:f7c8:bc02]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:a05:622a:294:b0:471:bd5e:d5e4 with SMTP id d75a77b69052e-474bc0e88f3mr106944771cf.42.1740860069383; Sat, 01 Mar 2025 12:14:29 -0800 (PST) Date: Sat, 1 Mar 2025 20:14:20 +0000 In-Reply-To: <20250301201424.2046477-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250301201424.2046477-1-edumazet@google.com> X-Mailer: git-send-email 2.48.1.711.g2feabab25a-goog Message-ID: <20250301201424.2046477-3-edumazet@google.com> Subject: [PATCH v2 net-next 2/6] tcp: add four drop reasons to tcp_check_req() From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni , Neal Cardwell Cc: Kuniyuki Iwashima , Simon Horman , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org Use two existing drop reasons in tcp_check_req(): - TCP_RFC7323_PAWS - TCP_OVERWINDOW Add two new ones: - TCP_RFC7323_TSECR (corresponds to LINUX_MIB_TSECRREJECTED) - TCP_LISTEN_OVERFLOW (when a listener accept queue is full) Signed-off-by: Eric Dumazet Reviewed-by: Jason Xing --- include/net/dropreason-core.h | 9 +++++++++ net/ipv4/tcp_minisocks.c | 10 ++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h index 32a34dfe8cc58fb1afda8922a52249080f1183b5..e4fdc6b54ceffe9b225e613f739c089f3077d3ab 100644 --- a/include/net/dropreason-core.h +++ b/include/net/dropreason-core.h @@ -40,6 +40,8 @@ FN(TCP_OFOMERGE) \ FN(TCP_RFC7323_PAWS) \ FN(TCP_RFC7323_PAWS_ACK) \ + FN(TCP_RFC7323_TSECR) \ + FN(TCP_LISTEN_OVERFLOW) \ FN(TCP_OLD_SEQUENCE) \ FN(TCP_INVALID_SEQUENCE) \ FN(TCP_INVALID_ACK_SEQUENCE) \ @@ -281,6 +283,13 @@ enum skb_drop_reason { * Corresponds to LINUX_MIB_PAWS_OLD_ACK. */ SKB_DROP_REASON_TCP_RFC7323_PAWS_ACK, + /** + * @SKB_DROP_REASON_TCP_RFC7323_TSECR: PAWS check, invalid TSEcr. + * Corresponds to LINUX_MIB_TSECRREJECTED. + */ + SKB_DROP_REASON_TCP_RFC7323_TSECR, + /** @SKB_DROP_REASON_TCP_LISTEN_OVERFLOW: listener queue full. */ + SKB_DROP_REASON_TCP_LISTEN_OVERFLOW, /** @SKB_DROP_REASON_TCP_OLD_SEQUENCE: Old SEQ field (duplicate packet) */ SKB_DROP_REASON_TCP_OLD_SEQUENCE, /** @SKB_DROP_REASON_TCP_INVALID_SEQUENCE: Not acceptable SEQ field */ diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 46c86c4f80e9f450834c72f28e3d16b0cffbbd1d..ba4a5d7f251d8ed093b38155d9b1a9f50bfcfe32 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -809,10 +809,15 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, LINUX_MIB_TCPACKSKIPPEDSYNRECV, &tcp_rsk(req)->last_oow_ack_time)) req->rsk_ops->send_ack(sk, skb, req); - if (paws_reject) + if (paws_reject) { + SKB_DR_SET(*drop_reason, TCP_RFC7323_PAWS); NET_INC_STATS(sock_net(sk), LINUX_MIB_PAWSESTABREJECTED); - else if (tsecr_reject) + } else if (tsecr_reject) { + SKB_DR_SET(*drop_reason, TCP_RFC7323_TSECR); NET_INC_STATS(sock_net(sk), LINUX_MIB_TSECRREJECTED); + } else { + SKB_DR_SET(*drop_reason, TCP_OVERWINDOW); + } return NULL; } @@ -882,6 +887,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, return inet_csk_complete_hashdance(sk, child, req, own_req); listen_overflow: + SKB_DR_SET(*drop_reason, TCP_LISTEN_OVERFLOW); if (sk != req->rsk_listener) __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMIGRATEREQFAILURE); From patchwork Sat Mar 1 20:14:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13997667 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f202.google.com (mail-qt1-f202.google.com [209.85.160.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AEAE51E8837 for ; Sat, 1 Mar 2025 20:14:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740860073; cv=none; b=WzmRXS5hxgLGfLRP+nP+yPQzNR3L1w7MzgnSJF12YJpX14O8KvzA64qrGWA+XMWUd/9sHvJ2mQ9Sk8GjxA2wWOFPF4BRrjHg4L3x6sar1MhA8oLiJXD0aVJ0vyCcWS63rlg2xB87C9LdemdW4L8HkR0NFmzvDkkdjPUauI/UYjU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740860073; c=relaxed/simple; bh=jJEg6DPCUrCdloRmhIEpIIn3TlheT8iOCqKCFwjnDNY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=iCE7CIEFOhbiJMwL6Gg3r5evhknL4Z5hVI+Pi28FjCo+OSPeBlMuFHnyIkdQOEFSq5KO6YCg9FFh1L3QFEQWu4p8YpZ7/L+5ROvvcwfo433mKcWEkE//jWHuJVv98ltC+Ubxzt0qjwljCqoUmvi5cCxAKx4U5+4UwhEiMT7qNYQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=L0LeM8eg; arc=none smtp.client-ip=209.85.160.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="L0LeM8eg" Received: by mail-qt1-f202.google.com with SMTP id d75a77b69052e-474bb848a7dso31264241cf.2 for ; Sat, 01 Mar 2025 12:14:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1740860070; x=1741464870; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=m3Gyz5Irr4onbWnuRNrk3cSUnmfOdTGAT+oq3uDi84M=; b=L0LeM8egyKA5QLjMdvkq6Lf0zl45FehMG8Kz6Chny0+tbn6PLp17UNfMC/E3Ih70XZ O/lKc1cLts/NuGMf5h54glWAazF0TmgYEcXpI5iUZ+HEz3oPSJmEMrlwmK/TwOt7+0yL ObUIukNTqJAetU13d0ur/doYRNTKk4WBEGs6DcCtI8Q4Pc6uIZKodM3dYRFIHdbslrbI wrH8ORXGIKYzEbDmfagk+giaUSnjslLmvq75itoWh15/mTSCMsVh5ZSM8oPQpoHCMmlE n0L93Ix16hg06Yth6jWmrsDC2bqcq1BpCFLFmYLGFq+OVSwBWcpNcidtu2ep2Jhh/Cvi YFMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740860070; x=1741464870; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=m3Gyz5Irr4onbWnuRNrk3cSUnmfOdTGAT+oq3uDi84M=; b=oFkQwYQGXVJFSkMcXrhiXgp2uDWRWEDAqwk2t8Kv0aCOFXZviKo4iAt4zUxX5EdT38 N8aXl0FSm6pJWmXlvt7RDFqJXqLoFK0HJ6R0pIsjmuxxwevg3tvr9SD98CSFHTc3TGY/ LLLzEsJfXOOBHDnBXU8YhKw9g+YJ8Cmjp1jcsye2B/4eE4hPr1F5I9vXLI/jimot6/qs B+sBfBNv/jQDJ6sFUWIK2rRYnarpQmkvajlTHOEA6MPiwZYZj0btb3GRn5alUGEzLRXo 9AoemJmzLlVpYLW4jobidzFtW05prcuCXu4W43HpUs7DNdI0mQoDWxzmhuIU2vYL9kVG GCvg== X-Forwarded-Encrypted: i=1; AJvYcCU/bb6GW1+qwEFSe39vJxUDPJH9kjDVB7QWay+9Ip0lsMEJWUcQ6Mdx4qwT7O/9DqBpN4V2RD4=@vger.kernel.org X-Gm-Message-State: AOJu0YyZT87dIOx7L9RmPmhDbjX8J7s86yrqzaHPL/2aNo/zHOsNMnix rewQfe+aQiNZLajr/OxLNjl4kwnEMUWLzTs5VcOhWjIJaguiYuEDkNul0XbdD81J0API/qwqgEQ x5dX+qVzp+g== X-Google-Smtp-Source: AGHT+IEHnIXAq5bw35LGECvPIokxcE1X1dEF9irvFqmAS3DdIBHluGiYgfL82FO7Q7ZXXLAwdboKAtMq2urjlw== X-Received: from qtbbq12.prod.google.com ([2002:a05:622a:1c0c:b0:471:f86c:c303]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:ac8:5751:0:b0:471:c962:11da with SMTP id d75a77b69052e-474bc0a1fc6mr125657141cf.27.1740860070654; Sat, 01 Mar 2025 12:14:30 -0800 (PST) Date: Sat, 1 Mar 2025 20:14:21 +0000 In-Reply-To: <20250301201424.2046477-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250301201424.2046477-1-edumazet@google.com> X-Mailer: git-send-email 2.48.1.711.g2feabab25a-goog Message-ID: <20250301201424.2046477-4-edumazet@google.com> Subject: [PATCH v2 net-next 3/6] tcp: convert to dev_net_rcu() From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni , Neal Cardwell Cc: Kuniyuki Iwashima , Simon Horman , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org TCP uses of dev_net() are under RCU protection, change them to dev_net_rcu() to get LOCKDEP support. Signed-off-by: Eric Dumazet Reviewed-by: Kuniyuki Iwashima --- include/net/inet6_hashtables.h | 2 +- include/net/inet_hashtables.h | 2 +- net/ipv4/tcp_ipv4.c | 12 ++++++------ net/ipv4/tcp_metrics.c | 6 +++--- net/ipv6/tcp_ipv6.c | 22 +++++++++++----------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h index 74dd90ff5f129fe4c8adad67a642ae5070410518..c32878c69179dac5a7fcfa098a297420d9adfab2 100644 --- a/include/net/inet6_hashtables.h +++ b/include/net/inet6_hashtables.h @@ -150,7 +150,7 @@ static inline struct sock *__inet6_lookup_skb(struct inet_hashinfo *hashinfo, int iif, int sdif, bool *refcounted) { - struct net *net = dev_net(skb_dst(skb)->dev); + struct net *net = dev_net_rcu(skb_dst(skb)->dev); const struct ipv6hdr *ip6h = ipv6_hdr(skb); struct sock *sk; diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h index 5eea47f135a421ce8275d4cd83c5771b3f448e5c..da818fb0205fed6b4120946bc032e67e046b716f 100644 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h @@ -492,7 +492,7 @@ static inline struct sock *__inet_lookup_skb(struct inet_hashinfo *hashinfo, const int sdif, bool *refcounted) { - struct net *net = dev_net(skb_dst(skb)->dev); + struct net *net = dev_net_rcu(skb_dst(skb)->dev); const struct iphdr *iph = ip_hdr(skb); struct sock *sk; diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 218f01a8cc5f6c410043f07293e9e51840c1f1cb..ae07613e4f335063723f49d7fd70a240412922ef 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -494,14 +494,14 @@ int tcp_v4_err(struct sk_buff *skb, u32 info) { const struct iphdr *iph = (const struct iphdr *)skb->data; struct tcphdr *th = (struct tcphdr *)(skb->data + (iph->ihl << 2)); - struct tcp_sock *tp; + struct net *net = dev_net_rcu(skb->dev); const int type = icmp_hdr(skb)->type; const int code = icmp_hdr(skb)->code; - struct sock *sk; struct request_sock *fastopen; + struct tcp_sock *tp; u32 seq, snd_una; + struct sock *sk; int err; - struct net *net = dev_net(skb->dev); sk = __inet_lookup_established(net, net->ipv4.tcp_death_row.hashinfo, iph->daddr, th->dest, iph->saddr, @@ -786,7 +786,7 @@ static void tcp_v4_send_reset(const struct sock *sk, struct sk_buff *skb, arg.iov[0].iov_base = (unsigned char *)&rep; arg.iov[0].iov_len = sizeof(rep.th); - net = sk ? sock_net(sk) : dev_net(skb_dst(skb)->dev); + net = sk ? sock_net(sk) : dev_net_rcu(skb_dst(skb)->dev); /* Invalid TCP option size or twice included auth */ if (tcp_parse_auth_options(tcp_hdr(skb), &md5_hash_location, &aoh)) @@ -1961,7 +1961,7 @@ EXPORT_SYMBOL(tcp_v4_do_rcv); int tcp_v4_early_demux(struct sk_buff *skb) { - struct net *net = dev_net(skb->dev); + struct net *net = dev_net_rcu(skb->dev); const struct iphdr *iph; const struct tcphdr *th; struct sock *sk; @@ -2172,7 +2172,7 @@ static void tcp_v4_fill_cb(struct sk_buff *skb, const struct iphdr *iph, int tcp_v4_rcv(struct sk_buff *skb) { - struct net *net = dev_net(skb->dev); + struct net *net = dev_net_rcu(skb->dev); enum skb_drop_reason drop_reason; int sdif = inet_sdif(skb); int dif = inet_iif(skb); diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c index 95669935494ef8003a1877e2b86c76bd27307afd..4251670e328c83b55eff7bbda3cc3d97d78563a8 100644 --- a/net/ipv4/tcp_metrics.c +++ b/net/ipv4/tcp_metrics.c @@ -170,7 +170,7 @@ static struct tcp_metrics_block *tcpm_new(struct dst_entry *dst, bool reclaim = false; spin_lock_bh(&tcp_metrics_lock); - net = dev_net(dst->dev); + net = dev_net_rcu(dst->dev); /* While waiting for the spin-lock the cache might have been populated * with this entry and so we have to check again. @@ -273,7 +273,7 @@ static struct tcp_metrics_block *__tcp_get_metrics_req(struct request_sock *req, return NULL; } - net = dev_net(dst->dev); + net = dev_net_rcu(dst->dev); hash ^= net_hash_mix(net); hash = hash_32(hash, tcp_metrics_hash_log); @@ -318,7 +318,7 @@ static struct tcp_metrics_block *tcp_get_metrics(struct sock *sk, else return NULL; - net = dev_net(dst->dev); + net = dev_net_rcu(dst->dev); hash ^= net_hash_mix(net); hash = hash_32(hash, tcp_metrics_hash_log); diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index d01088ab80d24eb0f829166faae791221d95bf9e..fe75ad8e606cbca77d69326dc00273e7b214edee 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -376,7 +376,7 @@ static int tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, { const struct ipv6hdr *hdr = (const struct ipv6hdr *)skb->data; const struct tcphdr *th = (struct tcphdr *)(skb->data+offset); - struct net *net = dev_net(skb->dev); + struct net *net = dev_net_rcu(skb->dev); struct request_sock *fastopen; struct ipv6_pinfo *np; struct tcp_sock *tp; @@ -866,16 +866,16 @@ static void tcp_v6_send_response(const struct sock *sk, struct sk_buff *skb, u32 int oif, int rst, u8 tclass, __be32 label, u32 priority, u32 txhash, struct tcp_key *key) { - const struct tcphdr *th = tcp_hdr(skb); - struct tcphdr *t1; - struct sk_buff *buff; - struct flowi6 fl6; - struct net *net = sk ? sock_net(sk) : dev_net(skb_dst(skb)->dev); - struct sock *ctl_sk = net->ipv6.tcp_sk; + struct net *net = sk ? sock_net(sk) : dev_net_rcu(skb_dst(skb)->dev); unsigned int tot_len = sizeof(struct tcphdr); + struct sock *ctl_sk = net->ipv6.tcp_sk; + const struct tcphdr *th = tcp_hdr(skb); __be32 mrst = 0, *topt; struct dst_entry *dst; - __u32 mark = 0; + struct sk_buff *buff; + struct tcphdr *t1; + struct flowi6 fl6; + u32 mark = 0; if (tsecr) tot_len += TCPOLEN_TSTAMP_ALIGNED; @@ -1041,7 +1041,7 @@ static void tcp_v6_send_reset(const struct sock *sk, struct sk_buff *skb, if (!sk && !ipv6_unicast_destination(skb)) return; - net = sk ? sock_net(sk) : dev_net(skb_dst(skb)->dev); + net = sk ? sock_net(sk) : dev_net_rcu(skb_dst(skb)->dev); /* Invalid TCP option size or twice included auth */ if (tcp_parse_auth_options(th, &md5_hash_location, &aoh)) return; @@ -1740,6 +1740,7 @@ static void tcp_v6_fill_cb(struct sk_buff *skb, const struct ipv6hdr *hdr, INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) { + struct net *net = dev_net_rcu(skb->dev); enum skb_drop_reason drop_reason; int sdif = inet6_sdif(skb); int dif = inet6_iif(skb); @@ -1749,7 +1750,6 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) bool refcounted; int ret; u32 isn; - struct net *net = dev_net(skb->dev); drop_reason = SKB_DROP_REASON_NOT_SPECIFIED; if (skb->pkt_type != PACKET_HOST) @@ -2001,7 +2001,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) void tcp_v6_early_demux(struct sk_buff *skb) { - struct net *net = dev_net(skb->dev); + struct net *net = dev_net_rcu(skb->dev); const struct ipv6hdr *hdr; const struct tcphdr *th; struct sock *sk; From patchwork Sat Mar 1 20:14:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13997668 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f74.google.com (mail-qv1-f74.google.com [209.85.219.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05EDD1E98FA for ; Sat, 1 Mar 2025 20:14:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740860074; cv=none; b=ex7x/LBtgZ0FrUrA06XJp3FucfSkDL+AS4UuJgjtok6IVQMAo/HveFLhUTErw/5CD0abErMEp5tnFVZF6aV1VHt4wkl2RXOsq9noiDzjPQKKWGPFnWG6/Gyb+ldOv1EgrMioV7t4BhNdBCLOaSCRN15weqU2fuBIaao6aZyDtUw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740860074; c=relaxed/simple; bh=7q3zlLijO/oYQjzipNBwgPkgkkAsvOaHy4vrp8lRFVM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mPjVbVyKjwaxWdKmwLEWHFEdYdL4c0YW0J4hu4Z/8Dft/hKOOkpb7Ig/JrjvCMO8Zp6xRVwHHve47OWFvtkKqRPBvkGwvmIOyuyGxcWfOa+k1VxNn8eNO/Qw0fykDo1IhnG9P0Z6TaL3HN1QRxOc8kxR/5S0iEKRUOfzIzc1RmE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=TjiaG3bA; arc=none smtp.client-ip=209.85.219.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="TjiaG3bA" Received: by mail-qv1-f74.google.com with SMTP id 6a1803df08f44-6e890855f09so81131536d6.2 for ; Sat, 01 Mar 2025 12:14:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1740860072; x=1741464872; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=cxw3yXkSMa6HHBMwRbpsaHbRthPBk1jXAbHh2yiBjUQ=; b=TjiaG3bAsLIsPdUl0LQl+t8+ntMnu3kE1LMnXCgiKn3SRJ2oGSNdPQRmt2JVu1kzYG iy5qoHePtqjVHxflEIeN9jmA+eJLp8yURHtllFFAptDhzfoo+OerVb5BdYlI3P4KEODR 2sPfLLD+rKuKs+S+owcZ2yaMJJR14z2CNgm3SSSUzincDTWXHomASycM7M9K4gEnEQGv UfIWR298pA8g1Pa2Gg5ofst7BiGJUkcHneVQj4SIS/XuNoShGt+tFld4Ydn/3XOcn1vr NJUJ5Mc8h+GKAtreC3bdFD/YEVpZ9OjQj/iIys+C2+/hDqR0rrlpBX4Zy20tuYZhuy0z hW+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740860072; x=1741464872; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cxw3yXkSMa6HHBMwRbpsaHbRthPBk1jXAbHh2yiBjUQ=; b=ndPXa2dXcDJd1Gk1OimVQb9Soa1sE5C2iZxcS5Z/NUROdkqbYI7T+pFauY0kevprZ5 eq7ySPaNBGS0isvmRYVsKlyHzQM7YJz1N/2VX9ejwnEmNhmpwUBR4PF0cko/Y9yHs2B5 wbgSVtyGAz/8T4fdF+lFAViDDJcfNnc9lxh7g+o9xMnMFy0cgBeCM+zVtszIu60fjdfe +C68uuGDgp86RpeKixGQhAwdfKmTpJFdTbCG0RMkLsDBTdphVM/aNTbZ9Nur71apUkgB +hKGRqCKCNzlw+DSjiaxMK0yhkMJjM9kyT+5N+201Fk34p0jVBrzgaUpLozoYwzPHTgW NrmA== X-Forwarded-Encrypted: i=1; AJvYcCUqDbRXn42Xr1VH1SuB3yq8FxIOrbw1ieCpNvFlKw4usVGN8alJTe3cMcDX1jf93FTo5bCuqps=@vger.kernel.org X-Gm-Message-State: AOJu0YxOx7wKLO348FwNSPQUPT9GDUx6EWq8OmOp49C3ajlUc6YVXGBe nR6papslfUWsLwhxmspdYSbtXcSVRs1xCtMGezvJjLzPvKznytGS6JWZse8uh1ctmupSCVIfoCe DOuBYx4Fb4Q== X-Google-Smtp-Source: AGHT+IHk5KQsx8H4DHSpfFcl0ve7q7RrH5QQCsAdaOZx72o3A1p9+FsEZ21vnOE/tkzWbvyvKaXoFUOLYB1T4A== X-Received: from qvon13.prod.google.com ([2002:a0c:e94d:0:b0:6e8:8e6a:2863]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:ad4:5ba3:0:b0:6d8:ab7e:e554 with SMTP id 6a1803df08f44-6e8a0d84b59mr120538656d6.34.1740860071969; Sat, 01 Mar 2025 12:14:31 -0800 (PST) Date: Sat, 1 Mar 2025 20:14:22 +0000 In-Reply-To: <20250301201424.2046477-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250301201424.2046477-1-edumazet@google.com> X-Mailer: git-send-email 2.48.1.711.g2feabab25a-goog Message-ID: <20250301201424.2046477-5-edumazet@google.com> Subject: [PATCH v2 net-next 4/6] net: gro: convert four dev_net() calls From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni , Neal Cardwell Cc: Kuniyuki Iwashima , Simon Horman , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org tcp4_check_fraglist_gro(), tcp6_check_fraglist_gro(), udp4_gro_lookup_skb() and udp6_gro_lookup_skb() assume RCU is held so that the net structure does not disappear. Use dev_net_rcu() instead of dev_net() to get LOCKDEP support. Signed-off-by: Eric Dumazet Reviewed-by: Kuniyuki Iwashima --- net/ipv4/tcp_offload.c | 2 +- net/ipv4/udp_offload.c | 2 +- net/ipv6/tcpv6_offload.c | 2 +- net/ipv6/udp_offload.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c index 2308665b51c5388814e5b61a262a1636d897c4a9..ecef16c58c07146cbeebade0620a5ec7251ddbc5 100644 --- a/net/ipv4/tcp_offload.c +++ b/net/ipv4/tcp_offload.c @@ -425,7 +425,7 @@ static void tcp4_check_fraglist_gro(struct list_head *head, struct sk_buff *skb, inet_get_iif_sdif(skb, &iif, &sdif); iph = skb_gro_network_header(skb); - net = dev_net(skb->dev); + net = dev_net_rcu(skb->dev); sk = __inet_lookup_established(net, net->ipv4.tcp_death_row.hashinfo, iph->saddr, th->source, iph->daddr, ntohs(th->dest), diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c index a5be6e4ed326fbdc6a9b3889db4da903f7f25d37..c1a85b300ee87758ee683a834248a600a3e7f18d 100644 --- a/net/ipv4/udp_offload.c +++ b/net/ipv4/udp_offload.c @@ -630,7 +630,7 @@ static struct sock *udp4_gro_lookup_skb(struct sk_buff *skb, __be16 sport, __be16 dport) { const struct iphdr *iph = skb_gro_network_header(skb); - struct net *net = dev_net(skb->dev); + struct net *net = dev_net_rcu(skb->dev); int iif, sdif; inet_get_iif_sdif(skb, &iif, &sdif); diff --git a/net/ipv6/tcpv6_offload.c b/net/ipv6/tcpv6_offload.c index a45bf17cb2a172d4612cb42f51481b97bbf364cd..91b88daa5b555cb1af591db7680b7d829ce7b1b7 100644 --- a/net/ipv6/tcpv6_offload.c +++ b/net/ipv6/tcpv6_offload.c @@ -35,7 +35,7 @@ static void tcp6_check_fraglist_gro(struct list_head *head, struct sk_buff *skb, inet6_get_iif_sdif(skb, &iif, &sdif); hdr = skb_gro_network_header(skb); - net = dev_net(skb->dev); + net = dev_net_rcu(skb->dev); sk = __inet6_lookup_established(net, net->ipv4.tcp_death_row.hashinfo, &hdr->saddr, th->source, &hdr->daddr, ntohs(th->dest), diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c index b41152dd424697a9fc3cef13fbb430de49dcb913..404212dfc99abba4d48fc27a574b48ab53731d39 100644 --- a/net/ipv6/udp_offload.c +++ b/net/ipv6/udp_offload.c @@ -117,7 +117,7 @@ static struct sock *udp6_gro_lookup_skb(struct sk_buff *skb, __be16 sport, __be16 dport) { const struct ipv6hdr *iph = skb_gro_network_header(skb); - struct net *net = dev_net(skb->dev); + struct net *net = dev_net_rcu(skb->dev); int iif, sdif; inet6_get_iif_sdif(skb, &iif, &sdif); From patchwork Sat Mar 1 20:14:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13997669 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f201.google.com (mail-qt1-f201.google.com [209.85.160.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 868851E9919 for ; Sat, 1 Mar 2025 20:14:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740860076; cv=none; b=TuD54UUTHBuaoC20ug0Qsbt6cCkZDBj319cgAlsIQK8IwE9c4pgLxA3ZVwUXZwU18Lxl4rghdTuHrNVYKiU/46KddT11tmCGy8QKiH3pSklaFY/4IRk12NL8WyX/xPHqk4fM7jvQKfERoPTQpGj++1+Vwh5WFIjMWSl68HQC+AM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740860076; c=relaxed/simple; bh=7cS9lozPjGK6CJDB0rbF/JsDu7ljNWKuNdAb8/+05tc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=CLCmnP2LesQpVm+jJHgIzStwyrfv4b+UDPG+hH+pYTNslOjIyJlGGi0BWF7NhRz3PXLtEb67uty3AdTZ9xebALD1N1DSEyqlJxhhrzrtZ0oMB3lfvbB0kixPWJSRdJlVHBNFxD61LDPrCevfhG5ra/zD+KFVm69BdZvHs9fm7UM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=APKo3r/n; arc=none smtp.client-ip=209.85.160.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="APKo3r/n" Received: by mail-qt1-f201.google.com with SMTP id d75a77b69052e-474bb848a7dso31264581cf.2 for ; Sat, 01 Mar 2025 12:14:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1740860073; x=1741464873; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=OOQFszIdy08TjK2quwg21U1oq4H1pENWDe9muSGOA0Q=; b=APKo3r/niw5Pc1DGAgmlru79ILxyIXLnyAcfMwedOWo3K72yvV79eYwWhZBTgtPrFP q1Vh8RYcIUiU5xqhxkMQodguOoTMn8RlnW4Ps4o8OD+PXqCMUirBL44YUCY0oJBIc5y/ C9lYjNppsiPF1LTGsAeXnSmT24SJ7MH1BO176GBhyF4OBBNNeLNcnVbuuLACBAtzP7sG +2rMj/4mGflkel2Zj2SSdHjGD8qlE8ZczZ3pxfQhrIAA9R/VlJXXAdqFHtpJ27MYFa89 YoRJnzdZBVN8VG5l1al29Rz5LUa7zxj3c/tRcEvIi0wMoMDcLSfQ5tDLwB+Vr1YtzeeK bsIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740860073; x=1741464873; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OOQFszIdy08TjK2quwg21U1oq4H1pENWDe9muSGOA0Q=; b=n5Lso3akzwWh8gtjO3QffvU2I3W6CcAXXuYSTidYUq8YWICZGHaYvMLMUyfGATKdNo eEbsMejKqpDZCB8Jv4hf1YsQzJZGVCaDstzta3CL8TxzeX6O2IoqqkUkdHy1Zt2SA8Kv 9mpeQWsHD4W9WfI3PfeuDykDCgqoJ01we8O0Zarp/m/EO0qL7qLKSLITnHhiH7liX3sf HeIW+f3Q38Bio/pjYm/pzGBBDmPpmTSyuHqQcc0mTTQWxrWiknFGUF5gqkcgdzyWCkxb Y/YVoAOFFyQuJAEA6xmpHtVPlUc8FDBphIqOu7XtM1Vp0L6gcMezlTtEsyu0ub7EEpNM 3psQ== X-Forwarded-Encrypted: i=1; AJvYcCUs7EIlEMhK8FgRg27i6kGainxFSvKm+UCwdghwbBneFEIrzVKGFQDlhRkAPBLS3IbDjJADspc=@vger.kernel.org X-Gm-Message-State: AOJu0Yy/NHVZ2PmeW6RuQ7EOdMqq3DnnZYYHjq8NxgZyhj2w1dgSXGXW zRrmJLgWf3Fqmlsxhp9zQmXhfX4YMvBprY5MNa/c1gwDDcd0WJWbfqhphTeK/Qg8bJiHJp4qusp c07aKFuSKxw== X-Google-Smtp-Source: AGHT+IGHvWH8RAS04QJKH7uyftTIwgEbKtMLkkxJHt3dTP0m/GS+sHIp/WmC/tXyHh0MYH1LiIv+ragXUueq9w== X-Received: from qtbfg15.prod.google.com ([2002:a05:622a:580f:b0:471:f334:1108]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:a05:622a:1108:b0:472:1e5:d577 with SMTP id d75a77b69052e-474bc10d546mr127083941cf.49.1740860073471; Sat, 01 Mar 2025 12:14:33 -0800 (PST) Date: Sat, 1 Mar 2025 20:14:23 +0000 In-Reply-To: <20250301201424.2046477-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250301201424.2046477-1-edumazet@google.com> X-Mailer: git-send-email 2.48.1.711.g2feabab25a-goog Message-ID: <20250301201424.2046477-6-edumazet@google.com> Subject: [PATCH v2 net-next 5/6] tcp: remove READ_ONCE(req->ts_recent) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni , Neal Cardwell Cc: Kuniyuki Iwashima , Simon Horman , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet , Wang Hai X-Patchwork-Delegate: kuba@kernel.org After commit 8d52da23b6c6 ("tcp: Defer ts_recent changes until req is owned"), req->ts_recent is not changed anymore. It is set once in tcp_openreq_init(), bpf_sk_assign_tcp_reqsk() or cookie_tcp_reqsk_alloc() before the req can be seen by other cpus/threads. This completes the revert of eba20811f326 ("tcp: annotate data-races around tcp_rsk(req)->ts_recent"). Signed-off-by: Eric Dumazet Cc: Wang Hai Reviewed-by: Jason Xing --- net/ipv4/tcp_ipv4.c | 2 +- net/ipv4/tcp_minisocks.c | 4 ++-- net/ipv4/tcp_output.c | 2 +- net/ipv6/tcp_ipv6.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index ae07613e4f335063723f49d7fd70a240412922ef..d9405b012dff079f7cafd9d422ff4445a27eb064 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1155,7 +1155,7 @@ static void tcp_v4_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb, tcp_rsk(req)->rcv_nxt, tcp_synack_window(req) >> inet_rsk(req)->rcv_wscale, tcp_rsk_tsval(tcp_rsk(req)), - READ_ONCE(req->ts_recent), + req->ts_recent, 0, &key, inet_rsk(req)->no_srccheck ? IP_REPLY_ARG_NOSRCCHECK : 0, ip_hdr(skb)->tos, diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index ba4a5d7f251d8ed093b38155d9b1a9f50bfcfe32..3cb8f281186b205e2b03d1b78e1750a024b94f6a 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -585,7 +585,7 @@ struct sock *tcp_create_openreq_child(const struct sock *sk, if (newtp->rx_opt.tstamp_ok) { newtp->tcp_usec_ts = treq->req_usec_ts; - newtp->rx_opt.ts_recent = READ_ONCE(req->ts_recent); + newtp->rx_opt.ts_recent = req->ts_recent; newtp->rx_opt.ts_recent_stamp = ktime_get_seconds(); newtp->tcp_header_len = sizeof(struct tcphdr) + TCPOLEN_TSTAMP_ALIGNED; } else { @@ -673,7 +673,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, tcp_parse_options(sock_net(sk), skb, &tmp_opt, 0, NULL); if (tmp_opt.saw_tstamp) { - tmp_opt.ts_recent = READ_ONCE(req->ts_recent); + tmp_opt.ts_recent = req->ts_recent; if (tmp_opt.rcv_tsecr) { if (inet_rsk(req)->tstamp_ok && !fastopen) tsecr_reject = !between(tmp_opt.rcv_tsecr, diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 0a660075add5bea05a61b4fe2d9d334a89d956a7..24e56bf96747253c1a508ddfe27ebd38da7c219e 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -949,7 +949,7 @@ static unsigned int tcp_synack_options(const struct sock *sk, tcp_rsk(req)->snt_tsval_first = opts->tsval; } WRITE_ONCE(tcp_rsk(req)->snt_tsval_last, opts->tsval); - opts->tsecr = READ_ONCE(req->ts_recent); + opts->tsecr = req->ts_recent; remaining -= TCPOLEN_TSTAMP_ALIGNED; } if (likely(ireq->sack_ok)) { diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index fe75ad8e606cbca77d69326dc00273e7b214edee..85c4820bfe1588e4553784129d13408dea70763a 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -1279,7 +1279,7 @@ static void tcp_v6_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb, tcp_rsk(req)->rcv_nxt, tcp_synack_window(req) >> inet_rsk(req)->rcv_wscale, tcp_rsk_tsval(tcp_rsk(req)), - READ_ONCE(req->ts_recent), sk->sk_bound_dev_if, + req->ts_recent, sk->sk_bound_dev_if, &key, ipv6_get_dsfield(ipv6_hdr(skb)), 0, READ_ONCE(sk->sk_priority), READ_ONCE(tcp_rsk(req)->txhash)); From patchwork Sat Mar 1 20:14:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13997670 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f74.google.com (mail-qv1-f74.google.com [209.85.219.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3392B1E8320 for ; Sat, 1 Mar 2025 20:14:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740860077; cv=none; b=h65vdXPx41GpjKjpmxEmgncDuboi0Ip/bmusgf/x14wFL3L6uvA4nhIuqZea/m/rY2ykKQd3Kgu9UbvBj1SQecAuDpXLVM3gBZpoxU2FsMX8kGlviclOuuZniWjeZr93fk8YU1FGnB0i1wqUaUj8clzvRQewuZX/+X6++8G5fBE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740860077; c=relaxed/simple; bh=FTYAPGA3SjXYPOXqynWOP8ZK5fmOsZH0A+0ezoAF2ic=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=R4kScBxEMgUpUUaKoYnEdg1ibLHqK/+KDvY8gB+ehGKnCYiVUkuwZrkk0QqGX5jaLbYBLJP+qSU/Dq9Gg2gj4USNno6ZWkGYsSClxYT3EwOXXY7RRGudpIeFQWk6FD0izAfydzpsz0D603WjupuzO/XYs3itvdIVDF49TC+igU0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=iH1ae+D4; arc=none smtp.client-ip=209.85.219.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="iH1ae+D4" Received: by mail-qv1-f74.google.com with SMTP id 6a1803df08f44-6e67c58f0f7so39751686d6.3 for ; Sat, 01 Mar 2025 12:14:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1740860075; x=1741464875; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=4n0xFPxK7p0S/n7CVqaTwUqyGjTiJKBUlxqkm44laGU=; b=iH1ae+D4+1SESWaSUWbRepfctLzamfN87ZnXM0Mvanq4jN9LPk+cF2mpKj80p6hTAC CxXy9driMx/W9HVDCKPKm5Y8s3pxjvMGr/5n+7696DsuBFTVL546LCybspFMZfyZbidb AkyjSglnm2D3JXUyitavHpRL5887rcHtmRak5k0DaP7IWJ4DLY0hUIsdEtOUw0uKI7R5 h9Nq3Fw6kKbdT0MQUfMLcAU6MdaUtMKVBdTm8LF527uIzkwEDvMH4/LJbOGxCa+S/yfO ABsQXAaJ9wPdFvKr/cxzIRlIlt7wNhdL+IBQdd9Hj2UDOO3mX72d0jew/n42Y9PVhYDB IZCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740860075; x=1741464875; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4n0xFPxK7p0S/n7CVqaTwUqyGjTiJKBUlxqkm44laGU=; b=qGQqtNBRMl88GNOdk88+9UPf2X8QrBYM/RhOqwDX/PlrwHPwaypoN5hTLQEGYLvb+Z Gx3/0FKaM8ccbFf7x1THpnRHcJg+Iz+LgYFaF5IsaPPi31sQRa34sS3TgLVsySre6yTy 3DOGyVf1dgnm8kXr7lOktdtkKqsoTMJxNKqTryyM3MKMtNKSYlVl9ehMNwaJbaBO9xzx dXARQEe0e31t6JM5HoaIb70+XH5yRhiJaHi7s7yn/LtIKn+JcLlqlv6fTApvuWg2Vu13 YRO9fp3gtbUFzr+IhaJjMJ3LyjRfC93I91BC3EcOJEBF4eP12OIHmxzovaDmzZ3gv//V xb8Q== X-Forwarded-Encrypted: i=1; AJvYcCXxYoRDMsu1uMx2mo6u4ZpiMis6qp2LX/Ax5oUvM9FPMVmYrG7vSVgSoWmw7YtX20+GvyXlgEk=@vger.kernel.org X-Gm-Message-State: AOJu0YzaXrBopHh413ilUB61TAZxYRrWE5lzuGpWSAaONAiOr8LGnflj Gl7/8H+i0YSMLubpcK6b8ScN23U99BWwaGHYQz+IKnXgM0xhIskwiiYnpwNCjk1uXD4ZrNpTzaU ts9fLDQwb/g== X-Google-Smtp-Source: AGHT+IEDkr1bl3B/kKUnYskkcqQj/VfPBzV6Ga8sg/OqcIl2IQ19mzG4BrRxMkx9vgKIgeByqxqFguVI7Fzr5A== X-Received: from qvop5.prod.google.com ([2002:a0c:fac5:0:b0:6e6:5f0e:8032]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:ad4:5cad:0:b0:6e4:2f7f:d0bb with SMTP id 6a1803df08f44-6e8a0cccae9mr128294576d6.4.1740860075167; Sat, 01 Mar 2025 12:14:35 -0800 (PST) Date: Sat, 1 Mar 2025 20:14:24 +0000 In-Reply-To: <20250301201424.2046477-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250301201424.2046477-1-edumazet@google.com> X-Mailer: git-send-email 2.48.1.711.g2feabab25a-goog Message-ID: <20250301201424.2046477-7-edumazet@google.com> Subject: [PATCH v2 net-next 6/6] tcp: tcp_set_window_clamp() cleanup From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni , Neal Cardwell Cc: Kuniyuki Iwashima , Simon Horman , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org Remove one indentation level. Use max_t() and clamp() macros. Signed-off-by: Eric Dumazet Reviewed-by: Jason Xing --- net/ipv4/tcp.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 1184866922130aff0f4a4e6d5c0d95fd42713b7d..eb5a60c7a9ccdd23fb78a74d614c18c4f7e281c9 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3693,33 +3693,33 @@ EXPORT_SYMBOL(tcp_sock_set_keepcnt); int tcp_set_window_clamp(struct sock *sk, int val) { + u32 old_window_clamp, new_window_clamp; struct tcp_sock *tp = tcp_sk(sk); if (!val) { if (sk->sk_state != TCP_CLOSE) return -EINVAL; WRITE_ONCE(tp->window_clamp, 0); - } else { - u32 new_rcv_ssthresh, old_window_clamp = tp->window_clamp; - u32 new_window_clamp = val < SOCK_MIN_RCVBUF / 2 ? - SOCK_MIN_RCVBUF / 2 : val; + return 0; + } - if (new_window_clamp == old_window_clamp) - return 0; + old_window_clamp = tp->window_clamp; + new_window_clamp = max_t(int, SOCK_MIN_RCVBUF / 2, val); - WRITE_ONCE(tp->window_clamp, new_window_clamp); - if (new_window_clamp < old_window_clamp) { - /* need to apply the reserved mem provisioning only - * when shrinking the window clamp - */ - __tcp_adjust_rcv_ssthresh(sk, tp->window_clamp); + if (new_window_clamp == old_window_clamp) + return 0; - } else { - new_rcv_ssthresh = min(tp->rcv_wnd, tp->window_clamp); - tp->rcv_ssthresh = max(new_rcv_ssthresh, - tp->rcv_ssthresh); - } - } + WRITE_ONCE(tp->window_clamp, new_window_clamp); + + /* Need to apply the reserved mem provisioning only + * when shrinking the window clamp. + */ + if (new_window_clamp < old_window_clamp) + __tcp_adjust_rcv_ssthresh(sk, new_window_clamp); + else + tp->rcv_ssthresh = clamp(new_window_clamp, + tp->rcv_ssthresh, + tp->rcv_wnd); return 0; }