From patchwork Sat Oct 29 13:09:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12706 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1342577wru; Sat, 29 Oct 2022 06:14:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4l7Jlygk+srCKlCIMfnxH/KvUFg3X6M80cCScA0KBlznriCd8hOyfgHV1umOjjY8S4Enhu X-Received: by 2002:a17:902:e902:b0:186:9c03:5f27 with SMTP id k2-20020a170902e90200b001869c035f27mr4339544pld.16.1667049264591; Sat, 29 Oct 2022 06:14:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667049264; cv=none; d=google.com; s=arc-20160816; b=WueBNYO4wVxVHNBiRn4wN23cfj1NJpCyh40klTtDDfewxkO4lwroycbdQmtNvUijOT gxuZsLh9oG/eZMtMuNsKst8cAYuh39UlLnvdaRKPDzAdwYT6AMl0TQ8Ejwj/sBWKW5c0 D2VzWdxXI4MujJFIolAUNPmVDxcmVUtccYeE4njxxTEocHp2wYXSnUKhQbhrdHVlYzHy c4QApskTPbM6EAIKuLt7QuaM2iaKphxet3MnR2bXp8X6dxPU4RC0bbDpzjZrlCWncCTo i9oleG9NzHXJP73Sfq4kOsN0gN2TEcqPaUwM4yGrIvuafiJAGTqnr/nSg0+dSyqTfnic JVmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vssy2QIzKmHydtkjFhF+7Vo85h49gdfydYy5+cmw3Ec=; b=ooruIrA0wT5QnNExdjtO3Xm4azf9wBQEXbgigne0U48f3+nok/nRJOAS3iqaG5r+Tp 2Fx/ceafd3p0XnRpz3go8WS5ycNKXe5+khhc/PjC4rpT/40I/RyAwgdLBkhEvVxMAIyY 2k0thqHknYLKWNIlA2+c1iAsFQ7jZVworgkxkuS52+vcDBibzcSiWAuYO84iNmwB8QTM tkEWnma0G+1gCimeVR3fp3FqoHMnRL6KRSwoD6gAuCS8/7+dmDMpA5nCdexPFjb5YeY9 XYkZCXU1cs5VXA6UAXXmQdZp0HX+FOLbGr+vJA5TZN/oISW1aMreTFdjmOehmkoFbAcM GgBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VecOJpnf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 198-20020a6217cf000000b0056349604a6bsi1541517pfx.334.2022.10.29.06.14.10; Sat, 29 Oct 2022 06:14:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VecOJpnf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229932AbiJ2NML (ORCPT + 99 others); Sat, 29 Oct 2022 09:12:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229937AbiJ2NLo (ORCPT ); Sat, 29 Oct 2022 09:11:44 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A4816A486; Sat, 29 Oct 2022 06:11:30 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id f193so7107760pgc.0; Sat, 29 Oct 2022 06:11:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=vssy2QIzKmHydtkjFhF+7Vo85h49gdfydYy5+cmw3Ec=; b=VecOJpnfnlcWgbsOAt8v7vlGdj9AvfBevtzjZeCqGGjrUrzbs0IEPmeJcf94/m72S1 hiWqVPJQFsFjNAMuIKjoXmhq9OFFVhPkdS/DcnzNPIzxdclHeET0prVMIaNTT4cdnCVN S8ciX2rdIZsRkCgsb9heNWDw0jQXc31HV15n/3Ab75dinK7L5sjpeTA1slH3TyE5UoAU TWLyj2gNWNr1/iH/w9qyEf3PJF75Jba/53NLjI+orO093uZtVlPI5Odb0LthCBWZlKAP XLcFdqS37qUqI57NVYABzR0pK1BQfOSvCjKbFseNzm0oWOHgwCTDUIRtpmSH5mqQKpOF AJMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=vssy2QIzKmHydtkjFhF+7Vo85h49gdfydYy5+cmw3Ec=; b=3KKSx75o6TT/WXwthy+8sOViF4Kh4qRQteUYt+RnqTZxFb0Vdc41gP2mQxmEnbnd6z 6cI0qLTkADKtcRZ9VQ2Wl7f4uj1NQ5e1+QOuoTyISccMv2ETLBqR8vqER5USUvI7p1iH kqlEqCHaC8Hgb2/AhPOOOa8YGlbhJztOkgC+JyD3zwZlfEwNJIF3ivkGIu4bSPcF2CEW SIO/MNwyNgFrPMzV5IaBxBpDlyraRPIIDQtwo3oEebbUAOy6jBCQ3/chMuHEVwgnbQ1i Rs1BFgqRFqIkHOCINCcP97+Wnk58MAqzQbqx0wphepXfMfsAVvR0J7F50GUc2EGkQz4J sVxg== X-Gm-Message-State: ACrzQf0ASv8TsLUQ5hKQ7mDIWnHI8/ynLU/YrzIswCto7PKwyFPI73hn /N79GyP7PaoLLCz9v20XXJw= X-Received: by 2002:a05:6a00:1912:b0:564:f6be:11fd with SMTP id y18-20020a056a00191200b00564f6be11fdmr4492077pfi.32.1667049089869; Sat, 29 Oct 2022 06:11:29 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.21]) by smtp.gmail.com with ESMTPSA id s7-20020a170902988700b001811a197797sm1244069plp.194.2022.10.29.06.11.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 06:11:29 -0700 (PDT) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: edumazet@google.com, kuba@kernel.org Cc: davem@davemloft.net, pabeni@redhat.com, yoshfuji@linux-ipv6.org, dsahern@kernel.org, imagedong@tencent.com, kafai@fb.com, asml.silence@gmail.com, keescook@chromium.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next 7/9] net: tcp: store drop reasons in tcp_rcv_state_process() Date: Sat, 29 Oct 2022 21:09:55 +0800 Message-Id: <20221029130957.1292060-8-imagedong@tencent.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221029130957.1292060-1-imagedong@tencent.com> References: <20221029130957.1292060-1-imagedong@tencent.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748027849680034056?= X-GMAIL-MSGID: =?utf-8?q?1748027849680034056?= From: Menglong Dong Store the drop reasons for skb to the tcp_skb_cb in tcp_rcv_state_process() when it returns non-zero, which means that the skb need to be dropped. The new drop reasons 'TCP_ABORTONDATA' and 'TCP_ABORTONLINGER' are added. Signed-off-by: Menglong Dong --- include/net/dropreason.h | 12 ++++++++++++ net/ipv4/tcp_input.c | 11 +++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/net/dropreason.h b/include/net/dropreason.h index 633a05c95026..364811bce63f 100644 --- a/include/net/dropreason.h +++ b/include/net/dropreason.h @@ -72,6 +72,8 @@ FN(TIMEWAIT) \ FN(LISTENOVERFLOWS) \ FN(TCP_REQQFULLDROP) \ + FN(TCP_ABORTONDATA) \ + FN(TCP_ABORTONLINGER) \ FNe(MAX) /** @@ -324,6 +326,16 @@ enum skb_drop_reason { * socket is full, corresponding to LINUX_MIB_TCPREQQFULLDROP */ SKB_DROP_REASON_TCP_REQQFULLDROP, + /** + * @SKB_DROP_REASON_TCP_ABORTONDATA: corresponding to + * LINUX_MIB_TCPABORTONDATA + */ + SKB_DROP_REASON_TCP_ABORTONDATA, + /** + * @SKB_DROP_REASON_TCP_ABORTONLINGER: corresponding to + * LINUX_MIB_TCPABORTONLINGER + */ + SKB_DROP_REASON_TCP_ABORTONLINGER, /** * @SKB_DROP_REASON_MAX: the maximum of drop reason, which shouldn't be * used as a real 'reason' diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index ad088e228b1e..e08842f999f8 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -6459,8 +6459,10 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) goto discard; case TCP_LISTEN: - if (th->ack) + if (th->ack) { + TCP_SKB_DR(skb, TCP_FLAGS); return 1; + } if (th->rst) { SKB_DR_SET(reason, TCP_RESET); @@ -6533,8 +6535,10 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) FLAG_NO_CHALLENGE_ACK) > 0; if (!acceptable) { - if (sk->sk_state == TCP_SYN_RECV) + if (sk->sk_state == TCP_SYN_RECV) { + TCP_SKB_DR(skb, TCP_FLAGS); return 1; /* send one RST */ + } tcp_send_challenge_ack(sk); SKB_DR_SET(reason, TCP_OLD_ACK); goto discard; @@ -6605,6 +6609,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) if (tp->linger2 < 0) { tcp_done(sk); NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONDATA); + TCP_SKB_DR(skb, TCP_ABORTONLINGER); return 1; } if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq && @@ -6614,6 +6619,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); + TCP_SKB_DR(skb, TCP_ABORTONDATA); return 1; } @@ -6678,6 +6684,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq && after(TCP_SKB_CB(skb)->end_seq - th->fin, tp->rcv_nxt)) { NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONDATA); + TCP_SKB_DR(skb, TCP_ABORTONDATA); tcp_reset(sk, skb); return 1; }