diff mbox series

[net-next,1/9] net: tcp: introduce tcp_drop_reason()

Message ID 20220216035426.2233808-2-imagedong@tencent.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: add skb drop reasons to TCP packet receive | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/cc_maintainers warning 5 maintainers not CCed: andrii@kernel.org kpsingh@kernel.org kafai@fb.com songliubraving@fb.com yhs@fb.com
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline fail Was 0 now: 1

Commit Message

Menglong Dong Feb. 16, 2022, 3:54 a.m. UTC
From: Menglong Dong <imagedong@tencent.com>

For TCP protocol, tcp_drop() is used to free the skb when it needs
to be dropped. To make use of kfree_skb_reason() and pass the drop
reason to it, introduce the function tcp_drop_reason(). Meanwhile,
make tcp_drop() an inline call to tcp_drop_reason().

Signed-off-by: Menglong Dong <imagedong@tencent.com>
---
 net/ipv4/tcp_input.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Jakub Kicinski Feb. 16, 2022, 3:58 p.m. UTC | #1
On Wed, 16 Feb 2022 11:54:18 +0800 menglong8.dong@gmail.com wrote:
> +static inline void tcp_drop(struct sock *sk, struct sk_buff *skb)
> +{
> +	tcp_drop_reason(sk, skb, SKB_DROP_REASON_NOT_SPECIFIED);
>  }

Please make this non-inline. The compiler will inline it anyway, and 
if it's a static inline compiler will not warn us that it should be
removed once all callers are gone.
Steven Rostedt Feb. 16, 2022, 4:50 p.m. UTC | #2
On Wed, 16 Feb 2022 07:58:21 -0800
Jakub Kicinski <kuba@kernel.org> wrote:

> On Wed, 16 Feb 2022 11:54:18 +0800 menglong8.dong@gmail.com wrote:
> > +static inline void tcp_drop(struct sock *sk, struct sk_buff *skb)
> > +{
> > +	tcp_drop_reason(sk, skb, SKB_DROP_REASON_NOT_SPECIFIED);
> >  }  
> 
> Please make this non-inline. The compiler will inline it anyway, and 
> if it's a static inline compiler will not warn us that it should be
> removed once all callers are gone.

I guess that's no longer true for C files.

  https://lore.kernel.org/all/202202132037.4aN017dU-lkp@intel.com/

-- Steve
Menglong Dong Feb. 18, 2022, 2:28 a.m. UTC | #3
On Thu, Feb 17, 2022 at 12:50 AM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Wed, 16 Feb 2022 07:58:21 -0800
> Jakub Kicinski <kuba@kernel.org> wrote:
>
> > On Wed, 16 Feb 2022 11:54:18 +0800 menglong8.dong@gmail.com wrote:
> > > +static inline void tcp_drop(struct sock *sk, struct sk_buff *skb)
> > > +{
> > > +   tcp_drop_reason(sk, skb, SKB_DROP_REASON_NOT_SPECIFIED);
> > >  }
> >
> > Please make this non-inline. The compiler will inline it anyway, and
> > if it's a static inline compiler will not warn us that it should be
> > removed once all callers are gone.
>
> I guess that's no longer true for C files.
>
>   https://lore.kernel.org/all/202202132037.4aN017dU-lkp@intel.com/
>

Ok, seems we can keep this inline still.

> -- Steve
diff mbox series

Patch

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index af94a6d22a9d..0a2740add404 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4684,10 +4684,16 @@  static bool tcp_ooo_try_coalesce(struct sock *sk,
 	return res;
 }
 
-static void tcp_drop(struct sock *sk, struct sk_buff *skb)
+static void tcp_drop_reason(struct sock *sk, struct sk_buff *skb,
+			    enum skb_drop_reason reason)
 {
 	sk_drops_add(sk, skb);
-	__kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
+}
+
+static inline void tcp_drop(struct sock *sk, struct sk_buff *skb)
+{
+	tcp_drop_reason(sk, skb, SKB_DROP_REASON_NOT_SPECIFIED);
 }
 
 /* This one checks to see if we can put data from the