[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220407062052.15907-4-imagedong@tencent.com>
Date: Thu, 7 Apr 2022 14:20:51 +0800
From: menglong8.dong@...il.com
To: dsahern@...nel.org, kuba@...nel.org, pabeni@...hat.com
Cc: rostedt@...dmis.org, mingo@...hat.com, xeb@...l.ru,
davem@...emloft.net, yoshfuji@...ux-ipv6.org,
imagedong@...cent.com, edumazet@...gle.com, kafai@...com,
talalahmad@...gle.com, keescook@...omium.org, alobakin@...me,
flyingpeng@...cent.com, mengensun@...cent.com,
dongli.zhang@...cle.com, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org, benbjiang@...cent.com
Subject: [PATCH RESEND net-next v5 3/4] net: icmp: introduce __ping_queue_rcv_skb() to report drop reasons
From: Menglong Dong <imagedong@...cent.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@...cent.com>
Reviewed-by: Jiang Biao <benbjiang@...cent.com>
Signed-off-by: Menglong Dong <imagedong@...cent.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
Powered by blists - more mailing lists