From: Michal Kubiak <michal.kubiak@intel.com>
To: "Adrián Moreno" <amorenoz@redhat.com>
Cc: <netdev@vger.kernel.org>, <aconole@redhat.com>,
<echaudro@redhat.com>, <horms@kernel.org>, <i.maximets@ovn.org>,
<dev@openvswitch.org>, "Donald Hunter" <donald.hunter@gmail.com>,
Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
"Paolo Abeni" <pabeni@redhat.com>,
Pravin B Shelar <pshelar@ovn.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next v7 05/10] net: openvswitch: add psample action
Date: Tue, 2 Jul 2024 13:10:37 +0200 [thread overview]
Message-ID: <ZoPgLfosO5e160nO@localhost.localdomain> (raw)
In-Reply-To: <CAG=2xmMgJcir=mfQuybosg9C8j3Sx1V=Du0ObH1eT_SnBZ7nMg@mail.gmail.com>
On Mon, Jul 01, 2024 at 12:56:43PM +0000, Adrián Moreno wrote:
> On Mon, Jul 01, 2024 at 01:40:39PM GMT, Michal Kubiak wrote:
> > On Sun, Jun 30, 2024 at 09:57:26PM +0200, Adrian Moreno wrote:
> > > Add support for a new action: psample.
> > >
> > > This action accepts a u32 group id and a variable-length cookie and uses
> > > the psample multicast group to make the packet available for
> > > observability.
> > >
> > > The maximum length of the user-defined cookie is set to 16, same as
> > > tc_cookie, to discourage using cookies that will not be offloadable.
> > >
> > > Acked-by: Eelco Chaudron <echaudro@redhat.com>
> > > Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
> > > ---
> > > Documentation/netlink/specs/ovs_flow.yaml | 17 ++++++++
> > > include/uapi/linux/openvswitch.h | 28 ++++++++++++++
> > > net/openvswitch/Kconfig | 1 +
> > > net/openvswitch/actions.c | 47 +++++++++++++++++++++++
> > > net/openvswitch/flow_netlink.c | 32 ++++++++++++++-
> > > 5 files changed, 124 insertions(+), 1 deletion(-)
> > >
[...]
> > > @@ -914,6 +914,31 @@ struct check_pkt_len_arg {
> > > };
> > > #endif
> > >
> > > +#define OVS_PSAMPLE_COOKIE_MAX_SIZE 16
> >
> > In your patch #2 you use "TC_COOKIE_MAX_SIZE" as an array size for your
> > cookie. I know that now OVS_PSAMPLE_COOKIE_MAX_SIZE == TC_COOKIE_MAX_SIZE,
> > so this size will be validated correctly.
> > But how likely is that those 2 constants will have different values in the
> > future?
> > Would it be reasonable to create more strict dependency between those
> > macros, e.g.:
> >
> > #define OVS_PSAMPLE_COOKIE_MAX_SIZE TC_COOKIE_MAX_SIZE
> >
> > or, at least, add a comment that the size shouldn't be bigger than
> > TC_COOKIE_MAX_SIZE?
> > I'm just considering the risk of exceeding the array from the patch #2 when
> > somebody increases OVS_PSAMPLE_COOKIE_MAX_SIZE in the future.
> >
> > Thanks,
> > Michal
> >
>
> Hi Michal,
>
> Thanks for sharing your thoughts.
>
> I tried to keep the dependency between both cookie sizes loose.
>
> I don't want a change in TC_COOKIE_MAX_SIZE to inadvertently modify
> OVS_PSAMPLE_COOKIE_MAX_SIZE because OVS might not need a bigger cookie
> and even if it does, backwards compatibility needs to be guaranteed:
> meaning OVS userspace will have to detect the new size and use it or
> fall back to a smaller cookie for older kernels. All this needs to be
> known and worked on in userspace.
>
> On the other hand, I intentionally made OVS's "psample" action as
> similar as possible to act_psample, including setting the same cookie
> size to begin with. The reason is that I think we should try to implement
> tc-flower offloading of this action using act_sample, plus 16 seemed a
> very reasonable max value.
>
> When we decide to support offloading the "psample" action, this must
> be done entirely in userspace. OVS must create a act_sample action
> (instead of the OVS "psample" one) via netlink. In no circumstances the
> openvswitch kmod interacts with tc directly.
>
> Now, back to your concern. If OVS_PSAMPLE_COOKIE_MAX_SIZE grows and
> TC_COOKIE_MAX_SIZE does not *and* we already support offloading this
> action to tc, the only consequence is that OVS userspace has a
> problem because the tc's netlink interface will reject cookies larger
> than TC_COOKIE_MAX_SIZE [1].
> This guarantees that the array in patch #2 is never overflown.
>
> OVS will have to deal with the different sizes and try to squeeze the
> data into TC_COOKIE_MAX_SIZE or fail to offload the action altogether.
>
> Psample does not have a size limit so different parts of the kernel can
> use psample with different internal max-sizes without any restriction.
>
> I hope this clears your concerns.
>
> [1] https://github.com/torvalds/linux/blob/master/net/sched/act_api.c#L1299
>
> Thanks.
> Adrián
>
Thank you, Adrian, for your detailed explanation. I wasn't aware of the
internal validation of that parameter using the mechanism from [1].
Sorry for asking the questions I should have answered by studying the
code more carefully.
I have no concerns about it now.
Thanks,
Reviewed-by: Michal Kubiak <michal.kubiak@intel.com>
next prev parent reply other threads:[~2024-07-02 11:10 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-30 19:57 [PATCH net-next v7 00/10] net: openvswitch: Add sample multicasting Adrian Moreno
2024-06-30 19:57 ` [PATCH net-next v7 01/10] net: psample: add user cookie Adrian Moreno
2024-07-01 11:20 ` Michal Kubiak
2024-07-01 18:05 ` Aaron Conole
2024-06-30 19:57 ` [PATCH net-next v7 02/10] net: sched: act_sample: add action cookie to sample Adrian Moreno
2024-07-01 18:06 ` Aaron Conole
2024-06-30 19:57 ` [PATCH net-next v7 03/10] net: psample: skip packet copy if no listeners Adrian Moreno
2024-07-01 18:07 ` Aaron Conole
2024-06-30 19:57 ` [PATCH net-next v7 04/10] net: psample: allow using rate as probability Adrian Moreno
2024-07-01 18:10 ` Aaron Conole
2024-06-30 19:57 ` [PATCH net-next v7 05/10] net: openvswitch: add psample action Adrian Moreno
2024-07-01 11:40 ` Michal Kubiak
2024-07-01 12:56 ` Adrián Moreno
2024-07-02 11:10 ` Michal Kubiak [this message]
2024-07-01 18:13 ` Ilya Maximets
2024-07-01 18:23 ` Aaron Conole
2024-07-02 7:05 ` Adrián Moreno
2024-07-02 7:29 ` Adrián Moreno
2024-07-02 9:37 ` Simon Horman
2024-07-02 9:52 ` Adrián Moreno
2024-07-02 9:53 ` Ilya Maximets
2024-07-02 12:33 ` [ovs-dev] " Simon Horman
2024-07-02 18:37 ` Adrián Moreno
2024-07-02 18:06 ` Jakub Kicinski
2024-07-02 18:16 ` Ilya Maximets
2024-07-02 18:24 ` Jakub Kicinski
2024-07-02 18:52 ` Ilya Maximets
2024-06-30 19:57 ` [PATCH net-next v7 06/10] net: openvswitch: store sampling probability in cb Adrian Moreno
2024-07-01 18:24 ` Aaron Conole
2024-06-30 19:57 ` [PATCH net-next v7 07/10] selftests: openvswitch: add psample action Adrian Moreno
2024-07-01 18:40 ` Aaron Conole
2024-06-30 19:57 ` [PATCH net-next v7 08/10] selftests: openvswitch: add userspace parsing Adrian Moreno
2024-06-30 19:57 ` [PATCH net-next v7 09/10] selftests: openvswitch: parse trunc action Adrian Moreno
2024-06-30 19:57 ` [PATCH net-next v7 10/10] selftests: openvswitch: add psample test Adrian Moreno
2024-07-01 18:34 ` Ilya Maximets
2024-07-01 18:38 ` Aaron Conole
2024-07-02 7:16 ` Adrián Moreno
2024-07-02 11:45 ` Aaron Conole
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=ZoPgLfosO5e160nO@localhost.localdomain \
--to=michal.kubiak@intel.com \
--cc=aconole@redhat.com \
--cc=amorenoz@redhat.com \
--cc=davem@davemloft.net \
--cc=dev@openvswitch.org \
--cc=donald.hunter@gmail.com \
--cc=echaudro@redhat.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=i.maximets@ovn.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pshelar@ovn.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).