Received: by 2002:a05:6358:795:b0:dc:4c66:fc3e with SMTP id n21csp476131rwj; Sat, 29 Oct 2022 06:12:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6i82TKGaewK9+UcF1EuT2wWA7CppKgN7w6m5XkZjyvR12b1ubYsDJRdXFX2gckx40kPJjD X-Received: by 2002:a05:6a00:234c:b0:56c:f6e6:976 with SMTP id j12-20020a056a00234c00b0056cf6e60976mr4454867pfj.32.1667049151293; Sat, 29 Oct 2022 06:12:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667049151; cv=none; d=google.com; s=arc-20160816; b=awvPA71Ms5U1YepmjzrtB1FawDIE298d007LH5grrgsrZqWVTUMzeanB5by7tloyje dgeExU+REF36Lhft24oQX0npGBIZSvMxr9ZubxLPvHPzFY6ocwhIFqBJ6Jjj89swIpbY QtX5p27+NDyBeH6md8O32SoGpi49IaHajdGxcAeogIcwrxhiRTmbbycPKF72b3jmC23I VtVvC+Ms/eJtVT/wcOky18MX+zS7g042KiR994nh87TOQidVp7MtEn0lol5Hf4i3Mwh1 8Phj3v3MO6XTnrAhyEUzQKz+R3s32eI0gsP0Y2XJ4beCkp42ftAmdpZGomdYZkrrG6Ny kVoA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=A9kU2QGc/0/ct5xSbAsmcvV4JkwDQsSv77UPsHyGLgg=; b=EO3jzcmd1/F1oX/PyBQBjG63XpZ+gqIgIE9pBwRHw7fqc07Kchiuk0dqGqj496M/hO /Yo53iPfq/QZRhM2KIUhoosoEA5R4jpK8WuZIc3PPDv0PH29NqqDc9fR0f4GfgIZjBN7 JvQtJIEdSs9SD9VxQe/ECMy4TFbtkL5MiZxdZE9fytlsLfdc7sIW3yyCnS3WUYMm+Nbt 8a/lxyMPlpmWBfWlC5uuTySBfeWBMx+KJo+1mMSBM3UJj3KYhohPakmnOBjKINwH3NbH jTohdDMXmX4F7KSEu01CwAi/rKptJov4MU4ZbbHxGSwcsYmiTLxxI2S/fwhbGie3tCnb xaEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=K8MHO0bw; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be1-20020a656e41000000b0043c01032729si1993927pgb.666.2022.10.29.06.12.20; Sat, 29 Oct 2022 06:12:31 -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=K8MHO0bw; 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 S229711AbiJ2NLH (ORCPT + 99 others); Sat, 29 Oct 2022 09:11:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbiJ2NLE (ORCPT ); Sat, 29 Oct 2022 09:11:04 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22B0467159; Sat, 29 Oct 2022 06:11:03 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id m6-20020a17090a5a4600b00212f8dffec9so6775530pji.0; Sat, 29 Oct 2022 06:11:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=A9kU2QGc/0/ct5xSbAsmcvV4JkwDQsSv77UPsHyGLgg=; b=K8MHO0bwXeJg5od0MtZYgwV6otQlasdfjhSkUFzZwwpzrv9ZmWPnvpRm4sG9CPAfq9 IjkhYKDMuKHtk/wS3e5yjapgEwJfL7i+p6IVaWXHf8rBXi51Pt+IW3oTTIzrckFEaQ2Z yq9PnSbHTYqbxsfdQJKTnb0FyigiA/5xBNgOCJAn0e+WfpbVriy4LbewgZ3Mc3vZNlA9 B0hj8i88RBH3ObhguFzPBibmIfKQ97HjOgHD71VuHskrtBJ1UJlJvLFvbfTnBL+eCNQ0 izr4cQIKbodv7Tbs/WTT8rEfD+YIdpWPUPNszqjtt6KcfKxLW2mTp3zrzu0xkU4JEXqz Rr7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=A9kU2QGc/0/ct5xSbAsmcvV4JkwDQsSv77UPsHyGLgg=; b=d5nDXNwzmw7Pvs0M6baIdauqri7nOymkwjY2jrdeYGc3KlrAMNHIqDcSPo1BnfG37z rkFbyjW4s430SikZsftDCRVwOJD+Jin6pEseibE7hbcEbjuZoPCIiYB97Otc3xE1HA90 T3FB0WjlNZbgxS2FmO8fTbkq2ohpxfEyMRKkIF7AHDmvvPU0UrT2lT5QlJJvrgn1ei/T a/ZuQC4LD78IdmtsYtA4Ua3YGNKosp8NLspzsjUPZgL8kvCk4fdeMK4ulg6jsB8QJgu7 SEsnoqk4ehDMFfLib1W1sc9F/dHEas3+h/Z7T7sI1+GojHG6D23BYPrsqfRnPI+qy2tJ YgQA== X-Gm-Message-State: ACrzQf0jASvd6A6LepKlis96tXFfDypx7XC3JbURRCOjo2HFK1DfDoSa 1/vAwsFgK7IKCzZngHYr5X4= X-Received: by 2002:a17:90a:74cb:b0:213:9b4c:ecc2 with SMTP id p11-20020a17090a74cb00b002139b4cecc2mr4756680pjl.154.1667049062614; Sat, 29 Oct 2022 06:11:02 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.21]) by smtp.gmail.com with ESMTPSA id s7-20020a170902988700b001811a197797sm1244069plp.194.2022.10.29.06.10.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 06:11:01 -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 0/9] net: tcp: add skb drop reasons to tcp state process Date: Sat, 29 Oct 2022 21:09:48 +0800 Message-Id: <20221029130957.1292060-1-imagedong@tencent.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Menglong Dong For now, the skb drop reasons have not fully be supported by TCP protocol on the code path of TCP connection state change. The function call chain is a little complex, which makes it hard to get the reason that why skb is dropped. However, I have a idea now: store the drop reason in the tcp_skb_cb, which means that we need to add a 'drop_reason' field to the struct tcp_skb_cb. Luckily, this struct still has 4 bytes spare space for this purpose. In this way, we need only to initialize to 'TCP_SKB_CB(skb)->drop_reason' to SKB_DROP_REASON_NOT_SPECIFIED in tcp_v4_rcv()/tcp_v6_rcv(). When the skb needs to be dropped, the value of this field should be the drop reason or SKB_DROP_REASON_NOT_SPECIFIED. Meanwhile, the value also can be SKB_NOT_DROPPED_YET. On such case, try_kfree_skb(), which we add in the 1th patch, should be called. Hi, Eric, do you like it? In this way, we almost don't need to change the exist code, and won't mess the code up. In this series, the skb drop reasons are added following functions: tcp_rcv_synsent_state_process tcp_timewait_state_process tcp_conn_request tcp_rcv_state_process And following new drop reasons are added: SKB_DROP_REASON_TCP_PAWSACTIVEREJECTED SKB_DROP_REASON_TIMEWAIT SKB_DROP_REASON_LISTENOVERFLOWS SKB_DROP_REASON_TCP_REQQFULLDROP SKB_DROP_REASON_TCP_ABORTONDATA SKB_DROP_REASON_TCP_ABORTONLINGER SKB_DROP_REASON_LSM Menglong Dong (9): net: skb: introduce try_kfree_skb() net: tcp: add 'drop_reason' field to struct tcp_skb_cb net: tcp: use the drop reasons stored in tcp_skb_cb net: tcp: store drop reasons in tcp_rcv_synsent_state_process() net: tcp: store drop reasons in tcp_timewait_state_process() net: tcp: store drop reasons in tcp_conn_request() net: tcp: store drop reasons in tcp_rcv_state_process() net: tcp: store drop reasons in route_req net: tcp: use LINUX_MIB_TCPABORTONLINGER in tcp_rcv_state_process() include/linux/skbuff.h | 9 +++++++++ include/net/dropreason.h | 43 ++++++++++++++++++++++++++++++++++++++++ include/net/tcp.h | 3 +++ net/ipv4/tcp_input.c | 29 ++++++++++++++++++++++----- net/ipv4/tcp_ipv4.c | 26 ++++++++++++++++++++---- net/ipv4/tcp_minisocks.c | 15 ++++++++++++-- net/ipv6/tcp_ipv6.c | 31 +++++++++++++++++++++++------ 7 files changed, 139 insertions(+), 17 deletions(-) -- 2.37.2