From: menglong8.dong@gmail.com
To: dsahern@kernel.org, kuba@kernel.org, pabeni@redhat.com
Cc: rostedt@goodmis.org, mingo@redhat.com, xeb@mail.ru,
	davem@davemloft.net, yoshfuji@linux-ipv6.org,
	imagedong@tencent.com, edumazet@google.com, kafai@fb.com,
	talalahmad@google.com, keescook@chromium.org, alobakin@pm.me,
	flyingpeng@tencent.com, mengensun@tencent.com,
	dongli.zhang@oracle.com, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, benbjiang@tencent.com
Subject: [PATCH RESEND net-next v5 3/4] net: icmp: introduce __ping_queue_rcv_skb() to report drop reasons
Date: Thu,  7 Apr 2022 14:20:51 +0800	[thread overview]
Message-ID: <20220407062052.15907-4-imagedong@tencent.com> (raw)
In-Reply-To: <20220407062052.15907-1-imagedong@tencent.com>
From: Menglong Dong <imagedong@tencent.com>
In order to avoid to change the return value of ping_queue_rcv_skb(),
introduce the function __ping_queue_rcv_skb(), which is able to report
the reasons of skb drop as its return value, as Paolo suggested.
Meanwhile, make ping_queue_rcv_skb() a simple call to
__ping_queue_rcv_skb().
The kfree_skb() and sock_queue_rcv_skb() used in ping_queue_rcv_skb()
are replaced with kfree_skb_reason() and sock_queue_rcv_skb_reason()
now.
Reviewed-by: Hao Peng <flyingpeng@tencent.com>
Reviewed-by: Jiang Biao <benbjiang@tencent.com>
Signed-off-by: Menglong Dong <imagedong@tencent.com>
---
v4:
- fix the return value problem of ping_queue_rcv_skb()
v3:
- fix aligenment problem
v2:
- introduce __ping_queue_rcv_skb() instead of change the return value
  of ping_queue_rcv_skb()
---
 net/ipv4/ping.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index 3ee947557b88..877270ad17c9 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -934,16 +934,24 @@ int ping_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock,
 }
 EXPORT_SYMBOL_GPL(ping_recvmsg);
 
-int ping_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
+static enum skb_drop_reason __ping_queue_rcv_skb(struct sock *sk,
+						 struct sk_buff *skb)
 {
+	enum skb_drop_reason reason;
+
 	pr_debug("ping_queue_rcv_skb(sk=%p,sk->num=%d,skb=%p)\n",
 		 inet_sk(sk), inet_sk(sk)->inet_num, skb);
-	if (sock_queue_rcv_skb(sk, skb) < 0) {
-		kfree_skb(skb);
+	if (sock_queue_rcv_skb_reason(sk, skb, &reason) < 0) {
+		kfree_skb_reason(skb, reason);
 		pr_debug("ping_queue_rcv_skb -> failed\n");
-		return -1;
+		return reason;
 	}
-	return 0;
+	return SKB_NOT_DROPPED_YET;
+}
+
+int ping_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
+{
+	return __ping_queue_rcv_skb(sk, skb) ? -1 : 0;
 }
 EXPORT_SYMBOL_GPL(ping_queue_rcv_skb);
 
-- 
2.35.1
next prev parent reply	other threads:[~2022-04-07  6:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-07  6:20 [PATCH RESEND net-next v5 0/4] net: icmp: add skb drop reasons to icmp menglong8.dong
2022-04-07  6:20 ` [PATCH RESEND net-next v5 1/4] net: sock: introduce sock_queue_rcv_skb_reason() menglong8.dong
2022-04-09  3:49   ` David Ahern
2022-04-07  6:20 ` [PATCH RESEND net-next v5 2/4] net: skb: rename SKB_DROP_REASON_PTYPE_ABSENT menglong8.dong
2022-04-09  3:50   ` David Ahern
2022-04-07  6:20 ` menglong8.dong [this message]
2022-04-09  4:05   ` [PATCH RESEND net-next v5 3/4] net: icmp: introduce __ping_queue_rcv_skb() to report drop reasons David Ahern
2022-04-07  6:20 ` [PATCH RESEND net-next v5 4/4] net: icmp: add skb drop reasons to icmp protocol menglong8.dong
2022-04-09  4:17   ` David Ahern
2022-04-11  9:50 ` [PATCH RESEND net-next v5 0/4] net: icmp: add skb drop reasons to icmp patchwork-bot+netdevbpf
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=20220407062052.15907-4-imagedong@tencent.com \
    --to=menglong8.dong@gmail.com \
    --cc=alobakin@pm.me \
    --cc=benbjiang@tencent.com \
    --cc=davem@davemloft.net \
    --cc=dongli.zhang@oracle.com \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=flyingpeng@tencent.com \
    --cc=imagedong@tencent.com \
    --cc=kafai@fb.com \
    --cc=keescook@chromium.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mengensun@tencent.com \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=talalahmad@google.com \
    --cc=xeb@mail.ru \
    --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).