From patchwork Tue Feb 13 14:05:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13555150 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) (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 421C556766 for ; Tue, 13 Feb 2024 14:06:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707833166; cv=none; b=SC5KGqJHTo5ftOIZr+5VCbjJ3vam4634wd+RbK7C4V/pk3emKM0H4NRAwkfICT1igP94hNI4JRs8a4rQ433y5Kw1GpSgHswtjPIoUOvYM0Ytf857taglVEbW7FesrKFrLfH64izdCyT48A9y9FVuVpYQFkbmZMlRplcmJRFhLho= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707833166; c=relaxed/simple; bh=pM03emsOdnkfRw0YpBGJfKaeWaExAlzFZjMO02xyVas=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nSJl2CkLYiwOb04E7c8MpO0GwA9gL/EKYl/4nSreqh4VEOG5iZvQuSxkgKTFP8pAg69Gi7LbwQzzvjjUH7iqoSCU7Bqr9siIBtbZl2UHPJUtODJIzDhmyKoAjl1aO3BGwjLkgCEsLECNCDwCHOajpuxKOBIh8nWyEkHElQmNU/4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lXVwt6IR; arc=none smtp.client-ip=209.85.166.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lXVwt6IR" Received: by mail-il1-f171.google.com with SMTP id e9e14a558f8ab-36423c819a3so588605ab.0 for ; Tue, 13 Feb 2024 06:06:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707833164; x=1708437964; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=N+qlEv3zkbEchZFcQWVopUaH0qwicWIrROaQiuqCVLg=; b=lXVwt6IRaIczTIlxP0bi+ThOkqHzyqsJaw4BxACXySSl7L7rVzEkMb+HnyYJxgDLRA iqpvV/jXbt1+GD1O191R2qfVTdVc7RXaTRPBj+CruFuhodTqdQM7GOvLxFbBsltNQ16U hb1YLPO3njpAr96CSAi05jSWv5Pdk+Snvqqx8GRKzkrI10SRJ8TwtWExQXR57Q9TyQCA Cf8rG0beTDJMDgY8xqcldBtoUK4kjWSwLTH8FXvE2C+hlQJWEqUYjjYg80uxOlVu2Q+f 7vI/f3+IXJPlbUq4Ncz2oMhaNvOdCddrkv6TiNhp0XDaBgTzqBlOfIcm8OT8+686dE/J kIqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707833164; x=1708437964; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N+qlEv3zkbEchZFcQWVopUaH0qwicWIrROaQiuqCVLg=; b=ny3OOBl2WOFu6cEEDAtfXXnmrF3K0gwwHe6bbS5wnkDbc1baUtVsK3H7xEBYZxLfPt /tm7o8lxkQcufORqqP6UbeKiSTFAw5wSTS6yjeoFEmjRo9T9fWUyo57MqbcaIWzSzxYN rnd962FgmK7qpkIWa/f8rq1yNCW0+BWV7mtao9EM1CDDl1ooFgmuLx6BsMBNOkFAsjYO Zzp4JV3PMLqhLhTuV56Z56BN0vwhCXUHyjD+tB19Sh1FrBu+xt94oPtKrGM1m47fF1Hy 7KJjVHG1iLHi1/PQtepLB0HgR5KGlHCQ7xqSmI/uMzFbBLEZTnspqxuDnci5bW81cS/C tVSg== X-Gm-Message-State: AOJu0YxG4pjVyhhbIdGZmSu3dnZFxawfBEBjB+XWthB5+xjLSwe/ProE 0mHpkgwAPyuZzP1sBib00ZAkQBiGCigpmOgnW2nlco8XajBMrCR5 X-Google-Smtp-Source: AGHT+IEHRyLVMJYDmI98jn6B+r4bkGBdv01y5QoVcEfhfaXnlzs4vqwvMSX+NyuqBUHLAToVV1aA/A== X-Received: by 2002:a92:c902:0:b0:363:d7c9:8189 with SMTP id t2-20020a92c902000000b00363d7c98189mr9445370ilp.20.1707833164275; Tue, 13 Feb 2024 06:06:04 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXqZ64rY4u1Rc4Y2tqxfVG9jh4+kl8+NQ64A28EwGgGQ+YkOIP+czldvL4fFyUmG9x/nmkB3Pyk4z0nsKi6PEQ8m4G0ud119ObZq41gwgCk4jkfFDFVSGpXgabx9mqPJJ5M7Rqy8UpcaxmqOLApn7qKaPB9Rozq+RQZAecVPb9xm1YIt3KJnJU0hamD/AyzbM4dPoj1WYbWn6r0fNgi9PXOCG6ZiPbNJGldo06TTPwPO+vXI6qht6iKW0RU1DYG9Pxh Received: from KERNELXING-MB0.tencent.com ([14.108.143.251]) by smtp.gmail.com with ESMTPSA id q19-20020a632a13000000b005dc8702f0a9sm1306247pgq.1.2024.02.13.06.06.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 06:06:03 -0800 (PST) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org, kuniyu@amazon.com Cc: netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v4 1/6] tcp: introduce another three dropreasons in receive path Date: Tue, 13 Feb 2024 22:05:03 +0800 Message-Id: <20240213140508.10878-2-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240213140508.10878-1-kerneljasonxing@gmail.com> References: <20240213140508.10878-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing Soon later patches can use these relatively more accurate reasons to recognise and find out the cause. Signed-off-by: Jason Xing --- include/net/dropreason-core.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h index 065caba42b0b..19ba900eae0e 100644 --- a/include/net/dropreason-core.h +++ b/include/net/dropreason-core.h @@ -31,6 +31,7 @@ FN(TCP_AOFAILURE) \ FN(SOCKET_BACKLOG) \ FN(TCP_FLAGS) \ + FN(TCP_ABORTONDATA) \ FN(TCP_ZEROWINDOW) \ FN(TCP_OLD_DATA) \ FN(TCP_OVERWINDOW) \ @@ -38,6 +39,7 @@ FN(TCP_RFC7323_PAWS) \ FN(TCP_OLD_SEQUENCE) \ FN(TCP_INVALID_SEQUENCE) \ + FN(TCP_INVALID_ACK_SEQUENCE) \ FN(TCP_RESET) \ FN(TCP_INVALID_SYN) \ FN(TCP_CLOSE) \ @@ -207,6 +209,11 @@ enum skb_drop_reason { SKB_DROP_REASON_SOCKET_BACKLOG, /** @SKB_DROP_REASON_TCP_FLAGS: TCP flags invalid */ SKB_DROP_REASON_TCP_FLAGS, + /** + * @SKB_DROP_REASON_TCP_ABORTONDATA: abort on data, corresponding to + * LINUX_MIB_TCPABORTONDATA + */ + SKB_DROP_REASON_TCP_ABORTONDATA, /** * @SKB_DROP_REASON_TCP_ZEROWINDOW: TCP receive window size is zero, * see LINUX_MIB_TCPZEROWINDOWDROP @@ -231,13 +238,19 @@ enum skb_drop_reason { SKB_DROP_REASON_TCP_OFOMERGE, /** * @SKB_DROP_REASON_TCP_RFC7323_PAWS: PAWS check, corresponding to - * LINUX_MIB_PAWSESTABREJECTED + * LINUX_MIB_PAWSESTABREJECTED, LINUX_MIB_PAWSACTIVEREJECTED */ SKB_DROP_REASON_TCP_RFC7323_PAWS, /** @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 */ SKB_DROP_REASON_TCP_INVALID_SEQUENCE, + /** + * @SKB_DROP_REASON_TCP_INVALID_ACK_SEQUENCE: Not acceptable ACK SEQ + * field. because of ack sequence is not in the window between snd_una + * and snd_nxt + */ + SKB_DROP_REASON_TCP_INVALID_ACK_SEQUENCE, /** @SKB_DROP_REASON_TCP_RESET: Invalid RST packet */ SKB_DROP_REASON_TCP_RESET, /** From patchwork Tue Feb 13 14:05:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13555151 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 09BF356B65 for ; Tue, 13 Feb 2024 14:06:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707833171; cv=none; b=ABqvmBJMZzV1C2goALW08H3YOIwoPQpUCy5phlAXLu6wwN1nVJTZic5ZBOcCLgGw2zNhD6LB96mDWrwXFoKAZqootdVdgnAhPqR537GNyf0vzNL4VpYx0FB8JMbooasxgnx8xF9o1vDOtvcnOkymQskDNF5bY7eDECQsoRCuiLA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707833171; c=relaxed/simple; bh=/N9m4JzzY4Og8houBpM4FYqjNvSreR2fN/mmtnP1Dgg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UxVCSU/ni4FuTTi2HyeLa0UnmdNoepgfrcI9w3eNwwNPIYvEA3OgcU+ft0CndUUzKBF8K643RQxla8VH4A8wo8/zPUkVD6x4D+/8fxm29nN4q/wc2hPFYSX4aP6FhkUZ+pC8lAzh0LyHsPvcpY5p9d3iq6pKsvrtxQQ5Ztjg+gs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CfOSlXN3; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CfOSlXN3" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6e0507eb60cso2808312b3a.3 for ; Tue, 13 Feb 2024 06:06:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707833169; x=1708437969; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=D2kud7U1xCPuFRH3Fod0cdrqRbt0/6Sra3JlljoFMKc=; b=CfOSlXN3fQG9Qzr5RGPMPEH4rOI0rIxaXOQ681J0GqdUGJfvIyZvR6z9ZUC2z4Lr5h 1r3M6hYgpbQjMg/EuA69nAtxqGcXMMiBIwrKzKHFtvqVLNPn1zxQTrcgjhN/CnpyRAb8 BzSxgDkFX1qu2FoMg9wy/SMp+QPRTYX7Hos2Oic0dxNBm1UF+IHQXVj+c6zKCT5Q6pYQ uKGHSdYWAY5ibYex+dIET8YYK/gos+lNBGs5eFCw22UOHu13eWSc4iwxZP+/e8fA1Iuf DOEa6JYF8l4krqVFzw+8smG+NOJagdu+KhyFgudrC8tLFSsqjpCbEu4iQsTNjrJiFUQ/ TOhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707833169; x=1708437969; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D2kud7U1xCPuFRH3Fod0cdrqRbt0/6Sra3JlljoFMKc=; b=hyINbCKZMefUSljGpg+lHm5n8zu+TyBL2x7x5uYZAfopCgNYxVHVDdH/3bX8G1ijOI Y39jU0oHQ0ew24fwiZUr1kxVOmn9EeF3Vtxs/rRLrBkc+x99uluKe9wfrVm1Oxv+/+DQ 8oZ0Z/K9fNZpCEF64MQ9txLj37HxEK2RjSjexZextbZH4Z5LSjkTIIY3aO6uMS9BohmO n9TXgAgVCACaBKPNskGyRgZjdEsHPZ5R9V9bPCfTg30kUo7P0JfOfuVgjjMI4XXHFxxS 5HcfPlcHDrVmIEF9IG6g11eKbX/W/Nh8U3jwb63dOljVAzLriXx784++1c/47gM0nI0L TuOQ== X-Gm-Message-State: AOJu0YzU0rEnoBELjhI/aUnjTKp1gwfXs89kfX4nXIYCIRkHfh1joOWo nRb+4udj0JiyswHL/hb0xLE5hyuoIbOFUugoByivfeAGijaGmHeB X-Google-Smtp-Source: AGHT+IHbeVvDAG3c1ovPSiPqCT/0TAccEI5THq1lRg6JLGKChE8IR2K/DTBFl32lqdWuhPRIM6QiGw== X-Received: by 2002:a05:6a21:3489:b0:19e:b6c6:8f15 with SMTP id yo9-20020a056a21348900b0019eb6c68f15mr13395964pzb.25.1707833169161; Tue, 13 Feb 2024 06:06:09 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVkL/H1kxaEM2kSwwfPhY55taliSFSN6K/gcP4eauR2TRPfI8hbP8cUToWFE56/kSRLEUIYIFDeL+VSOP0Vi7LWxj0vY0U4ON6mDy4cyzC/12GPIX8q1YCbr9vJEvAzgAFpQ2l0eShkRiVvwfQ4bw3VTKoDn2zk7bd8g/gwlqRKneY3U4hsTsLmtyEE1VIPp1vD5jqLDjNM5850tp4AEFr/YeFRBGhvx4EPbaWwZKtwb35l/h0rETQwt5mhTn+QFONm Received: from KERNELXING-MB0.tencent.com ([14.108.143.251]) by smtp.gmail.com with ESMTPSA id q19-20020a632a13000000b005dc8702f0a9sm1306247pgq.1.2024.02.13.06.06.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 06:06:08 -0800 (PST) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org, kuniyu@amazon.com Cc: netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v4 2/6] tcp: add more specific possible drop reasons in tcp_rcv_synsent_state_process() Date: Tue, 13 Feb 2024 22:05:04 +0800 Message-Id: <20240213140508.10878-3-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240213140508.10878-1-kerneljasonxing@gmail.com> References: <20240213140508.10878-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing This patch does two things: 1) add two more new reasons 2) only change the return value(1) to various drop reason values for the future use For now, we still cannot trace those two reasons. We'll implement the full function in the subsequent patch in this serie. Signed-off-by: Jason Xing --- net/ipv4/tcp_input.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index b1c4462a0798..43194918ab45 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -6361,6 +6361,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, TCP_TIMEOUT_MIN, TCP_RTO_MAX); + SKB_DR_SET(reason, TCP_INVALID_ACK_SEQUENCE); goto reset_and_undo; } @@ -6369,6 +6370,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, tcp_time_stamp_ts(tp))) { NET_INC_STATS(sock_net(sk), LINUX_MIB_PAWSACTIVEREJECTED); + SKB_DR_SET(reason, TCP_RFC7323_PAWS); goto reset_and_undo; } @@ -6572,7 +6574,8 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, reset_and_undo: tcp_clear_options(&tp->rx_opt); tp->rx_opt.mss_clamp = saved_clamp; - return 1; + /* we can reuse/return @reason to its caller to handle the exception */ + return reason; } static void tcp_rcv_synrecv_state_fastopen(struct sock *sk) From patchwork Tue Feb 13 14:05:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13555152 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) (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 D52CE57326 for ; Tue, 13 Feb 2024 14:06:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707833176; cv=none; b=PAgYj1tzrrYPiVNevg0wKh9z+FwaEdZArUzlFZCMl+++mO6GN0xiq3lFShBoCRU8dhaGzutdOoiYyHDYC/OQA7K444Zq11SoB6wSkVQ5Wwn8cbNFzB+rzsmz8IaOcbo7Cy8xJXM2u0SMxnoe3gAgKthxJRflMCD/OrC1xil172k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707833176; c=relaxed/simple; bh=UCGIW5PNf+zYO+oQsI0/Qb+oXrJw6/1jQGRqwbxjtRg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YouBV5lYstEmUXaiocZ0Lo9mIwPd0CvsLo7GaDMmEqZQgnVNf9qE4S5Z2POPedPAA0rWIlFhVKP1hFgjere6o/FyY7257kJ3vheQbAdE4fMxP5nbuaFhJuPJVP6FDjVophU/5kjcq3BQ5ZBhMGA2bfNifk1WYsUjJO/AI+WQ5A0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dVWM2qOH; arc=none smtp.client-ip=209.85.216.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dVWM2qOH" Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-296c58a11d0so3271353a91.3 for ; Tue, 13 Feb 2024 06:06:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707833174; x=1708437974; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TaVcVKNKCO/XNCQaHGJcdkP7KMSbIEDkzBRNfH2o85M=; b=dVWM2qOHU/W2KbNXyBcCOQIblcp+Ix/Mh5/APztgaZ1LWqZQ/BxKbNZKHfhK62jW7X DH1tScb4mA/zkmtd1zIEqak3+fmKQV16U3yAO0T19zVX8aWZrj5MO/vHWSHthLvQdiHA tV731S0v/lgboelCJK3eAED5qDyMLBaMYJFPVoOaa9rKY4o8nQjwQOJMq94VFJTl+x4Y cnsDHEJHoK0CO4UhCrPl8XcwukwcUE5g3rUkWiLvhVAwKwQPb26BMX+Yv6DlnNdr+dkA O/nmOssz+JypXhMqLI1RwLgfMwwHP43rgDvEkxXOrsvZvB/SI13gGGNKR013r9PRriKR ax8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707833174; x=1708437974; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TaVcVKNKCO/XNCQaHGJcdkP7KMSbIEDkzBRNfH2o85M=; b=WBS8CyWEsZu1ePqgbNxVYOaV5TBjWOSF52okvfsSduGdiNfR/GvVGVLydN9aNOS7cW ppprGveUZEjfvN5sCdJh0ewdYTMqk3OmMuyRzJFmCV6pqZIDNmXjib2hBG5QmC/X9SvH xCEkt09yH30Pk4zip46semcI19ZZ4RgllhmdoZpRudO8lB/RCjZbR8FA/gZEyrnpSczI o/Zx/VZsAmx1UwjsifxFOFOuvE6yvHFjShZf9vVAFZEZxmhmXk5ggdDSwX4QhPPakn2c m+Nz3yKvkFTK0RqA2ATdw5uNZRwH9Kf3dH82FqHziP5Vjq0bPwpDLfetgPMwpJSAjgr8 1mJg== X-Gm-Message-State: AOJu0YybtsyhHC7DuOm6DJ4pruEgEIEtyuKvGPGWM4mCqDhGrgGMdPcN vzuHR1jy6sIV1I+J6jrhNBSmV5a/QCJN/sL4Y0a+kRxWC5J/6MXa X-Google-Smtp-Source: AGHT+IFXEJNKtHCPmjx3vB+mDQCRjXvAA/Y54GOflLXfQQt3ZQ+BvXyNdbNINR7/trUcqcVoB3sD7A== X-Received: by 2002:a17:90b:1942:b0:296:df84:da3 with SMTP id nk2-20020a17090b194200b00296df840da3mr7432442pjb.35.1707833174011; Tue, 13 Feb 2024 06:06:14 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCV0ibQOGZ7OZSmHqz4Uw22iQnj5GrHTus39LK1j/2uEWVt9XvBUgJNrWbM0tpTm8JnXoKZTAWeeQ+r71pRLSnVyQ/DLqGCiR822EAlR1qWYNAg7iaRDp4sgDtpFNsPe6sJLZU+yXkytU34kuLWS8IqqpJfIi0eYoFLCPRVncCpTHFXz2/fqhz6XXTvnAq8jh5LVh2w7gpdbtsRjzx5enI/qa7ycunRXQM1CLdgkbJIiSMTXZNkSx3bnGuASWviH45ev Received: from KERNELXING-MB0.tencent.com ([14.108.143.251]) by smtp.gmail.com with ESMTPSA id q19-20020a632a13000000b005dc8702f0a9sm1306247pgq.1.2024.02.13.06.06.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 06:06:13 -0800 (PST) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org, kuniyu@amazon.com Cc: netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v4 3/6] tcp: add dropreasons in tcp_rcv_state_process() Date: Tue, 13 Feb 2024 22:05:05 +0800 Message-Id: <20240213140508.10878-4-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240213140508.10878-1-kerneljasonxing@gmail.com> References: <20240213140508.10878-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing In this patch, I equipped this function with more dropreasons, but it still doesn't work yet, which I will do later. Signed-off-by: Jason Xing --- include/net/tcp.h | 2 +- net/ipv4/tcp_input.c | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 58e65af74ad1..e5af9a5b411b 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -348,7 +348,7 @@ void tcp_wfree(struct sk_buff *skb); void tcp_write_timer_handler(struct sock *sk); void tcp_delack_timer_handler(struct sock *sk); int tcp_ioctl(struct sock *sk, int cmd, int *karg); -int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb); +enum skb_drop_reason tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb); void tcp_rcv_established(struct sock *sk, struct sk_buff *skb); void tcp_rcv_space_adjust(struct sock *sk); int tcp_twsk_unique(struct sock *sk, struct sock *sktw, void *twp); diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 43194918ab45..4bb0ec22538c 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -6619,7 +6619,8 @@ static void tcp_rcv_synrecv_state_fastopen(struct sock *sk) * address independent. */ -int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) +enum skb_drop_reason +tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) { struct tcp_sock *tp = tcp_sk(sk); struct inet_connection_sock *icsk = inet_csk(sk); @@ -6635,7 +6636,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) case TCP_LISTEN: if (th->ack) - return 1; + return SKB_DROP_REASON_TCP_FLAGS; if (th->rst) { SKB_DR_SET(reason, TCP_RESET); @@ -6704,8 +6705,13 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) FLAG_NO_CHALLENGE_ACK); if ((int)reason <= 0) { - if (sk->sk_state == TCP_SYN_RECV) - return 1; /* send one RST */ + if (sk->sk_state == TCP_SYN_RECV) { + /* send one RST */ + if (!reason) + return SKB_DROP_REASON_TCP_OLD_ACK; + else + return -reason; + } /* accept old ack during closing */ if ((int)reason < 0) { tcp_send_challenge_ack(sk); @@ -6781,7 +6787,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) if (READ_ONCE(tp->linger2) < 0) { tcp_done(sk); NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONDATA); - return 1; + return SKB_DROP_REASON_TCP_ABORTONDATA; } if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq && after(TCP_SKB_CB(skb)->end_seq - th->fin, tp->rcv_nxt)) { @@ -6790,7 +6796,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) tcp_fastopen_active_disable(sk); tcp_done(sk); NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONDATA); - return 1; + return SKB_DROP_REASON_TCP_ABORTONDATA; } tmo = tcp_fin_time(sk); @@ -6855,7 +6861,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) after(TCP_SKB_CB(skb)->end_seq - th->fin, tp->rcv_nxt)) { NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONDATA); tcp_reset(sk, skb); - return 1; + return SKB_DROP_REASON_TCP_ABORTONDATA; } } fallthrough; From patchwork Tue Feb 13 14:05:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13555153 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (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 C1D5556B6A for ; Tue, 13 Feb 2024 14:06:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707833181; cv=none; b=A9m7Yz8kfwUYqzB32/siCqLnbpjXpoRO6IpP69J6z7VqTycTw2NcmgVNa/foFuva3fqqbUhoR4ak3QIbHY+a+d76fP2lRorpQRbQL8kiEbbWACRHXJ3CQNv1xZDuV4uP+vimFKLogvk6DP341ykGNgo2uFTsBfBUPbeaKfQeH6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707833181; c=relaxed/simple; bh=fG6+f/knrZVVea72s9t5w9HbeU82G1WSAfUU5RZev88=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O7F03dpn152jxZi710HrkgBXx/PPE0S2SPDLeu7rAoUcNZpZY848MfEiWeSDbCR+7qwL75bhoKP117sEJmXSDnuF93lEx4pp3s2Aaq5s2EYiL2HrbaTc38yJOSyEovI2wKYBLcIdGy0VusPe86cYCaIkMZ4z+HFJZ14A8WpzvVk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kZ1iFLBr; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kZ1iFLBr" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-6e104196e6eso177637b3a.0 for ; Tue, 13 Feb 2024 06:06:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707833179; x=1708437979; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CLFyXQ7/UOg1JD4lPqBFMiUbTXIwLZt03FM53+WqP7A=; b=kZ1iFLBrl7OlxfxO6th8P2FipurI4qcjRoq0W0Hocr4uvsxq/eCOR/TaBeDBuE0UnK CE6FSmXt7UcRno8kRRgJcFZKpiwSeSQ/6q07f6jQJf8fj+yHBFUlhESE5nAizKwvEH7Q 2P04qvWMXDkOs+FueEy4SVdxeNM6qF1DWDR5NtYm5e/+MVYdwPErQNHlKQeTS7g+2g0K PZLtMLEBXWQEb+11LYwosUzf91wMql75GJIejBc5gMSgOAKg/iyOfXOhqNGCsgN7Zwcr Xs4KngU8ASp3cjZ3XG3T3WReXah2CoA9tp/e1BbELfIGYI1dM+81wLtSace+GODZFDVI D1lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707833179; x=1708437979; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CLFyXQ7/UOg1JD4lPqBFMiUbTXIwLZt03FM53+WqP7A=; b=p4oTm9jB0wAagKnNjnTajY9VJ9Lg6fck9HugZYJ+1ylu98K/EbwrI5IT2OrUL+HUyw 61ptY5TkHyytHcAYawz8j6bW4cILKRg10X5of6NN3EynKBCCqleTfxOtC+EbioV3fdPS u4Yr1oMuTFZsRMPnPd1JD0kkpHjy+Uqd7NbHUy7KOjYS99up9yyXa9ztsiQhaUotewf6 XtJeBEuFfyCiXwrmiDqJlnWs97jPP+ox9hzSZopK7nS9Yz19pN8fPP+Du7D9lfUCGNxe RkgspAlLV2ij2BGlczYNI1g9CntRsSZZ7oQn9gpCYuSqGb33VFZpt+tGZTvtTP+Uo6jg JgKw== X-Gm-Message-State: AOJu0YyuDZ7aG+38TvTLPeHpSSWZeKl+79cQ/tzUX9PuaHqsARPheQgF iu6OV7vCUkVpoWnRwpRH4yS3paRqZPoPZzk4XbpHB8FcLWynGFFb X-Google-Smtp-Source: AGHT+IEW1zqpJklppEQtmyXvEtdk5nADZgWQ5nGdzK160psWkadBUON3QlMZox6pNtkrJo74NhDbTg== X-Received: by 2002:a05:6a00:2f97:b0:6e0:9ce2:b598 with SMTP id fm23-20020a056a002f9700b006e09ce2b598mr10879687pfb.31.1707833179157; Tue, 13 Feb 2024 06:06:19 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVTUKwqLWHfWXhVRaYAQ1c6liByFM5OwhedkoMAQfirIVCQSVRQ/+3Q7b4cVwZcY1SSZ5IIkEg7rLELSN9kIYQYLLZbmBTcl3B9L4ShDMZh8aKbAs1jyMMPknl+mFGkhc7p4pMNmx8lwPUAgfA7YNKwLhTvF7NZVtXZgmhPqAT//W8D0hS+Lw7kH+XLe1SjC8hO1lB1IaYIHBXv/kZGzVgxktQK7j+KlMczHnUIgxtHzz+39FrTBremww6QqTe5ag+S Received: from KERNELXING-MB0.tencent.com ([14.108.143.251]) by smtp.gmail.com with ESMTPSA id q19-20020a632a13000000b005dc8702f0a9sm1306247pgq.1.2024.02.13.06.06.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 06:06:18 -0800 (PST) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org, kuniyu@amazon.com Cc: netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v4 4/6] tcp: make the dropreason really work when calling tcp_rcv_state_process() Date: Tue, 13 Feb 2024 22:05:06 +0800 Message-Id: <20240213140508.10878-5-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240213140508.10878-1-kerneljasonxing@gmail.com> References: <20240213140508.10878-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing Update three callers including both ipv4 and ipv6 and let the dropreason mechanism work in reality. Signed-off-by: Jason Xing --- include/net/tcp.h | 2 +- net/ipv4/tcp_ipv4.c | 3 ++- net/ipv4/tcp_minisocks.c | 9 +++++---- net/ipv6/tcp_ipv6.c | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index e5af9a5b411b..1d9b2a766b5e 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -396,7 +396,7 @@ enum tcp_tw_status tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, struct request_sock *req, bool fastopen, bool *lost_race); -int tcp_child_process(struct sock *parent, struct sock *child, +enum skb_drop_reason tcp_child_process(struct sock *parent, struct sock *child, struct sk_buff *skb); void tcp_enter_loss(struct sock *sk); void tcp_cwnd_reduction(struct sock *sk, int newly_acked_sacked, int newly_lost, int flag); diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 0a944e109088..c79e25549972 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1926,7 +1926,8 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) } else sock_rps_save_rxhash(sk, skb); - if (tcp_rcv_state_process(sk, skb)) { + reason = tcp_rcv_state_process(sk, skb); + if (reason) { rsk = sk; goto reset; } diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 9e85f2a0bddd..08d5b48540ea 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -911,11 +911,12 @@ EXPORT_SYMBOL(tcp_check_req); * be created. */ -int tcp_child_process(struct sock *parent, struct sock *child, +enum skb_drop_reason +tcp_child_process(struct sock *parent, struct sock *child, struct sk_buff *skb) __releases(&((child)->sk_lock.slock)) { - int ret = 0; + enum skb_drop_reason reason = SKB_NOT_DROPPED_YET; int state = child->sk_state; /* record sk_napi_id and sk_rx_queue_mapping of child. */ @@ -923,7 +924,7 @@ int tcp_child_process(struct sock *parent, struct sock *child, tcp_segs_in(tcp_sk(child), skb); if (!sock_owned_by_user(child)) { - ret = tcp_rcv_state_process(child, skb); + reason = tcp_rcv_state_process(child, skb); /* Wakeup parent, send SIGIO */ if (state == TCP_SYN_RECV && child->sk_state != state) parent->sk_data_ready(parent); @@ -937,6 +938,6 @@ int tcp_child_process(struct sock *parent, struct sock *child, bh_unlock_sock(child); sock_put(child); - return ret; + return reason; } EXPORT_SYMBOL(tcp_child_process); diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 27639ffcae2f..4924d41fb2b1 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -1669,7 +1669,8 @@ int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) } else sock_rps_save_rxhash(sk, skb); - if (tcp_rcv_state_process(sk, skb)) + reason = tcp_rcv_state_process(sk, skb); + if (reason) goto reset; if (opt_skb) goto ipv6_pktoptions; From patchwork Tue Feb 13 14:05:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13555154 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-il1-f170.google.com (mail-il1-f170.google.com [209.85.166.170]) (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 6ECA856B6A for ; Tue, 13 Feb 2024 14:06:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707833185; cv=none; b=qUgDq+nUhTfKBK2PrNHiHVPRef2rGZzmbb4YY5NKkXHBQW69odrWRShaf3m8EpsxgR9nJnHf+t/T25vKrk601mMlNPgDVCzW7wc0UJhTAI7KNHPORtJdONDUGfzs431AXrwJvo63yNGtUdXpjMXKRT5FQBeQ9g0IjYN+9u0qhUo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707833185; c=relaxed/simple; bh=2M7USFiX5nLXq140cq9+M5nfmHpQqyKhgE7+WdLYYrw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nSzSptAE4Qh7S0b4nhqcCzFr9Knn8BuSRgP/3WCwpf2wrU1DtREVoLDTYZIJ208G8HEYRF96CFHpUmXti8AGyWk1oDQ2+aSCzsAODuHeQMAAu7IR3vnf1BjjJHowTvcoBQRudboRLd1ljHQj4Iotc4abuUT9x+DaT2DnIJ8CgSI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LvTIB256; arc=none smtp.client-ip=209.85.166.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LvTIB256" Received: by mail-il1-f170.google.com with SMTP id e9e14a558f8ab-363ce3a220aso16953585ab.0 for ; Tue, 13 Feb 2024 06:06:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707833183; x=1708437983; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=F5VCz9rjMN59Icaq+ueDHdsVRQa+elI2g77RIpJ6uB0=; b=LvTIB256QdsSNn7Sl/0FRigaKThX4VQLNMTK50dTImMKDPogrKk6IWlwWrPjwZpdCm eIE+Hi41edpSvOaWBxPuo0iQJ9jcDKJ5MP8m+SVTKyFBi+u5wZpgPCv3V5aCoyjzM3Zg mCYLwMCRMv6pbTYJK/4tCR2L1SjYlI3+VWtkiQo3aqcvxeGDFNFi90LuM/YqyXd/Nm5q bmSTQmZgkvz60Lbqk9rhxkbZeSreqk9E2OFF90tIpWMAa0CueILdzWvqYP9yyqQfyAnP xASzJsJgcljDgyrRLMKtJx8+zaN4YstLRtxDdyXZ2eTyQJAxhQr88MA9k1fiU7oYfYJ5 Crnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707833183; x=1708437983; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F5VCz9rjMN59Icaq+ueDHdsVRQa+elI2g77RIpJ6uB0=; b=vbuAnuKEn+JON85uxlRJCa4Ic63KAvEPqgl37rPWYc7OXTwPUc6EL+kAP0Hc7XPpzw IVJHmfuKjDrgDLBdeoOqclTKn241V0jc//tDO8LtHW/VSRNcF2PBtFj7cg4TMcQeRDau yA8BA+lD866pgLmAwXXLnLoHw4bwLK2B5vjKD46YcyW350WbIeEdFPGssSVjnFVaM4PX 4b4KZa2C8uent6muVuVJpjIteC75E1OlxtMVcVteRm0E0PRYGlWwEEjCMkTkNuz0ElCW gqJD8FCKMPJm1TXvIDpI6VObuVvDSZlaANcVYprO2m5y1W9+6gHywVKFM20GZ6vSTjmS FNSw== X-Gm-Message-State: AOJu0YyiIfLMXd4IVjZYdDK63dAxDXGSRcqINWu8Q6DQyNd9OEsNeeMj Tjo5gV5NJ/sNHcoV/pgzo+xkRKvAxlf5+JvDVrNpDD8qZV74iB7D X-Google-Smtp-Source: AGHT+IHdUC968Ksny9xZmUMW4iWuz4/zD5hpIhzSMrtiFpyPnFbFUS6VeNzoMgm4++HFNGvQLgsQ4w== X-Received: by 2002:a92:d941:0:b0:363:7985:eee3 with SMTP id l1-20020a92d941000000b003637985eee3mr11860457ilq.24.1707833183678; Tue, 13 Feb 2024 06:06:23 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXIAE8oB4eESE3e5fVpX9NztB57+ntp8ZFLsTs+22rt+PCudVKNEeBH1XYP1RYtksD/7LCSS9N0mZomy8qk/h2Ee0ofoXRtGy0x7gED46ZBbgIgBc3bB/KrlzBFktD8Eu45k9AGOSgQQrXiLkq9uVBWSzdksoUbA1Ba4Zl/IO5UXRtSjs34FFRc92+PAvgWmX9utQlaxg7uyNGohdTB7vUjIBbWEgRsNZ6OYyx/Ab6zd4WVqG90ZC3bopUuiiP2V453 Received: from KERNELXING-MB0.tencent.com ([14.108.143.251]) by smtp.gmail.com with ESMTPSA id q19-20020a632a13000000b005dc8702f0a9sm1306247pgq.1.2024.02.13.06.06.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 06:06:23 -0800 (PST) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org, kuniyu@amazon.com Cc: netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v4 5/6] tcp: make dropreason in tcp_child_process() work Date: Tue, 13 Feb 2024 22:05:07 +0800 Message-Id: <20240213140508.10878-6-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240213140508.10878-1-kerneljasonxing@gmail.com> References: <20240213140508.10878-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing It's time to let it work right now. We've already prepared for this:) Signed-off-by: Jason Xing --- net/ipv4/tcp_ipv4.c | 16 ++++++++++------ net/ipv6/tcp_ipv6.c | 16 ++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index c79e25549972..c886c671fae9 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1917,7 +1917,8 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) if (!nsk) return 0; if (nsk != sk) { - if (tcp_child_process(sk, nsk, skb)) { + reason = tcp_child_process(sk, nsk, skb); + if (reason) { rsk = nsk; goto reset; } @@ -2276,12 +2277,15 @@ int tcp_v4_rcv(struct sk_buff *skb) if (nsk == sk) { reqsk_put(req); tcp_v4_restore_cb(skb); - } else if (tcp_child_process(sk, nsk, skb)) { - tcp_v4_send_reset(nsk, skb); - goto discard_and_relse; } else { - sock_put(sk); - return 0; + drop_reason = tcp_child_process(sk, nsk, skb); + if (drop_reason) { + tcp_v4_send_reset(nsk, skb); + goto discard_and_relse; + } else { + sock_put(sk); + return 0; + } } } diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 4924d41fb2b1..73fef436dbf6 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -1660,7 +1660,8 @@ int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) } if (nsk != sk) { - if (tcp_child_process(sk, nsk, skb)) + reason = tcp_child_process(sk, nsk, skb); + if (reason) goto reset; if (opt_skb) __kfree_skb(opt_skb); @@ -1860,12 +1861,15 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) if (nsk == sk) { reqsk_put(req); tcp_v6_restore_cb(skb); - } else if (tcp_child_process(sk, nsk, skb)) { - tcp_v6_send_reset(nsk, skb); - goto discard_and_relse; } else { - sock_put(sk); - return 0; + drop_reason = tcp_child_process(sk, nsk, skb); + if (drop_reason) { + tcp_v6_send_reset(nsk, skb); + goto discard_and_relse; + } else { + sock_put(sk); + return 0; + } } } From patchwork Tue Feb 13 14:05:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13555155 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (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 DB72E57315 for ; Tue, 13 Feb 2024 14:06:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707833190; cv=none; b=T93BYVqu7ki8gEfGf3BTvbBTGB2sqpWUlERqkcmeHdXdg2f436pY+W6kU0wyTnaIvRyvwaoYOalZG4QN5IMiwVMgAeFCbSDBC8juSE2YsCMZAqpSsNKbJzrgVZ58EHj4x3D7DuNGhaJkUu6uVBqQ7dh1TqMc4NI9MU0JpiycUNU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707833190; c=relaxed/simple; bh=TStINRVFhm9HzVI+/oSLRgbCmC3937DPOtZqDEpQyOo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=l/mC0OAFwScmppivxmpEbYW1rPcKQtmgDtDwqseIi+h8t+BAkQ+bR38Jh/SiGBCx63yaZc9CrHsV9GDAKuisaEjnBkgoGz2A0vcljF6Xn0tCWweOGaV2MRskLCI35t5hJdOLVy0sW1/kwY5Q5WZxYuuw+oaBKrT3p1qa+H4uA6A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=b1l0JnQA; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b1l0JnQA" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6e104196e6eso177788b3a.0 for ; Tue, 13 Feb 2024 06:06:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707833188; x=1708437988; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fNRRMX/M9s6K5W6pc2GtqVUZ7M9Go0EAy58TztDkPPw=; b=b1l0JnQAAhOeJIOGK9Q5c3oevzxZxvTqap7IrsacjNlZUsPEmGrZxmhuop8PtCTH9k e/iSXZ1qI1oUDJBPKsfYrl8JI4Z5qI3DN4vZs7sQ4RdT8OV1OUjslyfqx+U14/qZvG8/ JFGE+g8dkSUaJhsNayPPJwTt8VYqO7fHPN9HCAcFavTsc+Rw0Jg/94m/wJnumqXSJ6bD OUgSvk09VxX/KrYoMiKzDJGw4AcFWsLWo2YtbWsGkjVn5+63ZMkqOAiZCK3oqDCsoj01 b0GUx8X4XVP8HxENKC7qjcpp6uCppOkSsmOABeVKsfcNoxVHY4VKB64V7OHexxV7HWwE XPxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707833188; x=1708437988; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fNRRMX/M9s6K5W6pc2GtqVUZ7M9Go0EAy58TztDkPPw=; b=e7PmCSmdcSCOOts/0tZQlhWcQ7wPikmpE28JP6XAh6o3dL6qaW1KmXHLN7nIA5UJE4 gJvA9RLCTe6GD45fDntqvLzYP9fh/oxwLoMJsySCwL/U6JjQia3n4uc13YgADM5qkJLt 1x8YuX/4Y8tZhDqGoNUWp7ltNa2w9O7QDC1NOIBpKzn03CcncZXTu5gKHX+FfhEMQCuT q+7D1UBVN4wyjOm7rAZFa612gg5LxL8FF8HTXE250sREn/sHX39zQ1qQfcQ36Y4MlU2r 2wJrv8LAQocJpb8KgANfBkchKOcrDN6b6iHwhjI4g7QtS+jDMmst2/L339xFb+CQadxp KG/g== X-Gm-Message-State: AOJu0YxqSltiHcTkBcZjdRXBhOTYYqCP10rPinXXwoCNGfVNHPYq+DqG OLafrErlExshhQSeKTuHl0ERCkRUe3ZvjlRyw7RqRb6fBrhiwDuA X-Google-Smtp-Source: AGHT+IENFQQguds0gUVknQFIiWQtTE8ZCs7a4wrfxwxqxgFweytQakcsMYOvVFeX1+013XuuBZfPLA== X-Received: by 2002:a05:6a21:3a81:b0:19e:cf1a:5372 with SMTP id zv1-20020a056a213a8100b0019ecf1a5372mr7772656pzb.34.1707833188269; Tue, 13 Feb 2024 06:06:28 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVDEXDrZDzYzZ+BrHZTEYSfJB7O43mofO+RFJGWRa2LzNm91QvP9XU5MkPYKtbA9tbcuK4H7GEzYdTA1HsISRNWe9U9FxPj7oFsIzjZq2xRhkGm0FsI+4GmFC6DODTQqLLYdcFrEMsQz2YEbgDfvW9XhWtCBPMurLmryMMmLsXTNmf5FWCmtw6864LJFMLsdSBX55EzkfchhnnOKHXXKYkRjrz5xhr93vpK2he361Huuq4BM3Yjf/3CfvDaofwUUAl0 Received: from KERNELXING-MB0.tencent.com ([14.108.143.251]) by smtp.gmail.com with ESMTPSA id q19-20020a632a13000000b005dc8702f0a9sm1306247pgq.1.2024.02.13.06.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 06:06:27 -0800 (PST) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org, kuniyu@amazon.com Cc: netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v4 6/6] tcp: get rid of NOT_SEPCIFIED reason in tcp_v4/6_do_rcv Date: Tue, 13 Feb 2024 22:05:08 +0800 Message-Id: <20240213140508.10878-7-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240213140508.10878-1-kerneljasonxing@gmail.com> References: <20240213140508.10878-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing Finally we can drop this obscure reason in receive path because we replaced with many other more accurate reasons before. Signed-off-by: Jason Xing --- net/ipv4/tcp_ipv4.c | 1 - net/ipv6/tcp_ipv6.c | 1 - 2 files changed, 2 deletions(-) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index c886c671fae9..82e63f6af34b 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1907,7 +1907,6 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) return 0; } - reason = SKB_DROP_REASON_NOT_SPECIFIED; if (tcp_checksum_complete(skb)) goto csum_err; diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 73fef436dbf6..29a0fe0c8101 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -1623,7 +1623,6 @@ int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) if (np->rxopt.all) opt_skb = skb_clone_and_charge_r(skb, sk); - reason = SKB_DROP_REASON_NOT_SPECIFIED; if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */ struct dst_entry *dst;