From patchwork Wed Jun 5 20:23:28 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: 1944150 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=b9O2Jxl0; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (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 4Vvf7L0lzsz20Q5 for ; Thu, 6 Jun 2024 06:23:57 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 1F52E61195; Wed, 5 Jun 2024 20:23:56 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 4kIVb669Ha_x; Wed, 5 Jun 2024 20:23:55 +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 smtp3.osuosl.org DB4346066D Authentication-Results: smtp3.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=b9O2Jxl0 Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id DB4346066D; Wed, 5 Jun 2024 20:23:54 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A4DDFC0077; Wed, 5 Jun 2024 20:23:54 +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 92DD5C0037 for ; Wed, 5 Jun 2024 20:23:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 7888181120 for ; Wed, 5 Jun 2024 20:23:53 +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 M0HMAhPpfT77 for ; Wed, 5 Jun 2024 20:23:52 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=amorenoz@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org 537798110D 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 537798110D 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=b9O2Jxl0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 537798110D for ; Wed, 5 Jun 2024 20:23:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717619031; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fPgSlP0InUTAJ9/8t6Dz9AIKixNm2bkRe6KwinGA9ME=; b=b9O2Jxl0WWb5+X9HaLamCiTzs/zI9OkUR6+jRrypk1ikjm74q3QRztR46BzT9bu9d/VPjs l65Rb2QljK3fuHdxxlHx5tp7ojWq+SiJR9VnnBTHf1CsogXDOZpv0+D0/o28l8Q/qgiGEN DFyQTD3h7ujfqSGMK4vhq6Novxo/oXY= Received: from mx-prod-mc-05.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-187-mWJ0QBGtM-SPfhK_OlPL8A-1; Wed, 05 Jun 2024 16:23:47 -0400 X-MC-Unique: mWJ0QBGtM-SPfhK_OlPL8A-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CE8A119772C8; Wed, 5 Jun 2024 20:23:46 +0000 (UTC) Received: from antares.redhat.com (unknown [10.39.193.112]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7A0A61956086; Wed, 5 Jun 2024 20:23:44 +0000 (UTC) From: Adrian Moreno To: dev@openvswitch.org Date: Wed, 5 Jun 2024 22:23:28 +0200 Message-ID: <20240605202337.2904041-1-amorenoz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: dceara@redhat.com, i.maximets@ovn.org Subject: [ovs-dev] [RFC v2 0/9] Introduce local sampling with NXAST_SAMPLE action 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" (Was: Add psample support to NXAST_SAMPLE action) This is the userspace counterpart of the work being done in the kernel [1] which is still not merged (hence the RFC state). There, a new datapath action is added, called "emit_sample". Being a specific action, it promises a more efficient way of making packet samples available to observability applications. From the PoV of ovs-vswitchd, this new action is used to implement "local sampling". Local sampling (or lsample for short) is configured in a similar way as current per-flow IPFIX sampling, i.e: using the Flow_Sample_Collector_Set table and the NXAST_SAMPLE action. However, instead of sending the sample to an external IPFIX collector though the network, the sample is emitted using the new action and made available to locally running sample collector. The specific way emit_sample sends the sample (and the way the local collector shall collect it) is datapath-specific. Currently, currently only the Linux kernel datapath implements it using the psample netlink multicast group. ~~ Configuration ~~ Local sampling is configured via a new column in the Flow_Sample_Collector_Set (FSCS) table called "local_sample_group". Configuring this value is orthogonal to also associating the FSCS entry to an entry in the IPFIX table. Once that entry in the OVSDB is configured, NXAST_SAMPLE actions coming from the controller will be translated into the following odp action: sample(sample={P}%, actions(emit_sample(group={G},cookie={C}))) Where: P: Is the sampling probability from NXAST_SAMPLE G: Is the group id in the FSCS entry whose "id" matches the one in the NXAST_SAMPLE. C: Is a 64bit cookie result of concatenating the obs_domain and obs_point from the NXAST_SAMPLE, i.e: "obs_domain << 32 | obs_point" Notes: - The parent sample action might be omitted if the probability is 100% and there is no IPFIX sampling that requires the use of a meter. ~~ Internal implementation: dpif-lsample ~~ Internally, a new object called "dpif-lsample" is introduced to track the configured local sampling exporters and track statistics based on odp flow stats (using xcache). It exposes the list of configured exporters and their statistics on a new unixctl command called "lsample/show". ~~ Testing ~~ The series includes an test utility program than can be executed by running "tests/ovstest test-psample". This utility listens to packets multicasted by the psample module and prints them (also printing the obs_domain and obs_point ids). ~~ HW Offload ~~ tc offload is not being introduced in this series as existing sample or userspace actions are not currently offloadable. Also some improvements need to be implemented in tc for it to be feasible. [1] https://patchwork.kernel.org/project/netdevbpf/cover/20240603185647.2310748-1-amorenoz@redhat.com/ Adrian Moreno (9): odp-util: Add support OVS_ACTION_ATTR_EMIT_SAMPLE. ofproto_dpif: Check for emit_sample support. ofproto: Add ofproto-dpif-lsample. vswitchd: Add local sampling to vswitchd schema. ofproto-dpif-xlate: Use emit_sample for local sample. ofproto-dpif-xlate-cache: Add lsample to xcache. ofproto-dpif-lsample: Show stats via unixctl. tests: Add test-psample testing utility. tests: Test local sampling. NEWS | 6 + include/linux/automake.mk | 1 + include/linux/openvswitch.h | 25 +++ include/linux/psample.h | 68 ++++++ lib/dpif-netdev.c | 1 + lib/dpif.c | 8 + lib/dpif.h | 1 + lib/odp-execute.c | 25 ++- lib/odp-util.c | 103 +++++++++ lib/odp-util.h | 3 + ofproto/automake.mk | 2 + ofproto/ofproto-dpif-ipfix.c | 1 + ofproto/ofproto-dpif-lsample.c | 333 +++++++++++++++++++++++++++++ ofproto/ofproto-dpif-lsample.h | 45 ++++ ofproto/ofproto-dpif-sflow.c | 1 + ofproto/ofproto-dpif-xlate-cache.c | 11 +- ofproto/ofproto-dpif-xlate-cache.h | 6 + ofproto/ofproto-dpif-xlate.c | 178 +++++++++++---- ofproto/ofproto-dpif-xlate.h | 3 +- ofproto/ofproto-dpif.c | 86 +++++++- ofproto/ofproto-dpif.h | 7 +- ofproto/ofproto-provider.h | 9 + ofproto/ofproto.c | 12 ++ ofproto/ofproto.h | 8 + python/ovs/flow/odp.py | 8 + tests/automake.mk | 3 +- tests/odp.at | 16 ++ tests/system-common-macros.at | 4 + tests/system-traffic.at | 105 +++++++++ tests/test-psample.c | 282 ++++++++++++++++++++++++ vswitchd/bridge.c | 78 ++++++- vswitchd/vswitch.ovsschema | 9 +- vswitchd/vswitch.xml | 39 +++- 33 files changed, 1425 insertions(+), 62 deletions(-) create mode 100644 include/linux/psample.h create mode 100644 ofproto/ofproto-dpif-lsample.c create mode 100644 ofproto/ofproto-dpif-lsample.h create mode 100644 tests/test-psample.c