linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Xing <kerneljasonxing@gmail.com>
To: Antoine Tenart <atenart@kernel.org>
Cc: davem@davemloft.net, dsahern@kernel.org, edumazet@google.com,
	 geliang@kernel.org, kuba@kernel.org, martineau@kernel.org,
	 mathieu.desnoyers@efficios.com, matttbe@kernel.org,
	mhiramat@kernel.org,  pabeni@redhat.com, rostedt@goodmis.org,
	mptcp@lists.linux.dev,  linux-trace-kernel@vger.kernel.org,
	netdev@vger.kernel.org,  Jason Xing <kernelxing@tencent.com>
Subject: Re: [PATCH net-next v3 2/6] rstreason: prepare for passive reset
Date: Wed, 10 Apr 2024 21:55:21 +0800	[thread overview]
Message-ID: <CAL+tcoBpAOhbLC5TqwMBG6Q3hgiJYSV+ZAkZfLPNmG_OK22r1A@mail.gmail.com> (raw)
In-Reply-To: <171275527215.4303.17205725451869291289@kwain>

On Wed, Apr 10, 2024 at 9:21 PM Antoine Tenart <atenart@kernel.org> wrote:
>
> Quoting Jason Xing (2024-04-10 14:54:51)
> > Hi Antoine,
> >
> > On Wed, Apr 10, 2024 at 8:14 PM Antoine Tenart <atenart@kernel.org> wrote:
> > >
> > > Quoting Jason Xing (2024-04-09 12:09:30)
> > > >         void            (*send_reset)(const struct sock *sk,
> > > > -                                     struct sk_buff *skb);
> > > > +                                     struct sk_buff *skb,
> > > > +                                     int reason);
> >
> > > what should be 'reason' harder. Eg. when looking at the code or when
> > > using BTF (to then install debugging probes with BPF) this is not
> > > obvious.
> >
> > Only one number if we want to extract the reason with BPF, right? I
> > haven't tried it.
>
> Yes, we can get 'reason'. Knowing the type helps.
>
> > > A similar approach could be done as the one used for drop reasons: enum
> > > skb_drop_reason is used for parameters (eg. kfree_skb_reason) but other
> > > valid values (subsystem drop reasons) can be used too if casted (to
> > > u32). We could use 'enum sk_rst_reason' and cast the other values. WDYT?
> >
> > I have been haunted by this 'issue' for a long time...
> >
> > Are you suggesting doing so as below for readability:
> > 1) replace the reason parameter in all the related functions (like
> > .send_reset(), tcp_v4_send_reset(), etc) by using 'enum sk_rst_reason'
> > type?
> > 2) in patch [4/6], when it needs to pass the specific reason in those
> > functions, we can cast it to 'enum sk_rst_reason'?
> >
> > One modification I just made based on this patchset if I understand correctly:
> > diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
> > index 4889fccbf754..e0419b8496b5 100644
> > --- a/net/ipv4/tcp_ipv4.c
> > +++ b/net/ipv4/tcp_ipv4.c
> > @@ -725,7 +725,7 @@ static bool tcp_v4_ao_sign_reset(const struct sock
> > *sk, struct sk_buff *skb,
> >   */
> >
> >  static void tcp_v4_send_reset(const struct sock *sk, struct sk_buff *skb,
> > -                             int reason)
> > +                             enum sk_rst_reason reason)
> >  {
> >         const struct tcphdr *th = tcp_hdr(skb);
> >         struct {
> > @@ -1935,7 +1935,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
> >         return 0;
> >
> >  reset:
> > -       tcp_v4_send_reset(rsk, skb, 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
> >
>
> That's right. I think (u32) can also be used for the cast to make the
> compiler happy in 2), but the above makes sense.

Got it :) Will update soon.

Thanks,
Jason

  reply	other threads:[~2024-04-10 13:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-09 10:09 [PATCH net-next v3 0/6] Implement reset reason mechanism to detect Jason Xing
2024-04-09 10:09 ` [PATCH net-next v3 1/6] net: introduce rstreason to detect why the RST is sent Jason Xing
2024-04-09 10:09 ` [PATCH net-next v3 2/6] rstreason: prepare for passive reset Jason Xing
2024-04-10 12:14   ` Antoine Tenart
2024-04-10 12:54     ` Jason Xing
2024-04-10 13:21       ` Antoine Tenart
2024-04-10 13:55         ` Jason Xing [this message]
2024-04-09 10:09 ` [PATCH net-next v3 3/6] rstreason: prepare for active reset Jason Xing
2024-04-09 10:09 ` [PATCH net-next v3 4/6] tcp: support rstreason for passive reset Jason Xing
2024-04-09 10:09 ` [PATCH net-next v3 5/6] mptcp: " Jason Xing
2024-04-09 10:09 ` [PATCH net-next v3 6/6] rstreason: make it work in trace world Jason Xing
2024-04-09 15:38   ` Steven Rostedt
2024-04-09 16:09     ` 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+tcoBpAOhbLC5TqwMBG6Q3hgiJYSV+ZAkZfLPNmG_OK22r1A@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 read-only IMAP folder(s) and NNTP newsgroup(s).