{"id":2197696,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2197696/?format=json","project":{"id":47,"url":"http://patchwork.ozlabs.org/api/1.0/projects/47/?format=json","name":"Open vSwitch","link_name":"openvswitch","list_id":"ovs-dev.openvswitch.org","list_email":"ovs-dev@openvswitch.org","web_url":"http://openvswitch.org/","scm_url":"git@github.com:openvswitch/ovs.git","webscm_url":"https://github.com/openvswitch/ovs"},"msgid":"<20260218103716.3135692-2-amorenoz@redhat.com>","date":"2026-02-18T10:37:15","name":"[ovs-dev,RFC,v1,1/2] ofproto-dpif-upcall: Introduce tracing scheleton.","commit_ref":null,"pull_url":null,"state":"rfc","archived":false,"hash":"0a07b377099bab0c03d542dd568710f05285abf0","submitter":{"id":77477,"url":"http://patchwork.ozlabs.org/api/1.0/people/77477/?format=json","name":"Adrián Moreno","email":"amorenoz@redhat.com"},"delegate":{"id":57772,"url":"http://patchwork.ozlabs.org/api/1.0/users/57772/?format=json","username":"imaximets","first_name":"Ilya","last_name":"Maximets","email":"i.maximets@samsung.com"},"mbox":"http://patchwork.ozlabs.org/project/openvswitch/patch/20260218103716.3135692-2-amorenoz@redhat.com/mbox/","series":[{"id":492538,"url":"http://patchwork.ozlabs.org/api/1.0/series/492538/?format=json","date":"2026-02-18T10:37:14","name":"Introduce upcall (live) tracing.","version":1,"mbox":"http://patchwork.ozlabs.org/series/492538/mbox/"}],"check":"success","checks":"http://patchwork.ozlabs.org/api/patches/2197696/checks/","tags":{},"headers":{"Return-Path":"<ovs-dev-bounces@openvswitch.org>","X-Original-To":["incoming@patchwork.ozlabs.org","dev@openvswitch.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","ovs-dev@lists.linuxfoundation.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=Bh2XrVOU;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org\n (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org;\n envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org)","smtp4.osuosl.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key)\n header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=Bh2XrVOU","smtp4.osuosl.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com"],"Received":["from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fGCdC4Sp7z1xwr\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 18 Feb 2026 21:37:34 +1100 (AEDT)","from localhost (localhost [127.0.0.1])\n\tby smtp4.osuosl.org (Postfix) with ESMTP id DF9B84080D;\n\tWed, 18 Feb 2026 10:37:31 +0000 (UTC)","from smtp4.osuosl.org ([127.0.0.1])\n by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id c5gEEjShzB06; Wed, 18 Feb 2026 10:37:30 +0000 (UTC)","from lists.linuxfoundation.org (lf-lists.osuosl.org\n [IPv6:2605:bc80:3010:104::8cd3:938])\n\tby smtp4.osuosl.org (Postfix) with ESMTPS id 14997407CF;\n\tWed, 18 Feb 2026 10:37:30 +0000 (UTC)","from lf-lists.osuosl.org (localhost [127.0.0.1])\n\tby lists.linuxfoundation.org (Postfix) with ESMTP id D1184C0070;\n\tWed, 18 Feb 2026 10:37:29 +0000 (UTC)","from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n by lists.linuxfoundation.org (Postfix) with ESMTP id 5796CC0033\n for <dev@openvswitch.org>; Wed, 18 Feb 2026 10:37:28 +0000 (UTC)","from localhost (localhost [127.0.0.1])\n by smtp4.osuosl.org (Postfix) with ESMTP id 6725440368\n for <dev@openvswitch.org>; Wed, 18 Feb 2026 10:37:27 +0000 (UTC)","from smtp4.osuosl.org ([127.0.0.1])\n by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id KMGMfNV5d-IJ for <dev@openvswitch.org>;\n Wed, 18 Feb 2026 10:37:26 +0000 (UTC)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by smtp4.osuosl.org (Postfix) with ESMTPS id 7B2F74068F\n for <dev@openvswitch.org>; Wed, 18 Feb 2026 10:37:26 +0000 (UTC)","from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-646-jsAUGBaTMtSW1qwjREfobA-1; Wed,\n 18 Feb 2026 05:37:23 -0500","from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 4F3B518002C3\n for <dev@openvswitch.org>; Wed, 18 Feb 2026 10:37:22 +0000 (UTC)","from antares.redhat.com (unknown [10.45.224.73])\n by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 41D1B19560B5; Wed, 18 Feb 2026 10:37:20 +0000 (UTC)"],"X-Virus-Scanned":["amavis at osuosl.org","amavis at osuosl.org"],"X-Comment":"SPF check N/A for local connections -\n client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org;\n envelope-from=ovs-dev-bounces@openvswitch.org; receiver=<UNKNOWN> ","DKIM-Filter":["OpenDKIM Filter v2.11.0 smtp4.osuosl.org 14997407CF","OpenDKIM Filter v2.11.0 smtp4.osuosl.org 7B2F74068F"],"Received-SPF":"Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124;\n helo=us-smtp-delivery-124.mimecast.com; envelope-from=amorenoz@redhat.com;\n receiver=<UNKNOWN>","DMARC-Filter":"OpenDMARC Filter v1.4.2 smtp4.osuosl.org 7B2F74068F","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1771411045;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=5tO9jI7ppqFtkZwi7EVtwmZo+UaKfS+7DSJj6D63QI0=;\n b=Bh2XrVOUz0WkpOa6gs3JdMLhzwoOKvOE8uIZ6RTSXvpm/o2uVjABqCLbQWl3O6A1++vis5\n NCqG++raiQFrhnGLf97eewlxvDE8OiE8X+JDG6V/UltE6Pqsjc1cbYWeDKbVOwn0yMH/iq\n LBlV5enr0U8RUlYVkTijcWAizY05VXg=","X-MC-Unique":"jsAUGBaTMtSW1qwjREfobA-1","X-Mimecast-MFC-AGG-ID":"jsAUGBaTMtSW1qwjREfobA_1771411042","To":"dev@openvswitch.org","Date":"Wed, 18 Feb 2026 11:37:15 +0100","Message-ID":"<20260218103716.3135692-2-amorenoz@redhat.com>","In-Reply-To":"<20260218103716.3135692-1-amorenoz@redhat.com>","References":"<20260218103716.3135692-1-amorenoz@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.0 on 10.30.177.12","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"Lu-8PEY0aC6mcQCfp3G1kJPrNZXJ0PY98y4XX6KHrO0_1771411042","X-Mimecast-Originator":"redhat.com","Subject":"[ovs-dev] [RFC PATCH v1 1/2] ofproto-dpif-upcall: Introduce tracing\n scheleton.","X-BeenThere":"ovs-dev@openvswitch.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"<ovs-dev.openvswitch.org>","List-Unsubscribe":"<https://mail.openvswitch.org/mailman/options/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=unsubscribe>","List-Archive":"<http://mail.openvswitch.org/pipermail/ovs-dev/>","List-Post":"<mailto:ovs-dev@openvswitch.org>","List-Help":"<mailto:ovs-dev-request@openvswitch.org?subject=help>","List-Subscribe":"<https://mail.openvswitch.org/mailman/listinfo/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=subscribe>","From":"Adrian Moreno via dev <ovs-dev@openvswitch.org>","Reply-To":"Adrian Moreno <amorenoz@redhat.com>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"ovs-dev-bounces@openvswitch.org","Sender":"\"dev\" <ovs-dev-bounces@openvswitch.org>"},"content":"Introduce the scheleton of what will be the upcall tracing\ninfrastructure.\n\nTwo commands are created\nupcall/trace/create: creates a upcall_tracing instance attached to a\nudpif\nupcall/trace/show: displays all the upcall_tracing instances\nupcall/trace/delete: deletes all the upcall_tracing instances\n\nSigned-off-by: Adrian Moreno <amorenoz@redhat.com>\n---\n ofproto/automake.mk                 |  2 +\n ofproto/ofproto-dpif-upcall-trace.c | 90 +++++++++++++++++++++++++++++\n ofproto/ofproto-dpif-upcall-trace.h | 33 +++++++++++\n ofproto/ofproto-dpif-upcall.c       | 89 ++++++++++++++++++++++++++++\n 4 files changed, 214 insertions(+)\n create mode 100644 ofproto/ofproto-dpif-upcall-trace.c\n create mode 100644 ofproto/ofproto-dpif-upcall-trace.h","diff":"diff --git a/ofproto/automake.mk b/ofproto/automake.mk\nindex cb1361b8a..c1062f5b3 100644\n--- a/ofproto/automake.mk\n+++ b/ofproto/automake.mk\n@@ -44,6 +44,8 @@ ofproto_libofproto_la_SOURCES = \\\n \tofproto/ofproto-dpif-trace.h \\\n \tofproto/ofproto-dpif-upcall.c \\\n \tofproto/ofproto-dpif-upcall.h \\\n+\tofproto/ofproto-dpif-upcall-trace.c \\\n+\tofproto/ofproto-dpif-upcall-trace.h \\\n \tofproto/ofproto-dpif-xlate.c \\\n \tofproto/ofproto-dpif-xlate.h \\\n \tofproto/ofproto-provider.h \\\ndiff --git a/ofproto/ofproto-dpif-upcall-trace.c b/ofproto/ofproto-dpif-upcall-trace.c\nnew file mode 100644\nindex 000000000..94f158cf9\n--- /dev/null\n+++ b/ofproto/ofproto-dpif-upcall-trace.c\n@@ -0,0 +1,90 @@\n+#include <config.h>\n+\n+#include \"ofproto-dpif-upcall-trace.h\"\n+\n+#include <openvswitch/dynamic-string.h>\n+#include <openvswitch/ofp-flow.h>\n+#include <openvswitch/ofp-port.h>\n+#include <openvswitch/vlog.h>\n+#include \"ofproto-dpif.h\"\n+\n+VLOG_DEFINE_THIS_MODULE(upcall_trace);\n+\n+char * OVS_WARN_UNUSED_RESULT\n+upcall_tracing_create(int argc, const char *argv[],\n+                      struct ofproto_dpif **ofprotop,\n+                      struct upcall_tracing **tracingp)\n+{\n+    struct ofputil_port_map port_map = OFPUTIL_PORT_MAP_INITIALIZER(&port_map);\n+    struct upcall_tracing *tracing = xzalloc(sizeof *tracing);\n+    struct ofproto_dpif *ofproto = NULL;\n+    struct flow_wildcards wc_filter;\n+    const struct ofport *ofport;\n+    struct flow flow_filter;\n+    char *error = NULL;\n+\n+    ovs_mutex_init(&tracing->mutex);\n+    ovs_list_init(&tracing->blocks);\n+    tracing->n_blocks = 0;\n+    tracing->last_trace_id = 0;\n+    tracing->max_blocks =  UPCALL_TRACE_DEFAULT_MAX_SIZE;\n+\n+    if (argc < 3) {\n+        error = xasprintf(\"Missing arguments\");\n+        goto exit;\n+    }\n+\n+    ofproto = ofproto_dpif_lookup_by_name(argv[1]);\n+    if (!ofproto) {\n+        error = xasprintf(\"%s: unknown bridge\", argv[1]);\n+        goto exit;\n+    }\n+\n+    HMAP_FOR_EACH (ofport, hmap_node, &(ofproto->up.ports)) {\n+        ofputil_port_map_put(&port_map, ofport->ofp_port,\n+                             netdev_get_name(ofport->netdev));\n+    }\n+\n+    error = parse_ofp_exact_flow(&flow_filter, &wc_filter, NULL, argv[2],\n+                                 &port_map);\n+    if (error) {\n+        goto exit;\n+    }\n+    match_init(&tracing->filter, &flow_filter, &wc_filter);\n+\n+\n+exit:\n+    if (error) {\n+        upcall_tracing_destroy(tracing);\n+        *tracingp = NULL;\n+    } else {\n+        *ofprotop = ofproto;\n+        *tracingp = tracing;\n+    }\n+    ofputil_port_map_destroy(&port_map);\n+    return error;\n+}\n+\n+void\n+upcall_tracing_destroy(struct upcall_tracing *tracing)\n+{\n+    if (tracing) {\n+        ovs_mutex_destroy(&tracing->mutex);\n+        free(tracing);\n+    }\n+}\n+\n+void\n+upcall_tracing_format(const struct upcall_tracing *tracing, struct ds *output)\n+{\n+    if (tracing) {\n+        ovs_mutex_lock(&tracing->mutex);\n+        ds_put_format(output, \"enabled, max_traces=%\"PRIuSIZE\", \"\n+                      \"current=%\"PRIuSIZE\", filter: \",\n+                      tracing->max_blocks, tracing->n_blocks);\n+        match_format(&tracing->filter, NULL, output, 0);\n+        ovs_mutex_unlock(&tracing->mutex);\n+    } else {\n+        ds_put_cstr(output, \"disabled\");\n+    }\n+}\ndiff --git a/ofproto/ofproto-dpif-upcall-trace.h b/ofproto/ofproto-dpif-upcall-trace.h\nnew file mode 100644\nindex 000000000..150d48d29\n--- /dev/null\n+++ b/ofproto/ofproto-dpif-upcall-trace.h\n@@ -0,0 +1,33 @@\n+#ifndef OFPROTO_DPIF_UPCALL_TRACE_H\n+#define OFPROTO_DPIF_UPCALL_TRACE_H 1\n+\n+#include \"openvswitch/list.h\"\n+#include \"openvswitch/match.h\"\n+#include \"openvswitch/ofp-port.h\"\n+#include \"ovs-thread.h\"\n+\n+struct flow;\n+struct ofproto_dpif;\n+struct xlate_in;\n+struct xlate_out;\n+\n+#define UPCALL_TRACE_DEFAULT_MAX_SIZE 64\n+\n+/* upcall_tracing - The main upcall_tracing object configured by the user\n+ * and that stores all the generated traces. */\n+struct upcall_tracing {\n+    /* Match filter (optional). */\n+    struct match filter;\n+\n+    struct ovs_mutex mutex;\n+    struct ovs_list blocks;     /* List of upcall_trace_block, oldest first. */\n+    size_t n_blocks;\n+    size_t max_blocks;\n+    uint64_t last_trace_id;\n+};\n+char * upcall_tracing_create(int argc, const char *argv[],\n+                             struct ofproto_dpif **ofprotop,\n+                             struct upcall_tracing **tracingp);\n+void upcall_tracing_destroy(struct upcall_tracing *);\n+void upcall_tracing_format(const struct upcall_tracing *, struct ds *);\n+#endif /*OFPROTO_DPIF_UPCALL_TRACE_H */\ndiff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c\nindex 8e4897202..20fa302a5 100644\n--- a/ofproto/ofproto-dpif-upcall.c\n+++ b/ofproto/ofproto-dpif-upcall.c\n@@ -34,6 +34,7 @@\n #include \"openvswitch/ofpbuf.h\"\n #include \"ofproto-dpif-ipfix.h\"\n #include \"ofproto-dpif-sflow.h\"\n+#include \"ofproto-dpif-upcall-trace.h\"\n #include \"ofproto-dpif-xlate.h\"\n #include \"ofproto-dpif-xlate-cache.h\"\n #include \"ofproto-dpif-trace.h\"\n@@ -196,6 +197,8 @@ struct udpif {\n     size_t n_conns;                    /* Number of connections waiting. */\n \n     long long int offload_rebalance_time;  /* Time of last offload rebalance */\n+\n+    OVSRCU_TYPE(struct upcall_tracing *) tracing;  /* Tracing configuration. */\n };\n \n enum upcall_type {\n@@ -404,6 +407,13 @@ static void upcall_unixctl_resume(struct unixctl_conn *conn, int argc,\n static void upcall_unixctl_ofproto_detrace(struct unixctl_conn *, int argc,\n                                            const char *argv[], void *aux);\n \n+static void upcall_unixctl_trace_create(struct unixctl_conn *, int argc,\n+                                        const char *argv[], void *aux);\n+static void upcall_unixctl_trace_show(struct unixctl_conn *, int argc,\n+                                      const char *argv[], void *aux);\n+static void upcall_unixctl_trace_delete(struct unixctl_conn *, int argc,\n+                                        const char *argv[], void *aux);\n+\n static struct udpif_key *ukey_create_from_upcall(struct upcall *,\n                                                  struct flow_wildcards *);\n static int ukey_create_from_dpif_flow(const struct udpif *,\n@@ -482,6 +492,12 @@ udpif_init(void)\n                                  upcall_unixctl_resume, NULL);\n         unixctl_command_register(\"ofproto/detrace\", \"UFID [pmd=PMD-ID]\", 1, 2,\n                                  upcall_unixctl_ofproto_detrace, NULL);\n+        unixctl_command_register(\"upcall/trace/create\", \"bridge flow\", 2, 2,\n+                                 upcall_unixctl_trace_create, NULL);\n+        unixctl_command_register(\"upcall/trace/show\", \"\", 0, 0,\n+                                 upcall_unixctl_trace_show, NULL);\n+        unixctl_command_register(\"upcall/trace/delete\", \"\", 0, 1,\n+                                 upcall_unixctl_trace_delete, NULL);\n         ovsthread_once_done(&once);\n     }\n }\n@@ -3411,6 +3427,79 @@ upcall_unixctl_ofproto_detrace(struct unixctl_conn *conn, int argc,\n     ds_destroy(&ds);\n }\n \n+static void upcall_unixctl_trace_create(struct unixctl_conn *conn, int argc,\n+                                        const char *argv[],\n+                                        void *aux OVS_UNUSED)\n+{\n+    struct upcall_tracing *tracing;\n+    struct ofproto_dpif *ofproto;\n+    struct udpif *udpif;\n+    char *error;\n+\n+    error = upcall_tracing_create(argc, argv, &ofproto, &tracing);\n+    if (error) {\n+        unixctl_command_reply_error(conn, error);\n+        free(error);\n+        return;\n+    }\n+\n+    udpif = ofproto->backer->udpif;\n+    struct upcall_tracing *old_tracing =\n+        ovsrcu_get_protected(struct upcall_tracing *, &udpif->tracing);\n+\n+    if (old_tracing) {\n+        ovsrcu_postpone(upcall_tracing_destroy, old_tracing);\n+    }\n+\n+    ovsrcu_set(&udpif->tracing, tracing);\n+    unixctl_command_reply(conn, \"\");\n+}\n+\n+static void upcall_unixctl_trace_show(struct unixctl_conn *conn,\n+                                      int argc OVS_UNUSED,\n+                                      const char *argv[] OVS_UNUSED,\n+                                      void *aux OVS_UNUSED)\n+{\n+    struct ds ds = DS_EMPTY_INITIALIZER;\n+    const struct shash_node **backers;\n+    int i;\n+\n+    backers = shash_sort(&all_dpif_backers);\n+    for (i = 0; i < shash_count(&all_dpif_backers); i++) {\n+        struct dpif_backer *backer = (struct dpif_backer *)(backers[i]->data);\n+        struct upcall_tracing *tracing =\n+            ovsrcu_get(struct upcall_tracing *, &backer->udpif->tracing);\n+        ds_put_format(&ds, \"%s: \", dpif_name(backer->dpif));\n+        upcall_tracing_format(tracing, &ds);\n+        ds_put_cstr(&ds, \"\\n\");\n+    }\n+    unixctl_command_reply(conn, ds_cstr(&ds));\n+    ds_destroy(&ds);\n+}\n+\n+static void upcall_unixctl_trace_delete(struct unixctl_conn *conn,\n+                                        int argc OVS_UNUSED,\n+                                        const char *argv[] OVS_UNUSED,\n+                                        void *aux OVS_UNUSED)\n+{\n+    const struct shash_node **backers;\n+    int i;\n+\n+    backers = shash_sort(&all_dpif_backers);\n+    for (i = 0; i < shash_count(&all_dpif_backers); i++) {\n+        struct dpif_backer *backer = (struct dpif_backer *)(backers[i]->data);\n+        struct upcall_tracing *old_tracing =\n+            ovsrcu_get_protected(struct upcall_tracing *,\n+                                 &backer->udpif->tracing);\n+\n+        if (old_tracing) {\n+            ovsrcu_postpone(upcall_tracing_destroy, old_tracing);\n+        }\n+\n+        ovsrcu_set(&backer->udpif->tracing, NULL);\n+    }\n+    unixctl_command_reply(conn, \"\");\n+}\n \n /* Flows are sorted in the following order:\n  * netdev, flow state (offloaded/kernel path), flow_pps_rate.\n","prefixes":["ovs-dev","RFC","v1","1/2"]}