From: Paolo Abeni <pabeni@redhat.com>
To: menglong8.dong@gmail.com, dsahern@kernel.org, kuba@kernel.org
Cc: davem@davemloft.net, rostedt@goodmis.org, mingo@redhat.com,
yoshfuji@linux-ipv6.org, imagedong@tencent.com,
edumazet@google.com, kafai@fb.com, talalahmad@google.com,
keescook@chromium.org, alobakin@pm.me, dongli.zhang@oracle.com,
maze@google.com, aahringo@redhat.com, weiwan@google.com,
yangbo.lu@nxp.com, fw@strlen.de, tglx@linutronix.de,
rpalethorpe@suse.com, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org
Subject: Re: [PATCH net-next 2/3] net: icmp: add skb drop reasons to ping_queue_rcv_skb()
Date: Tue, 15 Mar 2022 13:49:29 +0100 [thread overview]
Message-ID: <5ebf8873334a3a38855e378748cb6d8948fbd0c7.camel@redhat.com> (raw)
In-Reply-To: <20220314113225.151959-3-imagedong@tencent.com>
Hello,
On Mon, 2022-03-14 at 19:32 +0800, menglong8.dong@gmail.com wrote:
> From: Menglong Dong <imagedong@tencent.com>
>
> In order to get the reasons of skb drops, replace sock_queue_rcv_skb()
> used in ping_queue_rcv_skb() with sock_queue_rcv_skb_reason().
> Meanwhile, use kfree_skb_reason() instead of kfree_skb().
>
> As we can see in ping_rcv(), 'skb' will be freed if '-1' is returned
> by ping_queue_rcv_skb(). In order to get the drop reason of 'skb',
> make ping_queue_rcv_skb() return the drop reason.
>
> As ping_queue_rcv_skb() is used as 'ping_prot.backlog_rcv()', we can't
> change its return type. (Seems ping_prot.backlog_rcv() is not used?)
> Therefore, make it return 'drop_reason * -1' to keep the origin logic.
>
> Signed-off-by: Menglong Dong <imagedong@tencent.com>
> ---
> net/ipv4/ping.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
> index 3ee947557b88..cd4eb211431a 100644
> --- a/net/ipv4/ping.c
> +++ b/net/ipv4/ping.c
> @@ -936,12 +936,13 @@ EXPORT_SYMBOL_GPL(ping_recvmsg);
>
> int ping_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
> {
> + enum skb_drop_reason reason;
Please insert an empty line between variable declaration and code.
> 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;
This changes the return value for the release callback. Such callback
has a long and non trivial call chain via sk_backlog_rcv.
It *should* be safe, but have you considered factoring out an
__ping_queue_rcv_skb() variant returning the full drop reason, use it
in the next patch and build ping_queue_rcv_skb() on top of such helper
to that backlog_rcv() return code will not change?
The above should additionally avoid the IMHO not so nice:
reason = ping_queue_rcv_skb(sk, skb2) * -1;
in the next patch - it will become:
reason = __ping_queue_rcv_skb(sk, skb2);
Thanks!
Paolo
next prev parent reply other threads:[~2022-03-15 12:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-14 11:32 [PATCH net-next 0/3] net: icmp: add skb drop reasons to icmp menglong8.dong
2022-03-14 11:32 ` [PATCH net-next 1/3] net: sock: introduce sock_queue_rcv_skb_reason() menglong8.dong
2022-03-14 11:32 ` [PATCH net-next 2/3] net: icmp: add skb drop reasons to ping_queue_rcv_skb() menglong8.dong
2022-03-15 12:49 ` Paolo Abeni [this message]
2022-03-16 1:34 ` Menglong Dong
2022-03-14 11:32 ` [PATCH net-next 3/3] net: icmp: add reasons of the skb drops to icmp protocol menglong8.dong
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=5ebf8873334a3a38855e378748cb6d8948fbd0c7.camel@redhat.com \
--to=pabeni@redhat.com \
--cc=aahringo@redhat.com \
--cc=alobakin@pm.me \
--cc=davem@davemloft.net \
--cc=dongli.zhang@oracle.com \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=imagedong@tencent.com \
--cc=kafai@fb.com \
--cc=keescook@chromium.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maze@google.com \
--cc=menglong8.dong@gmail.com \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=rpalethorpe@suse.com \
--cc=talalahmad@google.com \
--cc=tglx@linutronix.de \
--cc=weiwan@google.com \
--cc=yangbo.lu@nxp.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
all inboxes | Powered by JetHome®