From patchwork Mon Jun 3 18:56:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Adri=C3=A1n_Moreno?= X-Patchwork-Id: 1943013 X-Patchwork-Delegate: horms@verge.net.au Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DX4FD6z1; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VtNKg70n8z20Q1 for ; Tue, 4 Jun 2024 04:58:31 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 67396414B4; Mon, 3 Jun 2024 18:58:30 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 5zp0PgKIGdtV; Mon, 3 Jun 2024 18:58:29 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 64CEA40C0D Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DX4FD6z1 Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 64CEA40C0D; Mon, 3 Jun 2024 18:58:29 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id F357CC0072; Mon, 3 Jun 2024 18:58:28 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4C863C0037 for ; Mon, 3 Jun 2024 18:58:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 9E2FE84503 for ; Mon, 3 Jun 2024 18:57:47 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 3QQ-eUAF8c8s for ; Mon, 3 Jun 2024 18:57:47 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=amorenoz@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org 9C637842E4 Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 9C637842E4 Authentication-Results: smtp1.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DX4FD6z1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 9C637842E4 for ; Mon, 3 Jun 2024 18:57:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717441065; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rOBO6rTwZsWPfk6+dPakOlkKyyoY1m68zoodZwM7lVI=; b=DX4FD6z1Q8uE9ukOTAQ5CE0QHc/jwyaQvpRLNvBmzSQBoxmUwToglCIK12/lWOLG0dOx+D aCTNbFAYPolVLInGAdK7huzVAjoVsDojHl/wg2CxhRZjYzOyBWYlbBwLl9kOrI9nL65qMc yr3m4MLxnp/rqFdSEi7O13Zk2izJR+Y= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-606-grTpO5YAMvmyg-NemEBKVA-1; Mon, 03 Jun 2024 14:57:41 -0400 X-MC-Unique: grTpO5YAMvmyg-NemEBKVA-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5C03E1913F60; Mon, 3 Jun 2024 18:57:39 +0000 (UTC) Received: from antares.redhat.com (unknown [10.39.193.112]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 997951955F6E; Mon, 3 Jun 2024 18:57:35 +0000 (UTC) From: Adrian Moreno To: netdev@vger.kernel.org Date: Mon, 3 Jun 2024 20:56:41 +0200 Message-ID: <20240603185647.2310748-8-amorenoz@redhat.com> In-Reply-To: <20240603185647.2310748-1-amorenoz@redhat.com> References: <20240603185647.2310748-1-amorenoz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Cc: dev@openvswitch.org, Paolo Abeni , linux-kernel@vger.kernel.org, i.maximets@ovn.org, Eric Dumazet , horms@kernel.org, Jakub Kicinski , "David S. Miller" Subject: [ovs-dev] [PATCH net-next v2 7/9] net: openvswitch: do not notify drops inside sample X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" 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 Reviewed-by: Simon Horman --- 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); return 0; }