Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1526354/?format=api
http://patchwork.ozlabs.org/api/patches/1526354/?format=api", "web_url": "http://patchwork.ozlabs.org/project/ovn/patch/72c687b8bb6cc5eb1a55c7dcd9710ed953033ce1.1631229791.git.lorenzo.bianconi@redhat.com/", "project": { "id": 68, "url": "http://patchwork.ozlabs.org/api/projects/68/?format=api", "name": "Open Virtual Network development", "link_name": "ovn", "list_id": "ovs-dev.openvswitch.org", "list_email": "ovs-dev@openvswitch.org", "web_url": "http://openvswitch.org/", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<72c687b8bb6cc5eb1a55c7dcd9710ed953033ce1.1631229791.git.lorenzo.bianconi@redhat.com>", "list_archive_url": null, "date": "2021-09-09T23:27:44", "name": "[ovs-dev,v3] controller: add datapath meter capability check", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": false, "hash": "607ec106dfe621afb82cf8a3778e21c42d65e592", "submitter": { "id": 73083, "url": "http://patchwork.ozlabs.org/api/people/73083/?format=api", "name": "Lorenzo Bianconi", "email": "lorenzo.bianconi@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/ovn/patch/72c687b8bb6cc5eb1a55c7dcd9710ed953033ce1.1631229791.git.lorenzo.bianconi@redhat.com/mbox/", "series": [ { "id": 261687, "url": "http://patchwork.ozlabs.org/api/series/261687/?format=api", "web_url": "http://patchwork.ozlabs.org/project/ovn/list/?series=261687", "date": "2021-09-09T23:27:44", "name": "[ovs-dev,v3] controller: add datapath meter capability check", "version": 3, "mbox": "http://patchwork.ozlabs.org/series/261687/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1526354/comments/", "check": "fail", "checks": "http://patchwork.ozlabs.org/api/patches/1526354/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<ovs-dev-bounces@openvswitch.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "ovs-dev@openvswitch.org" ], "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "ovs-dev@lists.linuxfoundation.org" ], "Authentication-Results": [ "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=NqPy5dbD;\n\tdkim-atps=neutral", "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org\n (client-ip=140.211.166.136; helo=smtp3.osuosl.org;\n envelope-from=ovs-dev-bounces@openvswitch.org; receiver=<UNKNOWN>)", "relay.mimecast.com;\n auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lorenzo.bianconi@redhat.com" ], "Received": [ "from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 4H5FYG50SJz9sRf\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Sep 2021 09:28:02 +1000 (AEST)", "from localhost (localhost [127.0.0.1])\n\tby smtp3.osuosl.org (Postfix) with ESMTP id D366A60B4B;\n\tThu, 9 Sep 2021 23:27:59 +0000 (UTC)", "from smtp3.osuosl.org ([127.0.0.1])\n\tby localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id nD2pCCVOiRQI; Thu, 9 Sep 2021 23:27:58 +0000 (UTC)", "from lists.linuxfoundation.org (lf-lists.osuosl.org\n [IPv6:2605:bc80:3010:104::8cd3:938])\n\tby smtp3.osuosl.org (Postfix) with ESMTPS id D31B7606CB;\n\tThu, 9 Sep 2021 23:27:57 +0000 (UTC)", "from lf-lists.osuosl.org (localhost [127.0.0.1])\n\tby lists.linuxfoundation.org (Postfix) with ESMTP id 7BA15C000F;\n\tThu, 9 Sep 2021 23:27:57 +0000 (UTC)", "from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136])\n by lists.linuxfoundation.org (Postfix) with ESMTP id 49023C000D\n for <ovs-dev@openvswitch.org>; Thu, 9 Sep 2021 23:27:55 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n by smtp3.osuosl.org (Postfix) with ESMTP id 44F0E60673\n for <ovs-dev@openvswitch.org>; Thu, 9 Sep 2021 23:27:55 +0000 (UTC)", "from smtp3.osuosl.org ([127.0.0.1])\n by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n with ESMTP id gEdvPPwGZfoa for <ovs-dev@openvswitch.org>;\n Thu, 9 Sep 2021 23:27:54 +0000 (UTC)", "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by smtp3.osuosl.org (Postfix) with ESMTPS id 37B1E606CB\n for <ovs-dev@openvswitch.org>; Thu, 9 Sep 2021 23:27:53 +0000 (UTC)", "from mail-ej1-f70.google.com (mail-ej1-f70.google.com\n [209.85.218.70]) (Using TLS) by relay.mimecast.com with ESMTP id\n us-mta-490-Y32q8FllPSmC470Lq8QT-g-1; Thu, 09 Sep 2021 19:27:51 -0400", "by mail-ej1-f70.google.com with SMTP id\n ga42-20020a1709070c2a00b005dc8c1cc3a1so66290ejc.17\n for <ovs-dev@openvswitch.org>; Thu, 09 Sep 2021 16:27:50 -0700 (PDT)", "from lore-desk.redhat.com (net-37-179-26-33.cust.vodafonedsl.it.\n [37.179.26.33])\n by smtp.gmail.com with ESMTPSA id q14sm1524075ejc.93.2021.09.09.16.27.48\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 09 Sep 2021 16:27:48 -0700 (PDT)" ], "X-Virus-Scanned": [ "amavisd-new at osuosl.org", "amavisd-new at osuosl.org" ], "X-Greylist": "domain auto-whitelisted by SQLgrey-1.8.0", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1631230073;\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 bh=fNgFo7CwyT4H4T7RdBnVaYry/VrHUYkLgLV6khxKoU0=;\n b=NqPy5dbD10zHMbf5RVhM6kJji0QofbvisAHVD5u9x6KUjlK2iufcj5SKKOq3l3ubZbIKay\n 8yhzUi6n0WTNkimuQwbqcgXUtXvifLc1IdUGvWKD9jzU/7yF1fjdXQil+bhjbf1XSz7Fe6\n qjWJcz318/k6MA2OtKHB95RA6d9oj8M=", "X-MC-Unique": "Y32q8FllPSmC470Lq8QT-g-1", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20210112;\n h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n :content-transfer-encoding;\n bh=fNgFo7CwyT4H4T7RdBnVaYry/VrHUYkLgLV6khxKoU0=;\n b=JrcHP1F76MPtyHw2j/2nH5GREIX5J1aUjdN/GwLaj+dxlYI6BMEZITFpW4O6S9rA42\n 2bqn3fWxiupPGME0PmAI+Q/n63bKTRao10M/1Ollo7FwcaFVR10/FI7M/xF3EksJBAnP\n wYi6cMCq1rAPIJduU5g00Tw6PX2+UUJ2PBYNbT4DI3p4Kg0lCAAb3exhIr3/chmM/+3N\n gljGiEkEIGXYLdd62mClvIPRQYoWglbodEMYUFHfjYlxNi3vORMdQPnkygzvQCzVLS2M\n 7ATqHaqRi+vfSV+NfJzESp+VZq3ao8w3WJd6dTOQnqsLDvMGZ5LNbTQ3QA83fq6htBny\n 5QbQ==", "X-Gm-Message-State": "AOAM532DBMwLQJ7EUtR5MTR7KS56veZeRw8ux50ceI5Fmu6vLZuN5L19\n XuhmB6RwNMQ5Ulm0drZ0oQKbb6Lr7FwgWi/XA/2aBQd1Q3jXD75eEWvsnG7I8WQYKLqnba40gzL\n f+REdMQXjgKkfA+66Ez27uO50tYdeJi9Ug9gXtsz0sJK57bK6QE0RKe0TjGqaZ3mzI1GNmEtd5K\n XcWW2u", "X-Received": [ "by 2002:a50:8e42:: with SMTP id 2mr5833598edx.338.1631230069558;\n Thu, 09 Sep 2021 16:27:49 -0700 (PDT)", "by 2002:a50:8e42:: with SMTP id 2mr5833568edx.338.1631230069246;\n Thu, 09 Sep 2021 16:27:49 -0700 (PDT)" ], "X-Google-Smtp-Source": "\n ABdhPJyx04zrUc8jlNgMJUyxZymgzpw8DmovQEetzB/y7Im36SQR+sijWXHojBJ6DLURjZpNuO2LnA==", "From": "Lorenzo Bianconi <lorenzo.bianconi@redhat.com>", "To": "ovs-dev@openvswitch.org", "Date": "Fri, 10 Sep 2021 01:27:44 +0200", "Message-Id": "\n <72c687b8bb6cc5eb1a55c7dcd9710ed953033ce1.1631229791.git.lorenzo.bianconi@redhat.com>", "X-Mailer": "git-send-email 2.31.1", "MIME-Version": "1.0", "X-Mimecast-Spam-Score": "0", "X-Mimecast-Originator": "redhat.com", "Cc": "dceara@redhat.com", "Subject": "[ovs-dev] [PATCH v3 ovn] controller: add datapath meter capability\n\tcheck", "X-BeenThere": "ovs-dev@openvswitch.org", "X-Mailman-Version": "2.1.15", "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>", "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": "Dump datapath meter capabilities before configuring meters in\novn-controller\n\nSigned-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>\n---\nChanges since v2:\n- move meter capability logic in lib/features.c\n\nChanges since v1:\n- move rconn in ovn-controller to avoid concurrency issues\n---\n controller/ovn-controller.c | 4 ++\n include/ovn/features.h | 7 +++\n lib/actions.c | 3 ++\n lib/automake.mk | 1 +\n lib/features.c | 89 +++++++++++++++++++++++++++++++++++++\n tests/ovn.at | 4 +-\n 6 files changed, 106 insertions(+), 2 deletions(-)", "diff": "diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c\nindex 0031a1035..8c6d4393b 100644\n--- a/controller/ovn-controller.c\n+++ b/controller/ovn-controller.c\n@@ -3523,6 +3523,9 @@ main(int argc, char *argv[])\n ovsrec_server_has_datapath_table(ovs_idl_loop.idl)\n ? &br_int_dp\n : NULL);\n+ if (br_int) {\n+ ovs_feature_support_init(br_int);\n+ }\n \n /* Enable ACL matching for double tagged traffic. */\n if (ovs_idl_txn) {\n@@ -3898,6 +3901,7 @@ loop_done:\n ovsdb_idl_loop_destroy(&ovs_idl_loop);\n ovsdb_idl_loop_destroy(&ovnsb_idl_loop);\n \n+ ovs_feature_support_deinit();\n free(ovs_remote);\n service_stop();\n \ndiff --git a/include/ovn/features.h b/include/ovn/features.h\nindex c35d59b14..4a6d45d88 100644\n--- a/include/ovn/features.h\n+++ b/include/ovn/features.h\n@@ -23,17 +23,24 @@\n /* ovn-controller supported feature names. */\n #define OVN_FEATURE_PORT_UP_NOTIF \"port-up-notif\"\n \n+struct ovsrec_bridge;\n+struct rconn;\n+\n /* OVS datapath supported features. Based on availability OVN might generate\n * different types of openflows.\n */\n enum ovs_feature_support_bits {\n OVS_CT_ZERO_SNAT_SUPPORT_BIT,\n+ OVS_DP_METER_SUPPORT_BIT,\n };\n \n enum ovs_feature_value {\n OVS_CT_ZERO_SNAT_SUPPORT = (1 << OVS_CT_ZERO_SNAT_SUPPORT_BIT),\n+ OVS_DP_METER_SUPPORT = (1 << OVS_DP_METER_SUPPORT_BIT),\n };\n \n+void ovs_feature_support_init(const struct ovsrec_bridge *br_int);\n+void ovs_feature_support_deinit(void);\n bool ovs_feature_is_supported(enum ovs_feature_value feature);\n bool ovs_feature_support_update(const struct smap *ovs_capabilities);\n \ndiff --git a/lib/actions.c b/lib/actions.c\nindex c572e88ae..7cf6be308 100644\n--- a/lib/actions.c\n+++ b/lib/actions.c\n@@ -87,6 +87,9 @@ encode_start_controller_op(enum action_opcode opcode, bool pause,\n oc->max_len = UINT16_MAX;\n oc->reason = OFPR_ACTION;\n oc->pause = pause;\n+ if (!ovs_feature_is_supported(OVS_DP_METER_SUPPORT)) {\n+ meter_id = NX_CTLR_NO_METER;\n+ }\n oc->meter_id = meter_id;\n \n struct action_header ah = { .opcode = htonl(opcode) };\ndiff --git a/lib/automake.mk b/lib/automake.mk\nindex ddfe33948..9f9f447d5 100644\n--- a/lib/automake.mk\n+++ b/lib/automake.mk\n@@ -2,6 +2,7 @@ lib_LTLIBRARIES += lib/libovn.la\n lib_libovn_la_LDFLAGS = \\\n $(OVS_LTINFO) \\\n -Wl,--version-script=$(top_builddir)/lib/libovn.sym \\\n+ $(OVS_LIBDIR)/libopenvswitch.la \\\n $(AM_LDFLAGS)\n lib_libovn_la_SOURCES = \\\n \tlib/acl-log.c \\\ndiff --git a/lib/features.c b/lib/features.c\nindex fddf4c450..bd7ba79ef 100644\n--- a/lib/features.c\n+++ b/lib/features.c\n@@ -18,7 +18,14 @@\n #include <stdlib.h>\n \n #include \"lib/util.h\"\n+#include \"lib/dirs.h\"\n+#include \"socket-util.h\"\n+#include \"lib/vswitch-idl.h\"\n #include \"openvswitch/vlog.h\"\n+#include \"openvswitch/ofpbuf.h\"\n+#include \"openvswitch/rconn.h\"\n+#include \"openvswitch/ofp-msgs.h\"\n+#include \"openvswitch/ofp-meter.h\"\n #include \"ovn/features.h\"\n \n VLOG_DEFINE_THIS_MODULE(features);\n@@ -40,11 +47,15 @@ static uint32_t supported_ovs_features;\n \n static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 5);\n \n+/* ovs-vswitchd connection. */\n+static struct rconn *swconn;\n+\n static bool\n ovs_feature_is_valid(enum ovs_feature_value feature)\n {\n switch (feature) {\n case OVS_CT_ZERO_SNAT_SUPPORT:\n+ case OVS_DP_METER_SUPPORT:\n return true;\n default:\n return false;\n@@ -58,6 +69,80 @@ ovs_feature_is_supported(enum ovs_feature_value feature)\n return supported_ovs_features & feature;\n }\n \n+static bool\n+ovn_controller_get_ofp_capa(void)\n+{\n+ if (!swconn) {\n+ return false;\n+ }\n+\n+ rconn_run(swconn);\n+ if (!rconn_is_connected(swconn)) {\n+ return false;\n+ }\n+\n+ bool ret = false;\n+ /* dump datapath meter capabilities. */\n+ struct ofpbuf *msg = ofpraw_alloc(OFPRAW_OFPST13_METER_FEATURES_REQUEST,\n+ rconn_get_version(swconn), 0);\n+ rconn_send(swconn, msg, NULL);\n+ for (int i = 0; i < 10; i++) {\n+ msg = rconn_recv(swconn);\n+ if (!msg) {\n+ break;\n+ }\n+\n+ const struct ofp_header *oh = msg->data;\n+ enum ofptype type;\n+ ofptype_decode(&type, oh);\n+\n+ if (type == OFPTYPE_METER_FEATURES_STATS_REPLY) {\n+ struct ofputil_meter_features mf;\n+ ofputil_decode_meter_features(oh, &mf);\n+\n+ bool old_state = supported_ovs_features & OVS_DP_METER_SUPPORT;\n+ bool new_state = mf.max_meters > 0;\n+\n+ if (old_state != new_state) {\n+ ret = true;\n+ if (new_state) {\n+ supported_ovs_features |= OVS_DP_METER_SUPPORT;\n+ } else {\n+ supported_ovs_features &= ~OVS_DP_METER_SUPPORT;\n+ }\n+ }\n+ }\n+ ofpbuf_delete(msg);\n+ }\n+\n+ return ret;\n+}\n+\n+void\n+ovs_feature_support_init(const struct ovsrec_bridge *br_int)\n+{\n+ if (!swconn) {\n+ swconn = rconn_create(5, 0, DSCP_DEFAULT, 1 << OFP15_VERSION);\n+ }\n+\n+ if (swconn && !rconn_is_connected(swconn)) {\n+ char *target = xasprintf(\"unix:%s/%s.mgmt\", ovs_rundir(),\n+ br_int->name);\n+ if (strcmp(target, rconn_get_target(swconn))) {\n+ VLOG_INFO(\"%s: connecting to switch\", target);\n+ rconn_connect(swconn, target, target);\n+ }\n+ free(target);\n+ }\n+}\n+\n+void\n+ovs_feature_support_deinit(void)\n+{\n+ rconn_destroy(swconn);\n+ swconn = NULL;\n+}\n+\n /* Returns 'true' if the set of tracked OVS features has been updated. */\n bool\n ovs_feature_support_update(const struct smap *ovs_capabilities)\n@@ -69,6 +154,10 @@ ovs_feature_support_update(const struct smap *ovs_capabilities)\n ovs_capabilities = &empty_caps;\n }\n \n+ if (ovn_controller_get_ofp_capa()) {\n+ updated = true;\n+ }\n+\n for (size_t i = 0; i < ARRAY_SIZE(all_ovs_features); i++) {\n enum ovs_feature_value value = all_ovs_features[i].value;\n const char *name = all_ovs_features[i].name;\ndiff --git a/tests/ovn.at b/tests/ovn.at\nindex 5104a6895..fdee26ac9 100644\n--- a/tests/ovn.at\n+++ b/tests/ovn.at\n@@ -1529,9 +1529,9 @@ log(verdict=allow, severity=warning);\n log(name=\"test1\", verdict=drop, severity=info);\n encodes as controller(userdata=00.00.00.07.00.00.00.00.01.06.74.65.73.74.31)\n log(verdict=drop, severity=info, meter=\"meter1\");\n- encodes as controller(userdata=00.00.00.07.00.00.00.00.01.06,meter_id=4)\n+ encodes as controller(userdata=00.00.00.07.00.00.00.00.01.06)\n log(name=\"test1\", verdict=drop, severity=info, meter=\"meter1\");\n- encodes as controller(userdata=00.00.00.07.00.00.00.00.01.06.74.65.73.74.31,meter_id=4)\n+ encodes as controller(userdata=00.00.00.07.00.00.00.00.01.06.74.65.73.74.31)\n log(verdict=drop);\n formats as log(verdict=drop, severity=info);\n encodes as controller(userdata=00.00.00.07.00.00.00.00.01.06)\n", "prefixes": [ "ovs-dev", "v3" ] }{ "id": 1526354, "url": "