mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ilya Maximets <i.maximets@ovn.org>
To: Adrian Moreno <amorenoz@redhat.com>, netdev@vger.kernel.org
Cc: i.maximets@ovn.org, aconole@redhat.com, echaudro@redhat.com,
	horms@kernel.org, dev@openvswitch.org,
	Pravin B Shelar <pshelar@ovn.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2 7/9] net: openvswitch: do not notify drops inside sample
Date: Mon, 17 Jun 2024 13:55:02 +0200	[thread overview]
Message-ID: <8624ccf8-e9e2-4a95-a25c-7d3166bb3256@ovn.org> (raw)
In-Reply-To: <20240603185647.2310748-8-amorenoz@redhat.com>

On 6/3/24 20:56, Adrian Moreno wrote:
> The OVS_ACTION_ATTR_SAMPLE action is, in essence,
> observability-oriented.
> 
> Apart from some corner case in which it's used a replacement of clone()
> for old kernels, it's really only used for sFlow, IPFIX and now,
> local emit_sample.
> 
> With this in mind, it doesn't make much sense to report
> OVS_DROP_LAST_ACTION inside sample actions.
> 
> For instance, if the flow:
> 
>   actions:sample(..,emit_sample(..)),2
> 
> triggers a OVS_DROP_LAST_ACTION skb drop event, it would be extremely
> confusing for users since the packet did reach its destination.
> 
> This patch makes internal action execution silently consume the skb
> instead of notifying a drop for this case.
> 
> Unfortunately, this patch does not remove all potential sources of
> confusion since, if the sample action itself is the last action, e.g:
> 
>     actions:sample(..,emit_sample(..))
> 
> we actually _should_ generate a OVS_DROP_LAST_ACTION event, but we aren't.
> 
> Sadly, this case is difficult to solve without breaking the
> optimization by which the skb is not cloned on last sample actions.
> But, given explicit drop actions are now supported, OVS can just add one
> after the last sample() and rewrite the flow as:
> 
>     actions:sample(..,emit_sample(..)),drop
> 
> Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
> ---
>  net/openvswitch/actions.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
> index 33f6d93ba5e4..54fc1abcff95 100644
> --- a/net/openvswitch/actions.c
> +++ b/net/openvswitch/actions.c
> @@ -82,6 +82,15 @@ static struct action_fifo __percpu *action_fifos;
>  static struct action_flow_keys __percpu *flow_keys;
>  static DEFINE_PER_CPU(int, exec_actions_level);
>  
> +static inline void ovs_drop_skb_last_action(struct sk_buff *skb)
> +{
> +	/* Do not emit packet drops inside sample(). */
> +	if (OVS_CB(skb)->probability)
> +		consume_skb(skb);
> +	else
> +		ovs_kfree_skb_reason(skb, OVS_DROP_LAST_ACTION);
> +}
> +
>  /* Make a clone of the 'key', using the pre-allocated percpu 'flow_keys'
>   * space. Return NULL if out of key spaces.
>   */
> @@ -1061,7 +1070,7 @@ static int sample(struct datapath *dp, struct sk_buff *skb,
>  	if ((arg->probability != U32_MAX) &&
>  	    (!arg->probability || get_random_u32() > arg->probability)) {
>  		if (last)
> -			ovs_kfree_skb_reason(skb, OVS_DROP_LAST_ACTION);
> +			ovs_drop_skb_last_action(skb);
>  		return 0;
>  	}
>  
> @@ -1579,7 +1588,7 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb,
>  		}
>  	}
>  
> -	ovs_kfree_skb_reason(skb, OVS_DROP_LAST_ACTION);
> +	ovs_drop_skb_last_action(skb);

I don't think I agree with this one.  If we have a sample() action with
a lot of different actions inside and we reached the end while the last
action didn't consume the skb, then we should report that.  E.g.
"sample(emit_sample(),push_vlan(),set(eth())),2"  should report that the
cloned skb was dropped.  "sample(push_vlan(),emit_sample())" should not.

The only actions that are actually consuming the skb are "output",
"userspace", "recirc" and now "emit_sample".  "output" and "recirc" are
consuming the skb "naturally" by stealing it when it is the last action.
"userspace" has an explicit check to consume the skb if it is the last
action.  "emit_sample" should have the similar check.  It should likely
be added at the point of action introduction instead of having a separate
patch.

