From: Jason Xing <kerneljasonxing@gmail.com>
To: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>,
dsahern@kernel.org, matttbe@kernel.org, martineau@kernel.org,
geliang@kernel.org, pabeni@redhat.com, davem@davemloft.net,
rostedt@goodmis.org, mhiramat@kernel.org,
mathieu.desnoyers@efficios.com, atenart@kernel.org,
mptcp@lists.linux.dev, netdev@vger.kernel.org,
linux-trace-kernel@vger.kernel.org,
Jason Xing <kernelxing@tencent.com>
Subject: Re: [PATCH net-next v6 0/7] Implement reset reason mechanism to detect
Date: Fri, 19 Apr 2024 15:28:45 +0800 [thread overview]
Message-ID: <CAL+tcoBn8RHm8AbwMBJ6FM6PMLLotCwTxSgPS1ABd-_D7uBSxw@mail.gmail.com> (raw)
In-Reply-To: <CANn89iL9OzD5+Y56F_8Jqyxwa5eDQPaPjhX9Y-Y_b9+bcQE08Q@mail.gmail.com>
On Fri, Apr 19, 2024 at 3:02 PM Eric Dumazet <edumazet@google.com> wrote:
>
> On Fri, Apr 19, 2024 at 4:31 AM Jason Xing <kerneljasonxing@gmail.com> wrote:
> >
> > On Fri, Apr 19, 2024 at 7:26 AM Jason Xing <kerneljasonxing@gmail.com> wrote:
> > >
> > > > When I said "If you feel the need to put them in a special group, this
> > > > is fine by me.",
> > > > this was really about partitioning the existing enum into groups, if
> > > > you prefer having a group of 'RES reasons'
> > >
> > > Are you suggesting copying what we need from enum skb_drop_reason{} to
> > > enum sk_rst_reason{}? Why not reusing them directly. I have no idea
> > > what the side effect of cast conversion itself is?
> >
> > Sorry that I'm writing this email. I'm worried my statement is not
> > that clear, so I write one simple snippet which can help me explain
> > well :)
> >
> > Allow me give NO_SOCKET as an example:
> > diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
> > index e63a3bf99617..2c9f7364de45 100644
> > --- a/net/ipv4/icmp.c
> > +++ b/net/ipv4/icmp.c
> > @@ -767,6 +767,7 @@ void __icmp_send(struct sk_buff *skb_in, int type,
> > int code, __be32 info,
> > if (!fl4.saddr)
> > fl4.saddr = htonl(INADDR_DUMMY);
> >
> > + trace_icmp_send(skb_in, type, code);
> > icmp_push_reply(sk, &icmp_param, &fl4, &ipc, &rt);
> > ende:
> > ip_rt_put(rt);
> > diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
> > index 1e650ec71d2f..d5963831280f 100644
> > --- a/net/ipv4/tcp_ipv4.c
> > +++ b/net/ipv4/tcp_ipv4.c
> > @@ -2160,6 +2160,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
> > {
> > struct net *net = dev_net(skb->dev);
> > enum skb_drop_reason drop_reason;
> > + enum sk_rst_reason rst_reason;
> > int sdif = inet_sdif(skb);
> > int dif = inet_iif(skb);
> > const struct iphdr *iph;
> > @@ -2355,7 +2356,8 @@ int tcp_v4_rcv(struct sk_buff *skb)
> > bad_packet:
> > __TCP_INC_STATS(net, TCP_MIB_INERRS);
> > } else {
> > - tcp_v4_send_reset(NULL, skb);
> > + rst_reason = RST_REASON_NO_SOCKET;
> > + tcp_v4_send_reset(NULL, skb, rst_reason);
> > }
> >
> > discard_it:
> >
> > As you can see, we need to add a new 'rst_reason' variable which
> > actually is the same as drop reason. They are the same except for the
> > enum type... Such rst_reasons/drop_reasons are all over the place.
> >
> > Eric, if you have a strong preference, I can do it as you said.
> >
> > Well, how about explicitly casting them like this based on the current
> > series. It looks better and clearer and more helpful to people who is
> > reading codes to understand:
> > diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
> > index 461b4d2b7cfe..eb125163d819 100644
> > --- a/net/ipv4/tcp_ipv4.c
> > +++ b/net/ipv4/tcp_ipv4.c
> > @@ -1936,7 +1936,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
> > return 0;
> >
> > reset:
> > - tcp_v4_send_reset(rsk, skb, (u32)reason);
> > + tcp_v4_send_reset(rsk, skb, (enum sk_rst_reason)reason);
> > discard:
> > kfree_skb_reason(skb, reason);
> > /* Be careful here. If this function gets more complicated and
>
> It makes no sense to declare an enum sk_rst_reason and then convert it
> to drop_reason
> or vice versa.
>
> Next thing you know, compiler guys will add a new -Woption that will
> forbid such conversions.
>
> Please add to tcp_v4_send_reset() an skb_drop_reason, not a new enum.
Ah... It looks like I didn't make myself clear again. Sorry...
Actually I wrote this part many times. My conclusion is that It's not
feasible to do this.
REASONS:
If we __only__ need to deal with this passive reset in TCP, it's fine.
We pass a skb_drop_reason which should also be converted to u32 type
in tcp_v4_send_reset() as you said, it can work. People who use the
trace will see the reason with the 'SKB_DROP_REASON' prefix stripped.
But we have to deal with other cases. A few questions are listed here:
1) What about tcp_send_active_reset() in TCP/MPTCP? Passing weird drop
reasons? There is no drop reason at all. I think people will get
confused. So I believe we should invent new definitions to cope with
it.
2) What about the .send_reset callback in the subflow_syn_recv_sock()
in MPTCP? The reasons in MPTCP are only definitions (such as
MPTCP_RST_EUNSPEC). I don't think we can convert them into the enum
skb_drop_reason type.
So where should we group those various reasons?
Introducing a new enum is for extension and compatibility for all
kinds of reset reasons.
What do you think?
Thanks,
Jason
>
> skb_drop_reason are simply values that are later converted to strings...
>
> So : Do not declare a new enum.
next prev parent reply other threads:[~2024-04-19 7:29 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-17 8:51 [PATCH net-next v6 0/7] Implement reset reason mechanism to detect Jason Xing
2024-04-17 8:51 ` [PATCH net-next v6 1/7] net: introduce rstreason to detect why the RST is sent Jason Xing
2024-04-17 9:01 ` Eric Dumazet
2024-04-17 9:22 ` Jason Xing
2024-04-17 8:51 ` [PATCH net-next v6 2/7] rstreason: prepare for passive reset Jason Xing
2024-04-17 8:51 ` [PATCH net-next v6 3/7] rstreason: prepare for active reset Jason Xing
2024-04-17 8:51 ` [PATCH net-next v6 4/7] tcp: support rstreason for passive reset Jason Xing
2024-04-17 8:51 ` [PATCH net-next v6 5/7] mptcp: " Jason Xing
2024-04-17 8:51 ` [PATCH net-next v6 6/7] mptcp: introducing a helper into active reset logic Jason Xing
2024-04-17 8:51 ` [PATCH net-next v6 7/7] rstreason: make it work in trace world Jason Xing
2024-04-18 3:30 ` [PATCH net-next v6 0/7] Implement reset reason mechanism to detect Jason Xing
2024-04-18 15:46 ` Jakub Kicinski
2024-04-18 16:23 ` Jason Xing
2024-04-18 18:51 ` Eric Dumazet
2024-04-18 22:29 ` Jason Xing
2024-04-18 22:40 ` Jason Xing
2024-04-18 23:26 ` Jason Xing
2024-04-19 2:30 ` Jason Xing
2024-04-19 7:02 ` Eric Dumazet
2024-04-19 7:28 ` Jason Xing [this message]
2024-04-19 7:44 ` Eric Dumazet
2024-04-19 8:00 ` Jason Xing
2024-04-19 8:06 ` Jason Xing
2024-04-20 2:35 ` Steven Rostedt
2024-04-20 3:22 ` Jason Xing
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=CAL+tcoBn8RHm8AbwMBJ6FM6PMLLotCwTxSgPS1ABd-_D7uBSxw@mail.gmail.com \
--to=kerneljasonxing@gmail.com \
--cc=atenart@kernel.org \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=geliang@kernel.org \
--cc=kernelxing@tencent.com \
--cc=kuba@kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=martineau@kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=matttbe@kernel.org \
--cc=mhiramat@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rostedt@goodmis.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).