netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Menglong Dong <menglong8.dong@gmail.com>
To: David Ahern <dsahern@gmail.com>
Cc: David Ahern <dsahern@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	mingo@redhat.com, David Miller <davem@davemloft.net>,
	Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
	pablo@netfilter.org, kadlec@netfilter.org,
	Florian Westphal <fw@strlen.de>,
	Menglong Dong <imagedong@tencent.com>,
	Eric Dumazet <edumazet@google.com>,
	alobakin@pm.me, paulb@nvidia.com,
	Kees Cook <keescook@chromium.org>,
	talalahmad@google.com, haokexin@gmail.com, memxor@gmail.com,
	LKML <linux-kernel@vger.kernel.org>,
	netdev <netdev@vger.kernel.org>,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	Cong Wang <cong.wang@bytedance.com>
Subject: Re: [PATCH v3 net-next 1/7] net: skb_drop_reason: add document for drop reasons
Date: Thu, 10 Feb 2022 11:19:49 +0800	[thread overview]
Message-ID: <CADxym3akuxC_Cr07Vzvv+BD55XgMEx7nqU4qW8WHowGR0jeoOQ@mail.gmail.com> (raw)
In-Reply-To: <0029e650-3f38-989b-74a3-58c512d63f6b@gmail.com>

Hello!

On Tue, Feb 1, 2022 at 1:14 AM David Ahern <dsahern@gmail.com> wrote:
>
> On 1/28/22 12:33 AM, menglong8.dong@gmail.com wrote:
> > From: Menglong Dong <imagedong@tencent.com>
> >
> > Add document for following existing drop reasons:
> >
> > SKB_DROP_REASON_NOT_SPECIFIED
> > SKB_DROP_REASON_NO_SOCKET
> > SKB_DROP_REASON_PKT_TOO_SMALL
> > SKB_DROP_REASON_TCP_CSUM
> > SKB_DROP_REASON_SOCKET_FILTER
> > SKB_DROP_REASON_UDP_CSUM
> >
> > Signed-off-by: Menglong Dong <imagedong@tencent.com>
> > ---
> >  include/linux/skbuff.h | 12 ++++++------
> >  1 file changed, 6 insertions(+), 6 deletions(-)
> >
>
> Reviewed-by: David Ahern <dsahern@kernel.org>
>
>

I'm doing the job of using kfree_skb_reason() for the TCP layer,
and I have some puzzles.

When collecting drop reason for tcp_v4_inbound_md5_hash() in
tcp_v4_rcv(), I come up with 2 ways:

First way: pass the address of reason to tcp_v4_inbound_md5_hash()
like this:

 static bool tcp_v4_inbound_md5_hash(const struct sock *sk,
                      const struct sk_buff *skb,
-                    int dif, int sdif)
+                    int dif, int sdif,
+                    enum skb_drop_reason *reason)

This can work, but many functions like tcp_v4_inbound_md5_hash()
need to do such a change.

Second way: introduce a 'drop_reason' field to 'struct sk_buff'. Therefore,
drop reason can be set by 'skb->drop_reason = SKB_DROP_REASON_XXX'
anywhere.

For TCP, there are many cases where you can't get a drop reason in
the place where skb is freed, so I think there needs to be a way to
deeply collect drop reasons. The second can resolve this problem
easily, but extra fields may have performance problems.

Do you have some better ideas?

Thanks!
Menglong Dong

  reply	other threads:[~2022-02-10  3:24 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-28  7:33 [PATCH v3 net-next 0/7] net: use kfree_skb_reason() for ip/udp packet receive menglong8.dong
2022-01-28  7:33 ` [PATCH v3 net-next 1/7] net: skb_drop_reason: add document for drop reasons menglong8.dong
2022-01-31 17:14   ` David Ahern
2022-02-10  3:19     ` Menglong Dong [this message]
2022-02-10  5:12       ` Jakub Kicinski
2022-02-10 13:42         ` Menglong Dong
2022-02-10 16:13           ` Jakub Kicinski
2022-02-10 16:29             ` Eric Dumazet
2022-02-11  8:53               ` Menglong Dong
2022-02-11  8:49             ` Menglong Dong
2022-01-28  7:33 ` [PATCH v3 net-next 2/7] net: netfilter: use kfree_drop_reason() for NF_DROP menglong8.dong
2022-01-28  7:33 ` [PATCH v3 net-next 3/7] net: ipv4: use kfree_skb_reason() in ip_rcv_core() menglong8.dong
2022-01-31 18:05   ` David Ahern
2022-02-04 14:42     ` Menglong Dong
2022-01-28  7:33 ` [PATCH v3 net-next 4/7] net: ipv4: use kfree_skb_reason() in ip_rcv_finish_core() menglong8.dong
2022-01-31 17:45   ` David Ahern
2022-01-28  7:33 ` [PATCH v3 net-next 5/7] net: ipv4: use kfree_skb_reason() in ip_protocol_deliver_rcu() menglong8.dong
2022-01-31 17:49   ` David Ahern
2022-01-28  7:33 ` [PATCH v3 net-next 6/7] net: udp: use kfree_skb_reason() in udp_queue_rcv_one_skb() menglong8.dong
2022-01-31 17:50   ` David Ahern
2022-01-28  7:33 ` [PATCH v3 net-next 7/7] net: udp: use kfree_skb_reason() in __udp_queue_rcv_skb() menglong8.dong
2022-01-31 17:53   ` David Ahern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADxym3akuxC_Cr07Vzvv+BD55XgMEx7nqU4qW8WHowGR0jeoOQ@mail.gmail.com \
    --to=menglong8.dong@gmail.com \
    --cc=alobakin@pm.me \
    --cc=cong.wang@bytedance.com \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=haokexin@gmail.com \
    --cc=imagedong@tencent.com \
    --cc=kadlec@netfilter.org \
    --cc=keescook@chromium.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=memxor@gmail.com \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=paulb@nvidia.com \
    --cc=rostedt@goodmis.org \
    --cc=talalahmad@google.com \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).