Best regards, Ilya Maximets.

  parent reply	other threads:[~2024-06-17 11:55 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240603185647.2310748-1-amorenoz@redhat.com>
2024-06-03 18:56 ` [PATCH net-next v2 1/9] net: psample: add user cookie Adrian Moreno
2024-06-14 16:13   ` Simon Horman
2024-06-03 18:56 ` [PATCH net-next v2 2/9] net: sched: act_sample: add action cookie to sample Adrian Moreno
2024-06-14 16:14   ` Simon Horman
2024-06-17 10:00   ` Ilya Maximets
2024-06-18  7:38     ` Adrián Moreno
2024-06-18  9:42       ` Ilya Maximets
2024-06-03 18:56 ` [PATCH net-next v2 3/9] net: psample: skip packet copy if no listeners Adrian Moreno
2024-06-14 16:15   ` Simon Horman
2024-06-03 18:56 ` [PATCH net-next v2 4/9] net: psample: allow using rate as probability Adrian Moreno
2024-06-14 16:11   ` Simon Horman
2024-06-17  6:32     ` Adrián Moreno
2024-06-17 10:30       ` Simon Horman
2024-06-03 18:56 ` [PATCH net-next v2 5/9] net: openvswitch: add emit_sample action Adrian Moreno
2024-06-05  0:29   ` kernel test robot
2024-06-05 19:31     ` Adrián Moreno
2024-06-05 20:06       ` Simon Horman
2024-06-05 19:51   ` Simon Horman
2024-06-06  8:42     ` Adrián Moreno
2024-06-10 15:46   ` [ovs-dev] " Aaron Conole
2024-06-11  8:39     ` Adrián Moreno
2024-06-11 13:54       ` Aaron Conole
2024-06-11 15:42         ` Adrián Moreno
2024-06-14 16:13   ` Simon Horman
2024-06-17 10:44   ` Ilya Maximets
2024-06-18  7:33     ` Adrián Moreno
2024-06-18  9:47       ` Ilya Maximets
2024-06-18 10:08         ` Ilya Maximets
2024-06-03 18:56 ` [PATCH net-next v2 6/9] net: openvswitch: store sampling probability in cb Adrian Moreno
2024-06-04  6:09   ` kernel test robot
2024-06-04  8:49   ` kernel test robot
2024-06-05 19:34     ` Adrián Moreno
2024-06-14 16:55   ` Aaron Conole
2024-06-17  7:08     ` Adrián Moreno
2024-06-17 11:26       ` Ilya Maximets
2024-06-18  7:36         ` Adrián Moreno
2024-06-03 18:56 ` [PATCH net-next v2 7/9] net: openvswitch: do not notify drops inside sample Adrian Moreno
2024-06-14 16:17   ` Simon Horman
2024-06-17 11:55   ` Ilya Maximets [this message]
2024-06-17 12:10     ` Ilya Maximets
2024-06-18  7:00       ` Adrián Moreno
2024-06-18 10:22         ` Ilya Maximets
2024-06-18 10:50           ` Adrián Moreno
2024-06-18 15:44             ` Ilya Maximets
2024-06-19  6:35               ` Adrián Moreno
2024-06-19 18:21                 ` Ilya Maximets
2024-06-19 20:40                   ` Adrián Moreno
2024-06-19 20:56                     ` Ilya Maximets
2024-06-03 18:56 ` [PATCH net-next v2 8/9] selftests: openvswitch: add emit_sample action Adrian Moreno
2024-06-03 18:56 ` [PATCH net-next v2 9/9] selftests: openvswitch: add emit_sample test Adrian Moreno
2024-06-05 19:43   ` Simon Horman
2024-06-10  9:20     ` Adrián Moreno
2024-06-14 17:07   ` Aaron Conole
2024-06-17  7:18     ` Adrián Moreno
2024-06-18  9:08       ` Adrián Moreno
2024-06-18 13:27         ` 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=8624ccf8-e9e2-4a95-a25c-7d3166bb3256@ovn.org \
    --to=i.maximets@ovn.org \
    --cc=aconole@redhat.com \
    --cc=amorenoz@redhat.com \
    --cc=davem@davemloft.net \
    --cc=dev@openvswitch.org \
    --cc=echaudro@redhat.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.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

all inboxes | Powered by JetHome®