Message ID | 20221029130957.1292060-3-imagedong@tencent.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1341728wru; Sat, 29 Oct 2022 06:12:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7E+OtxazOTQhWLKx6eothyVEvVE14numEiHboD5VcI/bzJdLGfg8+jAADQCkCNsZTHpl85 X-Received: by 2002:a17:90b:4d84:b0:212:c78f:8d6e with SMTP id oj4-20020a17090b4d8400b00212c78f8d6emr4559552pjb.201.1667049147315; Sat, 29 Oct 2022 06:12:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667049147; cv=none; d=google.com; s=arc-20160816; b=OJaiLy9F4luNnlD25tS7Csb1IN9MxJvmUahkec4lkBqHaIS+dQ2agDYUvFRjFC/lr4 zVsc8nGQJUwyHT1qS2zZO86ZeJefjPDUR2c28rHFwyUow9TYaUuwUSwJ/Lc270befpUR S1S74D86i4rCS/k4weEI1VDCNdjSl5Qp6HoMQ6BlQI9sZhlV+v1XLrtX89si+1NAh0js eai/F/2aGExwydD1VA7WZod229XYqhQvKLQSPjjhtOW3BmSHgroqhJ5DsjXkTMn0ESnb YU5J1H85GeRy61saz59bcZDWuDxeZ11xd/at1/9lEBRoEQfOn9nDsPhc33ONU5sZsXlP +H5Q== 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=DZK5NQKMxu7Q7E+ji+/bWQancP2wJOHTkQ/B4KtPPIU=; b=VwBG9+SPtNvZwJyOzhemUod2Dg+XjZHyONBpy38YeykSoryWF0Ni3qQqUbbrMuXnkL WOVDJ0wWg36BmC+UeSFK8ds7zoFdcyp6MdTdsq/tKH4cYCa+OvrcYhb6L4ZauBCzFXeq Ugrr3klcYfsm7ycwEbiT9MYCU4NXG3ub++56W7ARrNA+Mq9XTbPdk4zNCCsAPpwHD61H 4+ZcRcw4SJIM8m1TXJPSUcgh6xVLiBafE/RSujT9DMeSS1sY25AWjyqr3QVjlZ0kDBkj Nn9HMxEuI3s2+l6blAU8NCuRqFGVkE+wZV3Q0BZuivDMsXJO8JUJmMb6vo6MZ9TgK9uf 4x/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FJ7o32Gl; 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 o4-20020a170902d4c400b0017e6e415520si2450644plg.292.2022.10.29.06.12.14; Sat, 29 Oct 2022 06:12:27 -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=FJ7o32Gl; 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 S229875AbiJ2NLY (ORCPT <rfc822;pusanteemu@gmail.com> + 99 others); Sat, 29 Oct 2022 09:11:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229777AbiJ2NLS (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 29 Oct 2022 09:11:18 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C51C46918F; Sat, 29 Oct 2022 06:11:11 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id h2so7076622pgp.4; Sat, 29 Oct 2022 06:11:11 -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=DZK5NQKMxu7Q7E+ji+/bWQancP2wJOHTkQ/B4KtPPIU=; b=FJ7o32Gllk7KI9sdfQ2eYONOatmIj1khojCKJVqftg8E5DWx6Ty8537rzVV2hveavq v6SF1dVE4KOC38S/3jV7BjoKPuHcSN3NhrmjaaS0BS+ri8Y0a86jh7nxZJdQ4FMCsVBV FB6wKOOSWUaJ4rsPjRmIK0LXT3JGJ70D7vC1osZbAcVn6teIGyUZHkNXIozn5NkK6Hun Yuq0xdxiG2yLaEbkcS+HR5SArtJj1dH58kUSyvWNIY8rWHsydHO3c0tyiQ6g0Ut8711j ZDeiw+iIrJhIzXBAjAgXIt5wuzoy2ZBfiuUN9uwYLmNIjtAe9VcAp64hPHc86iikMlR2 hkIw== 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=DZK5NQKMxu7Q7E+ji+/bWQancP2wJOHTkQ/B4KtPPIU=; b=6xx+DfBzK7bBsxM6QV4hz1bmEkdrHmmDUp8VFjGXWoqgCiglnx66lHNTyTa9DnbsYV UEZKcUffy82E1q0tFsMHtuJCIEmwyIW9qbSh5TfzTHgQQAJu0YQqbvm1GssXi9pkKuVY CCUazm+yqe1cpmJ7fLG2w4SVG38/5zbauHV7dw6L+nMSqkr4NgKpzV6harqDbZ6ONMzH ESnqjS9UCbD8tB9bHCiqKrjxsf+McEHPuavUznn/UrmS45xU2SbNleJPmwbW8cj9bpZz r6KRzRwyTqldAO/5BIwfGVALErHDMIdHv7AWlNjZ0OuTfAbIZ5V6NPiqqXSHG3Yj7Yv/ GB2Q== X-Gm-Message-State: ACrzQf1KG5atgFFVu6XimgS8wU0IpKZKou11u890LVLIixbDAic5Ksck sinEgkMYE02OVHjJ8peAmoY= X-Received: by 2002:a62:19cd:0:b0:56b:6a55:ffba with SMTP id 196-20020a6219cd000000b0056b6a55ffbamr4259598pfz.85.1667049071233; Sat, 29 Oct 2022 06:11:11 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 06:11:10 -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 2/9] net: tcp: add 'drop_reason' field to struct tcp_skb_cb Date: Sat, 29 Oct 2022 21:09:50 +0800 Message-Id: <20221029130957.1292060-3-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 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748027726406669136?= X-GMAIL-MSGID: =?utf-8?q?1748027726406669136?= |
Series |
net: tcp: add skb drop reasons to tcp state process
|
|
Commit Message
Menglong Dong
Oct. 29, 2022, 1:09 p.m. UTC
From: Menglong Dong <imagedong@tencent.com> Because of the long call chain on processing skb in TCP protocol, it's hard to pass the drop reason to the code where the skb is freed. Therefore, we can store the drop reason to skb->cb, and pass it to kfree_skb_reason(). I'm lucky, the struct tcp_skb_cb still has 4 bytes spare space for this purpose. Signed-off-by: Menglong Dong <imagedong@tencent.com> --- include/net/tcp.h | 3 +++ 1 file changed, 3 insertions(+)
Comments
On Sat, Oct 29, 2022 at 6:11 AM <menglong8.dong@gmail.com> wrote: > > From: Menglong Dong <imagedong@tencent.com> > > Because of the long call chain on processing skb in TCP protocol, it's > hard to pass the drop reason to the code where the skb is freed. > > Therefore, we can store the drop reason to skb->cb, and pass it to > kfree_skb_reason(). I'm lucky, the struct tcp_skb_cb still has 4 bytes > spare space for this purpose. No, we have needs for this space for future use. skb->cb[] purpose is to store semi-permanent info, for skbs that stay in a queue. Here, you need a state stored only in the context of the current context. Stack variables are better.
Hello, On Sat, Oct 29, 2022 at 11:23 PM Eric Dumazet <edumazet@google.com> wrote: > > On Sat, Oct 29, 2022 at 6:11 AM <menglong8.dong@gmail.com> wrote: > > > > From: Menglong Dong <imagedong@tencent.com> > > > > Because of the long call chain on processing skb in TCP protocol, it's > > hard to pass the drop reason to the code where the skb is freed. > > > > Therefore, we can store the drop reason to skb->cb, and pass it to > > kfree_skb_reason(). I'm lucky, the struct tcp_skb_cb still has 4 bytes > > spare space for this purpose. > > No, we have needs for this space for future use. > > skb->cb[] purpose is to store semi-permanent info, for skbs that stay > in a queue. > May I use it for a while? Or, can I make it a union with some field, such as 'header'? As the 'drop_reason' field will be set only if it is going to be freed. > Here, you need a state stored only in the context of the current context. > Stack variables are better. It's hard to get the drop reason through stack variables, especially some functions in TCP protocol, such as: tcp_rcv_synsent_state_process tcp_timewait_state_process tcp_conn_request tcp_rcv_state_process And it will mess the code a little up, just like what you comment in this series: https://lore.kernel.org/netdev/20220617100514.7230-1-imagedong@tencent.com/ I hope to complete this part, or I think I can't move ahead :/ Thanks! Menglong Dong
diff --git a/include/net/tcp.h b/include/net/tcp.h index 14d45661a84d..0b6e39ca83b4 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -888,6 +888,7 @@ struct tcp_skb_cb { has_rxtstamp:1, /* SKB has a RX timestamp */ unused:5; __u32 ack_seq; /* Sequence number ACK'd */ + enum skb_drop_reason drop_reason; /* Why skb is dropped */ union { struct { #define TCPCB_DELIVERED_CE_MASK ((1U<<20) - 1) @@ -912,6 +913,8 @@ struct tcp_skb_cb { }; #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0])) +#define TCP_SKB_DR(__skb, reason) \ + (TCP_SKB_CB(__skb)->drop_reason = SKB_DROP_REASON_##reason) extern const struct inet_connection_sock_af_ops ipv4_specific;