From patchwork Mon Feb 12 09:28:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13552849 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (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 C69F814010 for ; Mon, 12 Feb 2024 09:29:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707730178; cv=none; b=dCmm1B9TvHDZfwqm9VNi1ZZcDw0q+RQWnImM52T5gZTqneLe2uBR/Z+fvpOUE44LVO5UwmhRXkXl3v2MuPgdsZArMIuPlwMlAwN3Hd9bFE292w0RFwyPF3N5nQ78i944aT2rAvxQSqbyhRnZAFmVIJ/9aPCIFuX+s6V3WpwaGh0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707730178; c=relaxed/simple; bh=HfVSBaJfDzcfCtKeSl5LmTBEFoD/5ZETIe3NF4zIxrI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WVpMvtsPLxUpXwSbOwGLXLl8jCNFfdittSGDfChVTr9WLzRRmMjX27h1vVTgQwsW4iapXEVoho992jG0nTgui1eWKph5oh8CCAtE9dLSAT4jKRFHFsbXhFnlPsdXJ8TsRz/JlSQf0mpv6b09kCKW4eY1QJJRKUn+bGDaKvDW43w= 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=UyfQ6xk/; arc=none smtp.client-ip=209.85.215.181 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="UyfQ6xk/" Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-5d8b70b39efso2478254a12.0 for ; Mon, 12 Feb 2024 01:29:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707730176; x=1708334976; 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=vkN9Uw6RXhSc1sqpdvq5JNyS78LT5R8JJjTZGgod9mg=; b=UyfQ6xk/s27fNHaeQhALUp+TXo8RM+SitWhhuWxYdD1bcpPnCU2VDXaaSfDv2iEFZ8 39dxY9GaYx9DOb1v0qzuFTCDEU6Eq2nvvUk6a3aINR7MOD8RUDczU6UibRW9ROx1lytX qbpPQ4MCZNdenC83vEyGk+4l4m1WXVn07D7mUGUPXhlFMX3jz02Cpz2I13eWJjkD/O7h pTzKi1lBY4lg5ZvwNEKhB745qJHgXZx7l8Rq9ecP6NcCe0NHp0OutP7HVG/2D0fh9FcM npXq1lgxR9ogGCXXeGx/qVHpEto2SLOwnLaVgtF2ZTaG90kxBZJzGzdoO4mFT9kXCSdR z56g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707730176; x=1708334976; 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=vkN9Uw6RXhSc1sqpdvq5JNyS78LT5R8JJjTZGgod9mg=; b=pv9cZ7Ot+DSGpkU/Gr0pGWMU1qLa6Hv24shqfZXbCx/ltVgU6M3SduY74vMrgzEvt9 D/7DX94Yo3DG/i2c86qe7k7n9UbsnzKq+UaY++BNhXWZXJO4WHHeF0KMk6hUcn3g0ieM 703o57K/x353gnjqdMpENyo57kd7c/9ot18BKWTyMnuJqp9RAo0y71DK8B4l/vm29QKb BjfgkR0k8RtHOVWkOXGH4xk4JhJ3Bgl50NvV4bEn8Xhm7U8mhaD8YIsdRJKe5aBoIF/D Ep6CguGycqPJjsQVkZI9WgdvruX4oioEMbYKe/go9VnJGDkEr6rCaInu3MAgfQQgbF0l 880g== X-Gm-Message-State: AOJu0YyRqL6pzxJrlcHH1KY4Nx/a/J3I2USwHbSQCUz9Xxgen1fUnFAn pPlFH6MbBMLy6Xm5AXDXcZuNXRhpeKJH8Ho9Cz6Cdb4z0dY/2bgo X-Google-Smtp-Source: AGHT+IH0ZSs6yM/wtDEVmsoVtkRE+4NOz4H13/IgdjQ/SJIvGfnKB8YXSlJwwiaz3BCeruocfP0Baw== X-Received: by 2002:a05:6a20:ce4d:b0:19e:957c:f7e6 with SMTP id id13-20020a056a20ce4d00b0019e957cf7e6mr5200216pzb.13.1707730176166; Mon, 12 Feb 2024 01:29:36 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWazc4L69maCSm+XUtsLqXEiZFt7dWO+hGeG0LgmJL+0PX2993eO2dHQbFlRDYqnCjl/kS5Tuh3XQskm+2ETcLY3/FAux9qnFekIE1qSOpjHux2bnrXb0x3GO4CXBrUroiXeQM15tQEPUU1aUB7ul/MLT1FcF7wuunSNhmt3yiHyy/ENLmtK1WqtlEmn8RAFAn2nKk1JY8dbq+fAkG94Pf8VkXdVGpXslc+A/NJ12U= Received: from KERNELXING-MB0.tencent.com ([14.108.143.251]) by smtp.gmail.com with ESMTPSA id mg12-20020a170903348c00b001da18699120sm4220211plb.43.2024.02.12.01.29.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 01:29:35 -0800 (PST) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org Cc: netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v3 1/6] tcp: introduce another three dropreasons in receive path Date: Mon, 12 Feb 2024 17:28:22 +0800 Message-Id: <20240212092827.75378-2-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240212092827.75378-1-kerneljasonxing@gmail.com> References: <20240212092827.75378-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 | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h index 7cedece5dbbb..92513acca431 100644 --- a/include/net/dropreason-core.h +++ b/include/net/dropreason-core.h @@ -31,6 +31,8 @@ FN(TCP_AOFAILURE) \ FN(SOCKET_BACKLOG) \ FN(TCP_FLAGS) \ + FN(TCP_CONNREQNOTACCEPTABLE) \ + FN(TCP_ABORTONDATA) \ FN(TCP_ZEROWINDOW) \ FN(TCP_OLD_DATA) \ FN(TCP_OVERWINDOW) \ @@ -38,6 +40,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 +210,17 @@ 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_CONNREQNOTACCEPTABLE: connection request is not + * acceptable. This reason currently is a little bit obscure. It could + * be split into more specific reasons in the future. + */ + SKB_DROP_REASON_TCP_CONNREQNOTACCEPTABLE, + /** + * @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 +245,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 Mon Feb 12 09:28:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13552850 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 057BD17550 for ; Mon, 12 Feb 2024 09:29:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707730182; cv=none; b=qlPtQVdgew7wJ8Owf3yxkGETsoik5BBkyom1X3kzJe7bj/SvFo8ZwP04/uY+tuYhDm8/XPVjJnkLfLB1p+hbH+V6hFpwiSxamOgpFPRgJ+zYWYjU5hawAhTaTmaSBM/5lZhYXDkj29O0xZ7wkhaxEr1uS5+yiJ4tovo82Ea0oLo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707730182; c=relaxed/simple; bh=pCagSynNTlKYe4dOVJc4kvI+REabpDXkUlwOFY0W05A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OjYsOmrw8B5h3AfbQoP+e8ybAbnxvUDj+576OX6YeKjI5IYN2SQGrSlp9V9+AJngXu1H3kMkaG282h5zpdRLMXzT9WomJkRCcFPU04P25pJ7d4DSipQWAOkjb0jCqUq7xlkgR7KoxtsAQ9fvN+d2HIRtGGvsn1/W3n5aBCL1cFI= 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=EmV3TiCd; arc=none smtp.client-ip=209.85.214.178 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="EmV3TiCd" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1d76671e5a4so24604835ad.0 for ; Mon, 12 Feb 2024 01:29:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707730180; x=1708334980; 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=IVGxAX3qXUDPz2EArYhykiFmDLyjoCvm6jnG/mRSUlM=; b=EmV3TiCdaqT9Dq9TfPPTWP+nC7BUJDuzP8BH0AzNgHFTk1pGhNHfOf1N2AiyKF3aQO T2ZFru4Gev/lPUZIuZasmH6eNO+QeGC5ZC29HDLoC6q8hD9EVEbVmqHDRMqNjrw6Ks9Q vtsS57faZQUXLK2QHj/HBZbRhZgMmTk2OvRVFg8yyvYYhql2I8Thxk1Knv+dwoe2LM3d 4QjEZ6U57d4slVRnRPeiGaiagASg9T14JtsyVf6ZBzbzhCw/g3GO1UbXqoxbTr68M3J+ MiC8k0Kq6bxlIUJXm/A9HPjwFdqZAKWrE/hP1d/SU0gJukHVMaFc7CnL9JYuvwcr5efK qu/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707730180; x=1708334980; 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=IVGxAX3qXUDPz2EArYhykiFmDLyjoCvm6jnG/mRSUlM=; b=Uz3IlA8Q3HmRV3oHtQj8Zoa5cw/RtbnzAVkLsEow+mdX1O1tiTd8QRLuGCotD4fN2l gLsxTcqY/Wguatw+NhZRLRC9ZXfWZ/Xw+raefSZQrl8rCLjcsStaJ9AfJpQu8fAqfUvT tLajcE3I4wem+3vVtTRBfkUumvrJwrV79rOn3Al1ttYyUWf1AJbLrDTGBSuCNcHP/lc5 foCBcpB7DJJ+IVR7zQeK2PU+mu47Xdstkrmgh6zHF+V7xJTe3WpjpG1BKLEMNtNrtC8R yHCWuUG031ua+yXO8auoVQUfYee289atBdOZxH8k+paMxE75RpVzLXZ6Ql/Uvd/ZwFtE EmAA== X-Gm-Message-State: AOJu0YyoMcBiJ1BJBcF9AEQJ5HmLIO11He7+rE26c2BvYPHjc1tg1MNy NjbVfJjjITpm52VnjzUpJLzBqyfjtRv/qSLTSRY8y/DQULvjf009 X-Google-Smtp-Source: AGHT+IExbaGFe8Ma3lDyWxMdULSAPZq+7HhdkrQB26XZhGZXvpJhcpAZUKt6HEzlBd1OonvkKOio/A== X-Received: by 2002:a17:902:ebc6:b0:1d9:1b80:8799 with SMTP id p6-20020a170902ebc600b001d91b808799mr8604536plg.41.1707730180384; Mon, 12 Feb 2024 01:29:40 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCV0XcfSxzAQW8JJ3Iu/W2e1U3LvfonxTcnL4mBG1J7UMauBkVW4U+di/nknjZBG6WKJ2c3nAQM/HL/UekGMk5Quh+VBosc6O00det+Alxro+A3RCAxLvEhOQvkEuSN7QZy7G7maUWx+SQltsXIHaOK5cKi9hC8n37BV7SUZVzGwm8qJi0BzSrwkOvUXZJnfnVo9JfFjHBPSkX6EuVRnAiCZa1Siu4/b1zl9n1o/wWs= Received: from KERNELXING-MB0.tencent.com ([14.108.143.251]) by smtp.gmail.com with ESMTPSA id mg12-20020a170903348c00b001da18699120sm4220211plb.43.2024.02.12.01.29.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 01:29:39 -0800 (PST) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org Cc: netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v3 2/6] tcp: add more specific possible drop reasons in tcp_rcv_synsent_state_process() Date: Mon, 12 Feb 2024 17:28:23 +0800 Message-Id: <20240212092827.75378-3-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240212092827.75378-1-kerneljasonxing@gmail.com> References: <20240212092827.75378-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 2d20edf652e6..bfaf98c1f0ea 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 Mon Feb 12 09:28:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13552851 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 6D1F61754E for ; Mon, 12 Feb 2024 09:29:45 +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=1707730186; cv=none; b=bdRTmbGlVby9BJX3WMIl7Eo6fEPasrWjpnmfL2aujPLN0pr8F5gqy6W8ZTHonaN+o9uQzEI6hxjemDNnCLY0eHWKWqOYhgBE+2EPW+BQgaBCZZIMhDxc1Et+dNWs5YSX5IrpiEJPX2PGija1/fyFsmbORZhA2TLzZ6rXelzE6SE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707730186; c=relaxed/simple; bh=YGRBws0ozEQI+YF2kX7wkP0n+tjoQ4f/EoxoJ1BSfbU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EZm9B1c79iy4hgXdXJjn5lpI9qq6GA8F5e+EvMB8GwbF8M8A97aIZwuqhndvf1REbzjwe/mK38nZRfSlkpGViYz0AiIIo5KYZfF0/k08Ir6n1AvFFs+pR4uBQd+mOEnEweNU/SK+qi33Tccc8ELulMikiBpsnmtCqIrQ/cb1HiI= 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=NrhRgShZ; 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="NrhRgShZ" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6e0a37751cbso950483b3a.2 for ; Mon, 12 Feb 2024 01:29:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707730185; x=1708334985; 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=1nmPA5Z8Fe3emj9wQJ77Q93CJHoL3XGah4QiULskyFI=; b=NrhRgShZCtA9gDQs4Q45RVBicokiG4dGzeF9dZvxk3M64bhLxzyKlQwosSyox8m7O+ XRlqF8WKjJPA4XhGRllxHLUgwII3q6NiHraCrwDDTow7S9GSiy4SD2vVcuekyJAw2B+K J5bcmOafhGPYDC/ZMzBArd6ct/lP33ZHnl5T/qoZRqZadTT5CTWUqmW7bQiqlpiyfEEb H+wlAIMJXxuOQdU6dKle7ezXsr0/ZqK+RPZ2VT8CWwIi7aYVmn7HOJCqwGo+WsrfV5GM TCftY8EnSKa8OGigyoXn58M/cj0sFg2iflC0AqyTtmh0GhXyAjCljEgfI8XgS2klJvCJ w5kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707730185; x=1708334985; 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=1nmPA5Z8Fe3emj9wQJ77Q93CJHoL3XGah4QiULskyFI=; b=Pa3epYTWi3b5bQpJlqefuRPjpBSTnarWbVN+Lr/bXDtRRHsa/gJ/GUqxcLBcjmfZCM zSON4T4smP9uWnRDZ0M/YjmZ1f1K/0OH+CYCR8/SgNuzqruxKogo1+ag3W8YDtZEoVUx Zp7cyQUNFbPgVUa0XDFF/F8XbIoZKsa++FbdwmIdHPsWQxLGeDbxQNpQIUCYa3JhUPo0 o26pSQqccG8DkEQHxUlUwz0lrJPH15iZniZDFt9TaoVv7EpMlCHyyw9qXnUfW7QQRmy2 0KWuXtpAy5wWjkFkJNyicMat7naX5H2pH1bEJ2HuEKYC566vNPfl70BCgD4HGdZiGcLi 7ubg== X-Gm-Message-State: AOJu0Yz/6kkgz+ulhQ4uJo9ksGO2CMpCR9zdCgO5rxnb8+L9A323you9 fsiRcckqhYe5ldsYnzYd6+LTBOmfIcMqiF1T2/wjJTyhlZmHKTwk X-Google-Smtp-Source: AGHT+IFJmRlilaTYEvxwUQQ3W88TCKWOa344jXzJ2YnIYSSodCIIUGWtq4qN2ASgP88kuUm+SDrivg== X-Received: by 2002:a05:6a20:4e18:b0:19e:c777:5c61 with SMTP id gk24-20020a056a204e1800b0019ec7775c61mr2487551pzb.22.1707730184753; Mon, 12 Feb 2024 01:29:44 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXoqiOSyFlD+0ygsj17XbWqp28ntSvwtfCjgFXeNbfQgs+dmdCTlSiPDWIqpTUJtDxo/SHE9pyb5ebhWbhKDWCzdlMAQS9R+g+mHFtoNEXcVfnE2CQOP43cIInDPdV0Jbz/lKp3xpTHsPVAqT9LKPK4d2q+cG6OVhPaBfLo9U9X5jYZlnFAietyx/ocRKSqgT/I607OjehiFNtkGzPzVvW13tiUFpd1y/D6zLizrII= Received: from KERNELXING-MB0.tencent.com ([14.108.143.251]) by smtp.gmail.com with ESMTPSA id mg12-20020a170903348c00b001da18699120sm4220211plb.43.2024.02.12.01.29.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 01:29:44 -0800 (PST) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org Cc: netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v3 3/6] tcp: add dropreasons in tcp_rcv_state_process() Date: Mon, 12 Feb 2024 17:28:24 +0800 Message-Id: <20240212092827.75378-4-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240212092827.75378-1-kerneljasonxing@gmail.com> References: <20240212092827.75378-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 | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 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 bfaf98c1f0ea..d95f59f62742 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); @@ -6636,7 +6637,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); @@ -6657,7 +6658,8 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) rcu_read_unlock(); if (!acceptable) - return 1; + /* This reason isn't clear. We can refine it in the future */ + return SKB_DROP_REASON_TCP_CONNREQNOTACCEPTABLE; consume_skb(skb); return 0; } @@ -6707,8 +6709,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); @@ -6784,7 +6791,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)) { @@ -6793,7 +6800,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); @@ -6858,7 +6865,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 Mon Feb 12 09:28:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13552852 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 C345B522C for ; Mon, 12 Feb 2024 09:29:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707730191; cv=none; b=oZ2G3jJvDffFvtXrzJBKUS8klrJoOBzQH7pYBJeFjIn6Lka2sHGSXw2M83K5N9u04dYVd7SZ7zvXkrhBWxk5gnEB0KZSqIqcqsMs9CSa3ECmDYtQ5TOhQPUE16ovGUfP7yBvG5RIRjdgEApuEp1TjBKP0e0u1LR2pFBbCd0uiYI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707730191; c=relaxed/simple; bh=fG6+f/knrZVVea72s9t5w9HbeU82G1WSAfUU5RZev88=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=H7kIoz8qeehzr/erV6r0PalY2DYDuBjVrWjopU+FaogFIkdbOCYTDXJQ+cZ3ca2GGRfoIlfUb4AF7s00i5d23acVyqo8GqfGSrA6tr8WIfIoS0bMwdpFIMmswxLq7WwHjKrjGC7Zm5osl35Zz2ySTExWnACbECP2p4KwmU0J30M= 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=kjiHgdO/; arc=none smtp.client-ip=209.85.214.179 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="kjiHgdO/" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1d74045c463so22809625ad.3 for ; Mon, 12 Feb 2024 01:29:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707730189; x=1708334989; 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=kjiHgdO/M2/J0C0QhyCXQvQHeJqexKrlPCoUWY1uPlsRV6ZP2p8STzWJ2eTvL0eruk ReSX//6/a+8sx4oSZmTgR2KIQPX245MAJkien9RUU82EPv3vpYAiWLQWij17drbflhCM y59tjMQ7qbUjlDjD9n7qccTlTfWVQDhwnSgaK59ar+eYfAsAFtYl4Ytj225Www8ilj1c +gvficKS2B7baYGCutzy0DNcHtY1L2MaJHvJ8AN3oxcUpFx20sz4Gkx3bsYC87jgFnnY teNn2FXMx3OM8ju5ZIyXxbweSOCSIYokGJzLA2t1ciYoDFA6odo/OKHx4iN0ZqTUx8Np ryQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707730189; x=1708334989; 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=USt32HhugB7RxkxryMyFLAipe/IBT5tbVjvOrs0JCrPOO278ynJVd7rQR6GhJsoI+B g8VHfRq1xnkkfJ4gwMbh9vW7exM8nsJJ1zMcQuLIRr8zR8t2JE2Dc/p6ElN3KE6BMV8X cnxf3NPcGK8KsVjvbeekyoXQ6XhKTLwTa6sAQtJuc6vRa3MepOwx1CCZThWKQ2U9bwz0 20NC9EKLolXjflz79GyqosmgCs/oZRL6/c1kyqdWM+LvkVKfVnRZu0YcI0jDurzWLPh/ WsLoftuI/sc+V69Jd+LXTThB/BayLQRtXjSp2Pj7h3WkwquJteSjuYHCo9y6NDoHm5k/ QKwg== X-Gm-Message-State: AOJu0Yw6ReBocCFxmQF4zro//qFDJuuFTxkzF+x9utBrkx6Evu4BWMve YiK5V7OyjXodnvZwgRH8AjGcR8nYaP/L9vhRWIJHqAxfjti1Qr/c X-Google-Smtp-Source: AGHT+IEFaplLhyIInBnGDVvSSu2lgL2qZ2UFDdZZqje7f9BfQBN0LtFTsRgfTnwAU7Q0HgqLTIWoCw== X-Received: by 2002:a17:903:3287:b0:1d8:ef8d:a7ec with SMTP id jh7-20020a170903328700b001d8ef8da7ecmr5867465plb.2.1707730189053; Mon, 12 Feb 2024 01:29:49 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCW6R/zs4VjOa/nBwJb48fgGitdRixoD6Imhxvr62srMnCVz3bIjbM3PkInayKz7zCVXRq03awykZT0YMmWbWsSyBmiTSJvZtlZJ8q4SDKVFkNNM7xXhCaC6IdUPYaF23MuxbA4jtCxyJO1T+vvZa2Yszfo+QtDE5QaKtsZ64RXK1CKjo1ArBWKbwLufChPM8imMzgLWk5QPT0+fiyRgUyTkPfDRYQNY42XrsF+JUdo= Received: from KERNELXING-MB0.tencent.com ([14.108.143.251]) by smtp.gmail.com with ESMTPSA id mg12-20020a170903348c00b001da18699120sm4220211plb.43.2024.02.12.01.29.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 01:29:48 -0800 (PST) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org Cc: netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v3 4/6] tcp: make the dropreason really work when calling tcp_rcv_state_process() Date: Mon, 12 Feb 2024 17:28:25 +0800 Message-Id: <20240212092827.75378-5-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240212092827.75378-1-kerneljasonxing@gmail.com> References: <20240212092827.75378-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 Mon Feb 12 09:28:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13552853 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 10E4617557 for ; Mon, 12 Feb 2024 09:29:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707730195; cv=none; b=G0NPQj3ycr/qh870OPM/J3VKy3HBRKAuRg+r600sU6XDVkieF6zm1gBulF/my3aYk8aRvg0QVqO58M0IJf/EGq6/xJK4goH+BLfpgxeJoz8XCmBxiXvNXGwjj/SCKfhKa5Ayigq5DYz5ZP3d+zd1UfXYYm2mpUUETTsM+4JZeDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707730195; c=relaxed/simple; bh=2M7USFiX5nLXq140cq9+M5nfmHpQqyKhgE7+WdLYYrw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=s/FCVZxG6nWUqBFyXQ9z5NdlouattJum3XE+8DvzAC+YjIGVkcMk3a0jPEmAlXViwOtcAVTEbUuYam1Ezv01yylFEbHP1NwUQRvzRrObN29j8rWp+p0FIp5D8wtWzuZ0zCJlGiTTIHN4lerUT08bDzC2ama2+LCZKiYIfUe4yCk= 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=WiWB5YLV; arc=none smtp.client-ip=209.85.210.169 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="WiWB5YLV" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6e09aada5fdso770883b3a.2 for ; Mon, 12 Feb 2024 01:29:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707730193; x=1708334993; 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=WiWB5YLVRDwKvmyrP8rs+BuErWtnfxV+TKjPHrsXDxrKHmLEYnWp46U3XVRf1iBcLD IZ51ZCYTA/+Vo7HbWga3Rf5xm39n+KUBobaH1NQlE2nxhuhxP7itsNo8CAOAj00wH9wb 4KQLBV4yhRqeigVC8VRq8owUhlv63NUxTD/LsRl0OqbC7TW7vHuys+4zhW/1Y/gK+2eQ YvGmu7fivKjZUprOQWlhGw+DjUwB8HI36sDEjhW2UzpbxUfksZ/cVITdgZB+yAAQ3DFH KFr6pUzctCv6OFS0JET62q8UyAuvQACs7t9b14wxjLyq9+quUa2he4XHl9YWBSwDqWbK u5qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707730193; x=1708334993; 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=HOjJndntMMoDfR0kFRVzKBbE6egg+pTuE8D3PSTmHtbRVm2ehMgX6E/ZQw2yd+F03k c/P7+N/mEuXhR5F3iQPyZ0E6kS/aEfkSkaH37NJGqtD8GO3NzxlQnOu9lhHs/x4uUJ5I uakfBi5l07XL/04jbp7bfDYO6Nj2LuBdIPvK8THEI/OAJpUVSVAhIWW6YxmeMAaGb9+b TUNhd7VubAw/3Vqzk+XGX+lNG23UZ028+uLSBjr/K9/2ln/mR53PL22CW6Dca/QjpDIc WKVZbGDUqqpHnaNo3Ax2GbKg0z1AvtgGQbHt3072MlCcfiKpkfttretBsFX7/I5fbNhP vphQ== X-Gm-Message-State: AOJu0YwSICyxM63R0E42kL7Q3B6mteKh6StjYY8gdom3BrPAbEaXQ3oy Ao8tXJrAlo09KwmiMGsB2WAQcaqovbsoFoqi3lRzIvE7Z3Tgx2lG X-Google-Smtp-Source: AGHT+IEF7TT6ZIgtSaE2JtBV9Mx9e6WQBAJQ/rVBGWlLdybBHdqQzQR4yM1uoQVkjjQXE/9eENaLiw== X-Received: by 2002:a17:902:d4c9:b0:1da:2390:c6c8 with SMTP id o9-20020a170902d4c900b001da2390c6c8mr4238563plg.57.1707730193225; Mon, 12 Feb 2024 01:29:53 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVDQ3/NFbyFggEP27K5Ap2PZVqys/ua0KwAGp7CXgLzooMsApucuxdjr+rCCNI6sLngYkvoiIdfl5basIkcOiGWdNeh1c1wfgow8xMqDexgKQBcrcvY1TOTCCcQxjHWO7mmyCm1NChChl91dWtY/L+sVK7cwT2RwgTC+2OA45U6sHtxqVkEjLE3RRqxqXQKF+WtxEJ+dyT1mnVi43WT3K++/m/Q6zpLzW0HSdaWRd4= Received: from KERNELXING-MB0.tencent.com ([14.108.143.251]) by smtp.gmail.com with ESMTPSA id mg12-20020a170903348c00b001da18699120sm4220211plb.43.2024.02.12.01.29.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 01:29:52 -0800 (PST) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org Cc: netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v3 5/6] tcp: make dropreason in tcp_child_process() work Date: Mon, 12 Feb 2024 17:28:26 +0800 Message-Id: <20240212092827.75378-6-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240212092827.75378-1-kerneljasonxing@gmail.com> References: <20240212092827.75378-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 Mon Feb 12 09:28:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13552854 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.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 0AAD817560 for ; Mon, 12 Feb 2024 09:29:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707730199; cv=none; b=pbvvN54F4Q29FMAlr2boHMuIYkQF8EUxYV3XExt200n9LEGOZ3udZRLhyJIz/wQZ8yRR4PrYwxOEz/pawQxpmBTMvCW/xWNahQDoinf5iNGHEKuFqzyY6Rh4YwXjbDvVENSrofOfB2V/rPvV5kHZuzd7AYurLcsLnzhAICVA5hg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707730199; c=relaxed/simple; bh=TStINRVFhm9HzVI+/oSLRgbCmC3937DPOtZqDEpQyOo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nV0w1jYcOJyMiUFJKBFjg7E5sUr4wMuRiuo6VYrfJjTJ0wrVexQFriozKGnxySUkgYD13sLYQ6kXF0UVzEkCZoBWgt+1uHvj1pWHvqixe0zcW12q9jhWQNVbFGFD5HBR3odyH4ewvvrnRus2LyKQ4EYPC7i1y20yXiE7Vi/YXZw= 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=TGOAPQRA; arc=none smtp.client-ip=209.85.214.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="TGOAPQRA" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1d746856d85so21711015ad.0 for ; Mon, 12 Feb 2024 01:29:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707730197; x=1708334997; 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=TGOAPQRARUpNXphmQxkklVxlWpk8cP90eAD+nOBZv6cR6a6k4vR0QptC+JxBtaEKP6 jcW65ZJUZCSAmCK0wCYkBY2IwHGguV526CWgzQ+E8fvAPaXA3wP5DJUw3uNOjzwkNa7r 3M9KvybaAlCd5/Z1ijVvhNPFJ8Upi26TczNtBnTOcJUy8cb5/m22BfUqKWTdgMt5y7iS Ge20a5k8M8yqDziY5b6lR0A2XLciQs1Lvjvp7lCbrMy9O08oDb1T9x0FpeYYII9aY57g SdAhY7AVrr00ZwZo2fUqqDc76CTvCXZKNhh1d0vsJ0CdgxdSndhdWr2Pxuza5v60ys+A S5aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707730197; x=1708334997; 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=GpDTOmZclcGc4h6toDxJSUPWamRHFclPh/X4v6KlmWmg8cW3Ul/c/VsrVGAxKaf7nf rkMREA8RwaGTej6XB0SezXMGAVkBrZqwYcxWXfhbZKLyJT2E4WzIJQFw5+X5tnAKiQ0w 6zU5YMJa20hFBSozAza01oIojfPpG5m/hrCvttsGpzsmnRdF2IO7deA+8Qvn8dERlek7 2HY/PUpyTySyhcMBDxHCPpBinYDL1OeuZ59h/VT0h5SVkoyxfTA2gcF941OzfSq5Oi1B a55qOU4KqhFkStuUFLo3CzLpKwvIL01bQJ3/zpUELHY50uvwGzvx0YN7mEURHyZQ/0yL ikuw== X-Gm-Message-State: AOJu0YwIzxHWYmEzF8CGH/5aQbmbHP+UuTz022rgK3wk1/eL++SAcX0r Edwn36I00n8/K2vBNk0ad515vFBWT1kzciiQJpsN3Vfl18Pi7s3h X-Google-Smtp-Source: AGHT+IHsJTEDdXMZVxetFTN8HYeMum+VaNLWhNv/hoFEjgMF/CV6vtPJ+OxhuJzYj6NBiiZES5RNTg== X-Received: by 2002:a17:903:595:b0:1d8:f06f:5cfa with SMTP id jv21-20020a170903059500b001d8f06f5cfamr4617367plb.59.1707730197461; Mon, 12 Feb 2024 01:29:57 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUwCzZOaq7gLAvD+ShZqympOTeF0y41nQLAm7+p07/9BZBf31Ay9XkVT5X77URcCs6LyXXAnc0NQeIDtT+N7MDrZv732YWlRSaaR4lj342viQLJDG/b4z1MqeB0kGP7Qff1vdpabtoPR2Zrf0qch0u7DKRC75TL13wn+c6rME8+MnmcyEGPaMCqXQkEpQXIgD5juKMtmaYzFuc87AkzldtFVpTeZJ9CkFU31iLmA90= Received: from KERNELXING-MB0.tencent.com ([14.108.143.251]) by smtp.gmail.com with ESMTPSA id mg12-20020a170903348c00b001da18699120sm4220211plb.43.2024.02.12.01.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 01:29:56 -0800 (PST) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org Cc: netdev@vger.kernel.org, kerneljasonxing@gmail.com, Jason Xing Subject: [PATCH net-next v3 6/6] tcp: get rid of NOT_SEPCIFIED reason in tcp_v4/6_do_rcv Date: Mon, 12 Feb 2024 17:28:27 +0800 Message-Id: <20240212092827.75378-7-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240212092827.75378-1-kerneljasonxing@gmail.com> References: <20240212092827.75378-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;