From patchwork Wed Sep 8 13:27:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1525863 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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=CAflGbRe; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H4NGj3DK2z9sVw for ; Wed, 8 Sep 2021 23:27:22 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 1D576406DF; Wed, 8 Sep 2021 13:27:19 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hP5hVmlEppNH; Wed, 8 Sep 2021 13:27:18 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id 47DE540624; Wed, 8 Sep 2021 13:27:17 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 252E4C000F; Wed, 8 Sep 2021 13:27:17 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id C32B0C000D for ; Wed, 8 Sep 2021 13:27:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id AD0256074A for ; Wed, 8 Sep 2021 13:27:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qGDgsG_x_ODG for ; Wed, 8 Sep 2021 13:27:14 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id BE24E60688 for ; Wed, 8 Sep 2021 13:27:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631107633; 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=sk2XKRO8HL0Xn5Pe6py0YRn7JbD7N/eJPhqZyL5qY+Y=; b=CAflGbReezqHdS9F+TZd8FUaE5H0w3sZ5Hz7mVQnxC83nEOrPchxJXzizCdiBMq4Xotzgv BGsSW02YH3GEB0PvrzVHUv/1JOG6qpgNMPDdd9n0Fqjxej8ex4jUMzn88SKyeghqrRalMY YJVu/707yC9mzljo9wSXBQHlPZVeFUg= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-451-jg51wZD7MjmoAH-EtofOJA-1; Wed, 08 Sep 2021 09:27:12 -0400 X-MC-Unique: jg51wZD7MjmoAH-EtofOJA-1 Received: by mail-ej1-f72.google.com with SMTP id ga42-20020a1709070c2a00b005dc8c1cc3a1so982333ejc.17 for ; Wed, 08 Sep 2021 06:27:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sk2XKRO8HL0Xn5Pe6py0YRn7JbD7N/eJPhqZyL5qY+Y=; b=7TEVYBBb0H0nxfis2P2DGsAXdgX3FhfL1LbcGx5FqFKOu+cf5ct2ry9BFDhuKEhzb7 a1P6W9tKh2h0ez8xV99X+fwkXoBPRJOL5affJ4Qx7eZFNKwTVpb4xZw7/6iliQBz2bNi UmQOZXmimVgO92KOpos7a6yY7qVFXqa5iSBLCsgHEYKNKIkrp2/T0EkNvtjDWDVDPs4p M4iaw1Qdz8BFQViqPzL/r/sNGSOAJvg00ZtKwGtSLdTTMAqrOGyGuvZyDq/myG/BrAB/ iRqVrQOyrVvDqFwlR3bDj6nR6LtqOvE3h1Kge71xxcelUWJWtVa6ezpvc4SlthYJibKn JFcg== X-Gm-Message-State: AOAM533MJVC7tTTg2/Ve9LQHqeIZ1BevUh6svMrBID6u6fnWw4iQc/es gIg4oA0P0KlHu9l2RN/SHCJadvyEbM6+eTrKK2R0d2SJ5FGHmP6z9yjZBT6Sb3vV2j0W2DUAvyd liETl3mGJ0X6EHMrrO3gWXPfG0E7A3Bj6f/4fVJ9RfrP/fHtk/8uoHaRZ+I4AMwUiXRq6ZCxAEV LRkr3V X-Received: by 2002:a17:906:1146:: with SMTP id i6mr4199128eja.12.1631107631059; Wed, 08 Sep 2021 06:27:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuTY3wX9dxoQUJCh3pK7kRHylztwJVE6r8jSsLMiofOS4m2M/fW3pSAvD8hqda4kAs9lWeFA== X-Received: by 2002:a17:906:1146:: with SMTP id i6mr4199089eja.12.1631107630616; Wed, 08 Sep 2021 06:27:10 -0700 (PDT) Received: from lore-desk.redhat.com (net-37-116-49-210.cust.vodafonedsl.it. [37.116.49.210]) by smtp.gmail.com with ESMTPSA id t1sm1189478edq.31.2021.09.08.06.27.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 06:27:10 -0700 (PDT) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Wed, 8 Sep 2021 15:27:07 +0200 Message-Id: X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lorenzo.bianconi@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: dceara@redhat.com Subject: [ovs-dev] [PATCH v2 ovn] controller: add datapath meter capability check 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" Dump datapath meter capabilities before configuring meters in ovn-controller Signed-off-by: Lorenzo Bianconi --- Changes since v1: - move rconn in ovn-controller to avoid concurrency issues --- controller/lflow.c | 2 +- controller/ovn-controller.c | 65 +++++++++++++++++++++++++++++++++++++ controller/ovn-controller.h | 2 ++ 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/controller/lflow.c b/controller/lflow.c index 923d8f0a4..d4fda6114 100644 --- a/controller/lflow.c +++ b/controller/lflow.c @@ -648,7 +648,7 @@ add_matches_to_flow_table(const struct sbrec_logical_flow *lflow, .ct_snat_vip_ptable = OFTABLE_CT_SNAT_HAIRPIN, .fdb_ptable = OFTABLE_GET_FDB, .fdb_lookup_ptable = OFTABLE_LOOKUP_FDB, - .ctrl_meter_id = ctrl_meter_id, + .ctrl_meter_id = dp_meter_capa > 0 ? ctrl_meter_id : NX_CTLR_NO_METER, }; ovnacts_encode(ovnacts->data, ovnacts->size, &ep, &ofpacts); diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 0031a1035..5e77f5c2e 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -73,6 +73,9 @@ #include "stopwatch.h" #include "lib/inc-proc-eng.h" #include "hmapx.h" +#include "openvswitch/rconn.h" +#include "openvswitch/ofp-msgs.h" +#include "openvswitch/ofp-meter.h" VLOG_DEFINE_THIS_MODULE(main); @@ -117,6 +120,9 @@ static const char *ssl_private_key_file; static const char *ssl_certificate_file; static const char *ssl_ca_cert_file; +/* datapath meter capabilities. */ +int dp_meter_capa = -1; + /* By default don't set an upper bound for the lflow cache and enable auto * trimming above 10K logical flows when reducing cache size by 50%. */ @@ -3065,6 +3071,58 @@ check_northd_version(struct ovsdb_idl *ovs_idl, struct ovsdb_idl *ovnsb_idl, return true; } +static void +ovn_controller_connect_vswitch(struct rconn *swconn, + const struct ovsrec_bridge *br_int) +{ + if (!rconn_is_connected(swconn)) { + char *target = xasprintf("unix:%s/%s.mgmt", ovs_rundir(), + br_int->name); + if (strcmp(target, rconn_get_target(swconn))) { + VLOG_INFO("%s: connecting to switch", target); + rconn_connect(swconn, target, target); + } + free(target); + } +} + +static void +ovn_controller_get_meter_capa(struct rconn *swconn) +{ + if (dp_meter_capa >= 0) { + return; + } + + rconn_run(swconn); + if (!rconn_is_connected(swconn)) { + return; + } + + /* dump datapath meter capabilities. */ + struct ofpbuf *msg = ofpraw_alloc(OFPRAW_OFPST13_METER_FEATURES_REQUEST, + rconn_get_version(swconn), 0); + rconn_send(swconn, msg, NULL); + for (int i = 0; i < 10; i++) { + msg = rconn_recv(swconn); + if (!msg) { + break; + } + + const struct ofp_header *oh = msg->data; + enum ofptype type; + ofptype_decode(&type, oh); + + if (type == OFPTYPE_METER_FEATURES_STATS_REPLY) { + struct ofputil_meter_features mf; + + ofputil_decode_meter_features(oh, &mf); + dp_meter_capa = mf.max_meters > 0; + engine_set_force_recompute(true); + } + ofpbuf_delete(msg); + } +} + int main(int argc, char *argv[]) { @@ -3445,6 +3503,8 @@ main(int argc, char *argv[]) char *ovn_version = ovn_get_internal_version(); VLOG_INFO("OVN internal version is : [%s]", ovn_version); + struct rconn *swconn = rconn_create(5, 0, DSCP_DEFAULT, + 1 << OFP15_VERSION); /* Main loop. */ exiting = false; restart = false; @@ -3523,6 +3583,10 @@ main(int argc, char *argv[]) ovsrec_server_has_datapath_table(ovs_idl_loop.idl) ? &br_int_dp : NULL); + if (br_int) { + ovn_controller_connect_vswitch(swconn, br_int); + } + ovn_controller_get_meter_capa(swconn); /* Enable ACL matching for double tagged traffic. */ if (ovs_idl_txn) { @@ -3898,6 +3962,7 @@ loop_done: ovsdb_idl_loop_destroy(&ovs_idl_loop); ovsdb_idl_loop_destroy(&ovnsb_idl_loop); + rconn_destroy(swconn); free(ovs_remote); service_stop(); diff --git a/controller/ovn-controller.h b/controller/ovn-controller.h index 78a53312f..0eda72724 100644 --- a/controller/ovn-controller.h +++ b/controller/ovn-controller.h @@ -22,6 +22,8 @@ struct ovsrec_bridge_table; +extern int dp_meter_capa; + /* Linux supports a maximum of 64K zones, which seems like a fine default. */ #define MAX_CT_ZONES 65535