From patchwork Thu Aug 11 14:19:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1665590 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=LFhSGSQK; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4M3TV822JHz9sG0 for ; Fri, 12 Aug 2022 00:20:16 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 4719341880; Thu, 11 Aug 2022 14:20:14 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 4719341880 Authentication-Results: smtp4.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=LFhSGSQK 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 exvHxDUzAX-y; Thu, 11 Aug 2022 14:20:12 +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 B732341837; Thu, 11 Aug 2022 14:20:11 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org B732341837 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6C030C0033; Thu, 11 Aug 2022 14:20:11 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6338CC002D for ; Thu, 11 Aug 2022 14:20:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 3DA3D4049A for ; Thu, 11 Aug 2022 14:20:09 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 3DA3D4049A Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LFhSGSQK X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id G47EbpBnRjfI for ; Thu, 11 Aug 2022 14:20:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 42D6240289 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 42D6240289 for ; Thu, 11 Aug 2022 14:20:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660227607; 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: in-reply-to:in-reply-to:references:references; bh=A0Hw5z5RdhqOcQ+JR5VsHtcCTddH/FbufYSNZPhzfGU=; b=LFhSGSQKtRZxpiUrd8Q0mLuHoGBlRsuLAyquhqMpXhSd8vXM4GN0eHO4YOgad5OGv5QuZC Lwy0W93HWfpzlqHfc2eE2/HxM3DIUx2/KV7cL3jkag1yG7fDnnOnDJeQgFP3VO1K5lKYOY 5U7jSI+TWKR9ADoeU4FvBIVAzgwlbjw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-544-wBltJQQqOoC7p60JRQMAyg-1; Thu, 11 Aug 2022 10:20:06 -0400 X-MC-Unique: wBltJQQqOoC7p60JRQMAyg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 91521811E87; Thu, 11 Aug 2022 14:20:05 +0000 (UTC) Received: from amusil.redhat.com (unknown [10.40.192.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6EA0E492C3B; Thu, 11 Aug 2022 14:20:04 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Thu, 11 Aug 2022 16:19:57 +0200 Message-Id: <20220811142001.106287-2-amusil@redhat.com> In-Reply-To: <20220811142001.106287-1-amusil@redhat.com> References: <20220811142001.106287-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: dceara@redhat.com Subject: [ovs-dev] [PATCH ovn v5 1/5] northd, controller: Add timestamp column to MAC_Binding table 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 new timestamp column in MAC_Binding is populated with current time whenever the row is created or the MAC address is updated. This can be utilized by MAC binding aging mechanism, when we can check if enough time has passed since the creation/update. Reported-at: https://bugzilla.redhat.com/2084668 Acked-By: Ihar Hrachyshka Acked-by: Dumitru Ceara Signed-off-by: Ales Musil Acked-by: Mark Michelson --- v4: Rebase on top of current main. Add ack from Ihar. v5: Rebase on top of current main. --- controller/pinctrl.c | 2 ++ northd/ovn-northd.c | 2 +- ovn-sb.ovsschema | 5 +++-- ovn-sb.xml | 6 ++++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/controller/pinctrl.c b/controller/pinctrl.c index e3ac829ce..eeb6f7527 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -4245,8 +4245,10 @@ mac_binding_add_to_sb(struct ovsdb_idl_txn *ovnsb_idl_txn, sbrec_mac_binding_set_ip(b, ip); sbrec_mac_binding_set_mac(b, mac_string); sbrec_mac_binding_set_datapath(b, dp); + sbrec_mac_binding_set_timestamp(b, time_wall_msec()); } else if (strcmp(b->mac, mac_string)) { sbrec_mac_binding_set_mac(b, mac_string); + sbrec_mac_binding_set_timestamp(b, time_wall_msec()); } } diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index ab28756af..bd35802ed 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -115,7 +115,7 @@ static const char *rbac_port_binding_update[] = static const char *rbac_mac_binding_auth[] = {""}; static const char *rbac_mac_binding_update[] = - {"logical_port", "ip", "mac", "datapath"}; + {"logical_port", "ip", "mac", "datapath", "timestamp"}; static const char *rbac_svc_monitor_auth[] = {""}; diff --git a/ovn-sb.ovsschema b/ovn-sb.ovsschema index 3b78ea6f6..bca552b5e 100644 --- a/ovn-sb.ovsschema +++ b/ovn-sb.ovsschema @@ -1,7 +1,7 @@ { "name": "OVN_Southbound", - "version": "20.23.0", - "cksum": "4045988377 28575", + "version": "20.24.0", + "cksum": "4165157445 28634", "tables": { "SB_Global": { "columns": { @@ -260,6 +260,7 @@ "logical_port": {"type": "string"}, "ip": {"type": "string"}, "mac": {"type": "string"}, + "timestamp": {"type": {"key": "integer"}}, "datapath": {"type": {"key": {"type": "uuid", "refTable": "Datapath_Binding"}}}}, "indexes": [["logical_port", "ip"]], diff --git a/ovn-sb.xml b/ovn-sb.xml index 59ad3aa2d..c5e6c9cc1 100644 --- a/ovn-sb.xml +++ b/ovn-sb.xml @@ -3621,6 +3621,12 @@ tcp.flags = RST; The Ethernet address to which the IP is bound. + + + The timestamp in msec when the MAC binding was added or updated. + Records that existed before this column will have 0. + + The logical datapath to which the logical port belongs. From patchwork Thu Aug 11 14:19:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1665592 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=CeWIUEmL; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4M3TVH49ptz9sG0 for ; Fri, 12 Aug 2022 00:20:23 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 4CC82610FB; Thu, 11 Aug 2022 14:20:19 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 4CC82610FB 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=CeWIUEmL X-Virus-Scanned: amavisd-new at osuosl.org 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 MSEcEIA2kqHt; Thu, 11 Aug 2022 14:20:17 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 4024961101; Thu, 11 Aug 2022 14:20:16 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 4024961101 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 08477C0083; Thu, 11 Aug 2022 14:20:14 +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 0A046C002D for ; Thu, 11 Aug 2022 14:20:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id B82A68144E for ; Thu, 11 Aug 2022 14:20:10 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org B82A68144E 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=CeWIUEmL X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xDWeJT9I4h_L for ; Thu, 11 Aug 2022 14:20:09 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org A9FBF830FB 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 A9FBF830FB for ; Thu, 11 Aug 2022 14:20:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660227608; 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: in-reply-to:in-reply-to:references:references; bh=3L7DjKWxKRH4plqJZnCy523Hsl0Ps5VOsqhKONegip0=; b=CeWIUEmLz3VN/ENQ20JJ8RmEW931mPf6QCfJbmBwyf6ozXI/HC4KoW7kNzDpPQxyTNEDKN mkrVZ/jf5OrA+aIcmMQzlLMMps4voDn1ZNHSLfJ+JI0MZ7X4YDL489GR2s4TZrPOJfhteM mxBJi0b8nl9tahmQu7PdUwfXkHz9zGs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-450-bpuwrOBJPNaRk0b4CRr_MA-1; Thu, 11 Aug 2022 10:20:07 -0400 X-MC-Unique: bpuwrOBJPNaRk0b4CRr_MA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 522F880A0B9; Thu, 11 Aug 2022 14:20:07 +0000 (UTC) Received: from amusil.redhat.com (unknown [10.40.192.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id F19C1492C3B; Thu, 11 Aug 2022 14:20:05 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Thu, 11 Aug 2022 16:19:58 +0200 Message-Id: <20220811142001.106287-3-amusil@redhat.com> In-Reply-To: <20220811142001.106287-1-amusil@redhat.com> References: <20220811142001.106287-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: dceara@redhat.com Subject: [ovs-dev] [PATCH ovn v5 2/5] controller: Add mac-binding-index.c/.h files 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" Add helper source file for creating index over MAC binding table. Reported-at: https://bugzilla.redhat.com/2084668 Acked-by: Dumitru Ceara Signed-off-by: Ales Musil Acked-by: Mark Michelson --- v4: Rebase on top of current main. Address comment from Mark. Add ack from Ihar. v5: Rebase on top of current main. Address comments from Dumitru. --- controller/ovn-controller.c | 8 +++----- lib/automake.mk | 2 ++ lib/mac-binding-index.c | 33 +++++++++++++++++++++++++++++++++ lib/mac-binding-index.h | 26 ++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 lib/mac-binding-index.c create mode 100644 lib/mac-binding-index.h diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 8268726e6..6850bc7fb 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -53,6 +53,7 @@ #include "lib/chassis-index.h" #include "lib/extend-table.h" #include "lib/ip-mcast-index.h" +#include "lib/mac-binding-index.h" #include "lib/mcast-group-index.h" #include "lib/ovn-sb-idl.h" #include "lib/ovn-util.h" @@ -3496,9 +3497,7 @@ main(int argc, char *argv[]) = ovsdb_idl_index_create1(ovnsb_idl_loop.idl, &sbrec_datapath_binding_col_tunnel_key); struct ovsdb_idl_index *sbrec_mac_binding_by_lport_ip - = ovsdb_idl_index_create2(ovnsb_idl_loop.idl, - &sbrec_mac_binding_col_logical_port, - &sbrec_mac_binding_col_ip); + = mac_binding_by_lport_ip_index_create(ovnsb_idl_loop.idl); struct ovsdb_idl_index *sbrec_ip_multicast = ip_mcast_index_create(ovnsb_idl_loop.idl); struct ovsdb_idl_index *sbrec_igmp_group @@ -3511,8 +3510,7 @@ main(int argc, char *argv[]) &sbrec_fdb_col_mac, &sbrec_fdb_col_dp_key); struct ovsdb_idl_index *sbrec_mac_binding_by_datapath - = ovsdb_idl_index_create1(ovnsb_idl_loop.idl, - &sbrec_mac_binding_col_datapath); + = mac_binding_by_datapath_index_create(ovnsb_idl_loop.idl); struct ovsdb_idl_index *sbrec_static_mac_binding_by_datapath = ovsdb_idl_index_create1(ovnsb_idl_loop.idl, &sbrec_static_mac_binding_col_datapath); diff --git a/lib/automake.mk b/lib/automake.mk index 3a2da1fe4..60bead6a6 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -26,6 +26,8 @@ lib_libovn_la_SOURCES = \ lib/ovn-parallel-hmap.c \ lib/ip-mcast-index.c \ lib/ip-mcast-index.h \ + lib/mac-binding-index.c \ + lib/mac-binding-index.h \ lib/mcast-group-index.c \ lib/mcast-group-index.h \ lib/lex.c \ diff --git a/lib/mac-binding-index.c b/lib/mac-binding-index.c new file mode 100644 index 000000000..d774f12d0 --- /dev/null +++ b/lib/mac-binding-index.c @@ -0,0 +1,33 @@ +/* Copyright (c) 2022, Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "lib/mac-binding-index.h" +#include "lib/ovn-sb-idl.h" + +struct ovsdb_idl_index * +mac_binding_by_datapath_index_create(struct ovsdb_idl *idl) +{ + return ovsdb_idl_index_create1(idl, &sbrec_mac_binding_col_datapath); +} + +struct ovsdb_idl_index * +mac_binding_by_lport_ip_index_create(struct ovsdb_idl *idl) +{ + return ovsdb_idl_index_create2(idl, + &sbrec_mac_binding_col_logical_port, + &sbrec_mac_binding_col_ip); +} diff --git a/lib/mac-binding-index.h b/lib/mac-binding-index.h new file mode 100644 index 000000000..8e977ecea --- /dev/null +++ b/lib/mac-binding-index.h @@ -0,0 +1,26 @@ +/* Copyright (c) 2022, Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OVN_MAC_BINDING_INDEX_H +#define OVN_MAC_BINDING_INDEX_H 1 + +#include "lib/ovn-sb-idl.h" + +struct ovsdb_idl_index *mac_binding_by_datapath_index_create( + struct ovsdb_idl *idl); +struct ovsdb_idl_index *mac_binding_by_lport_ip_index_create( + struct ovsdb_idl *idl); + +#endif /* lib/mac-binding-index.h */ From patchwork Thu Aug 11 14:19:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1665593 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=hYLnOXbH; 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 (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4M3TVL07W8z9sG0 for ; Fri, 12 Aug 2022 00:20:25 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 05F984188D; Thu, 11 Aug 2022 14:20:23 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 05F984188D Authentication-Results: smtp4.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=hYLnOXbH 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 QnmVTndyp0Sp; Thu, 11 Aug 2022 14:20:20 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 267AC4187D; Thu, 11 Aug 2022 14:20:18 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 267AC4187D Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 55742C0089; Thu, 11 Aug 2022 14:20:16 +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 63DA6C0081 for ; Thu, 11 Aug 2022 14:20:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id CF89F83104 for ; Thu, 11 Aug 2022 14:20:12 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org CF89F83104 Authentication-Results: smtp1.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=hYLnOXbH X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EvmTVld_XlTK for ; Thu, 11 Aug 2022 14:20:11 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 84AEB830FB 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 84AEB830FB for ; Thu, 11 Aug 2022 14:20:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660227610; 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: in-reply-to:in-reply-to:references:references; bh=FtGQgj9C1N/ro5FQR55VtOyMekUAlJZeSw4/GVFx8D0=; b=hYLnOXbHc8D1xXQuI0p6x9Mp57y31/kJGTxM1xTpEllvAPUwtJszU3PO52mwUS9m17507l DMhxWUEV53iWAtOZ4kGvsH0mS0s/ieTpIolCJkeV11QOesv6LTU8j1FDeAyF58epWNze4P E5JDsEcx92vmMi+Tc8iz8d0jM47DEyc= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-474-z5MKw_AmMgi4ijV1bOHoZQ-1; Thu, 11 Aug 2022 10:20:09 -0400 X-MC-Unique: z5MKw_AmMgi4ijV1bOHoZQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B11273C025AC; Thu, 11 Aug 2022 14:20:08 +0000 (UTC) Received: from amusil.redhat.com (unknown [10.40.192.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id 993DD492C3B; Thu, 11 Aug 2022 14:20:07 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Thu, 11 Aug 2022 16:19:59 +0200 Message-Id: <20220811142001.106287-4-amusil@redhat.com> In-Reply-To: <20220811142001.106287-1-amusil@redhat.com> References: <20220811142001.106287-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: dceara@redhat.com Subject: [ovs-dev] [PATCH ovn v5 3/5] northd: Move struct ovn_datapath and related structs to northd.h 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 struct ovn_datapath could not be used outside the northd.c move it to northd.h that it can be used by other .c files later on. Reported-at: https://bugzilla.redhat.com/2084668 Acked-by: Dumitru Ceara Signed-off-by: Ales Musil Acked-by: Mark Michelson --- v4: Rebase on top of current main. Add ack from Ihar. v5: Rebase on top of current main. Address comment from Dumitru. --- northd/northd.c | 154 ---------------------------------------------- northd/northd.h | 158 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 158 insertions(+), 154 deletions(-) diff --git a/northd/northd.c b/northd/northd.c index facd41a59..330c03d63 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -514,74 +514,6 @@ port_has_qos_params(const struct smap *opts) } -/* - * Multicast snooping and querier per datapath configuration. - */ -struct mcast_switch_info { - - bool enabled; /* True if snooping enabled. */ - bool querier; /* True if querier enabled. */ - bool flood_unregistered; /* True if unregistered multicast should be - * flooded. - */ - bool flood_relay; /* True if the switch is connected to a - * multicast router and unregistered multicast - * should be flooded to the mrouter. Only - * applicable if flood_unregistered == false. - */ - bool flood_reports; /* True if the switch has at least one port - * configured to flood reports. - */ - bool flood_static; /* True if the switch has at least one port - * configured to flood traffic. - */ - int64_t table_size; /* Max number of IP multicast groups. */ - int64_t idle_timeout; /* Timeout after which an idle group is - * flushed. - */ - int64_t query_interval; /* Interval between multicast queries. */ - char *eth_src; /* ETH src address of the queries. */ - char *ipv4_src; /* IPv4 src address of the queries. */ - char *ipv6_src; /* IPv6 src address of the queries. */ - - int64_t query_max_response; /* Expected time after which reports should - * be received for queries that were sent out. - */ - - atomic_uint64_t active_v4_flows; /* Current number of active IPv4 multicast - * flows. - */ - atomic_uint64_t active_v6_flows; /* Current number of active IPv6 multicast - * flows. - */ -}; - -struct mcast_router_info { - bool relay; /* True if the router should relay IP multicast. */ - bool flood_static; /* True if the router has at least one port configured - * to flood traffic. - */ -}; - -struct mcast_info { - - struct hmap group_tnlids; /* Group tunnel IDs in use on this DP. */ - uint32_t group_tnlid_hint; /* Hint for allocating next group tunnel ID. */ - struct ovs_list groups; /* List of groups learnt on this DP. */ - - union { - struct mcast_switch_info sw; /* Switch specific multicast info. */ - struct mcast_router_info rtr; /* Router specific multicast info. */ - }; -}; - -struct mcast_port_info { - bool flood; /* True if the port should flood IP multicast traffic - * regardless if it's registered or not. */ - bool flood_reports; /* True if the port should flood IP multicast reports - * (e.g., IGMP join/leave). */ -}; - static void init_mcast_port_info(struct mcast_port_info *mcast_info, const struct nbrec_logical_switch_port *nbsp, @@ -611,92 +543,6 @@ ovn_mcast_group_allocate_key(struct mcast_info *mcast_info) &mcast_info->group_tnlid_hint); } -/* The 'key' comes from nbs->header_.uuid or nbr->header_.uuid or - * sb->external_ids:logical-switch. */ -struct ovn_datapath { - struct hmap_node key_node; /* Index on 'key'. */ - struct uuid key; /* (nbs/nbr)->header_.uuid. */ - - const struct nbrec_logical_switch *nbs; /* May be NULL. */ - const struct nbrec_logical_router *nbr; /* May be NULL. */ - const struct sbrec_datapath_binding *sb; /* May be NULL. */ - - struct ovs_list list; /* In list of similar records. */ - - uint32_t tunnel_key; - - /* Logical switch data. */ - struct ovn_port **router_ports; - size_t n_router_ports; - size_t n_allocated_router_ports; - - struct hmap port_tnlids; - uint32_t port_key_hint; - - bool has_stateful_acl; - bool has_lb_vip; - bool has_unknown; - bool has_acls; - - /* IPAM data. */ - struct ipam_info ipam_info; - - /* Multicast data. */ - struct mcast_info mcast_info; - - /* Applies to only logical router datapath. - * True if logical router is a gateway router. i.e options:chassis is set. - * If this is true, then 'l3dgw_ports' will be ignored. */ - bool is_gw_router; - - /* OVN northd only needs to know about logical router gateway ports for - * NAT/LB on a distributed router. The "distributed gateway ports" are - * populated only when there is a gateway chassis or ha chassis group - * specified for some of the ports on the logical router. Otherwise this - * will be NULL. */ - struct ovn_port **l3dgw_ports; - size_t n_l3dgw_ports; - - /* NAT entries configured on the router. */ - struct ovn_nat *nat_entries; - size_t n_nat_entries; - - bool has_distributed_nat; - - /* Set of nat external ips on the router. */ - struct sset external_ips; - - /* SNAT IPs owned by the router (shash of 'struct ovn_snat_ip'). */ - struct shash snat_ips; - - struct lport_addresses dnat_force_snat_addrs; - struct lport_addresses lb_force_snat_addrs; - bool lb_force_snat_router_ip; - /* The "routable" ssets are subsets of the load balancer - * IPs for which IP routes and ARP resolution flows are automatically - * added - */ - struct sset lb_ips_v4; - struct sset lb_ips_v4_routable; - struct sset lb_ips_v4_reachable; - struct sset lb_ips_v6; - struct sset lb_ips_v6_routable; - struct sset lb_ips_v6_reachable; - - struct ovn_port **localnet_ports; - size_t n_localnet_ports; - - struct ovs_list lr_list; /* In list of logical router datapaths. */ - /* The logical router group to which this datapath belongs. - * Valid only if it is logical router datapath. NULL otherwise. */ - struct lrouter_group *lr_group; - - /* Port groups related to the datapath, used only when nbs is NOT NULL. */ - struct hmap nb_pgs; - - struct ovs_list port_list; -}; - /* Contains a NAT entry with the external addresses pre-parsed. */ struct ovn_nat { const struct nbrec_nat *nb; diff --git a/northd/northd.h b/northd/northd.h index 677b35877..2fa1d1221 100644 --- a/northd/northd.h +++ b/northd/northd.h @@ -16,6 +16,10 @@ #include "ovsdb-idl.h" +#include "lib/ovn-util.h" +#include "lib/ovs-atomic.h" +#include "lib/sset.h" +#include "northd/ipam.h" #include "openvswitch/hmap.h" struct northd_input { @@ -98,6 +102,160 @@ struct lflow_input { bool ovn_internal_version_changed; }; +/* + * Multicast snooping and querier per datapath configuration. + */ +struct mcast_switch_info { + + bool enabled; /* True if snooping enabled. */ + bool querier; /* True if querier enabled. */ + bool flood_unregistered; /* True if unregistered multicast should be + * flooded. + */ + bool flood_relay; /* True if the switch is connected to a + * multicast router and unregistered multicast + * should be flooded to the mrouter. Only + * applicable if flood_unregistered == false. + */ + bool flood_reports; /* True if the switch has at least one port + * configured to flood reports. + */ + bool flood_static; /* True if the switch has at least one port + * configured to flood traffic. + */ + int64_t table_size; /* Max number of IP multicast groups. */ + int64_t idle_timeout; /* Timeout after which an idle group is + * flushed. + */ + int64_t query_interval; /* Interval between multicast queries. */ + char *eth_src; /* ETH src address of the queries. */ + char *ipv4_src; /* IPv4 src address of the queries. */ + char *ipv6_src; /* IPv6 src address of the queries. */ + + int64_t query_max_response; /* Expected time after which reports should + * be received for queries that were sent out. + */ + + atomic_uint64_t active_v4_flows; /* Current number of active IPv4 + * multicast flows. + */ + atomic_uint64_t active_v6_flows; /* Current number of active IPv6 + * multicast flows. + */ +}; + +struct mcast_router_info { + bool relay; /* True if the router should relay IP multicast. */ + bool flood_static; /* True if the router has at least one port configured + * to flood traffic. + */ +}; + +struct mcast_info { + + struct hmap group_tnlids; /* Group tunnel IDs in use on this DP. */ + uint32_t group_tnlid_hint; /* Hint for allocating next group tunnel ID. */ + struct ovs_list groups; /* List of groups learnt on this DP. */ + + union { + struct mcast_switch_info sw; /* Switch specific multicast info. */ + struct mcast_router_info rtr; /* Router specific multicast info. */ + }; +}; + +struct mcast_port_info { + bool flood; /* True if the port should flood IP multicast traffic + * regardless if it's registered or not. */ + bool flood_reports; /* True if the port should flood IP multicast reports + * (e.g., IGMP join/leave). */ +}; + +/* The 'key' comes from nbs->header_.uuid or nbr->header_.uuid or + * sb->external_ids:logical-switch. */ +struct ovn_datapath { + struct hmap_node key_node; /* Index on 'key'. */ + struct uuid key; /* (nbs/nbr)->header_.uuid. */ + + const struct nbrec_logical_switch *nbs; /* May be NULL. */ + const struct nbrec_logical_router *nbr; /* May be NULL. */ + const struct sbrec_datapath_binding *sb; /* May be NULL. */ + + struct ovs_list list; /* In list of similar records. */ + + uint32_t tunnel_key; + + /* Logical switch data. */ + struct ovn_port **router_ports; + size_t n_router_ports; + size_t n_allocated_router_ports; + + struct hmap port_tnlids; + uint32_t port_key_hint; + + bool has_stateful_acl; + bool has_lb_vip; + bool has_unknown; + bool has_acls; + + /* IPAM data. */ + struct ipam_info ipam_info; + + /* Multicast data. */ + struct mcast_info mcast_info; + + /* Applies to only logical router datapath. + * True if logical router is a gateway router. i.e options:chassis is set. + * If this is true, then 'l3dgw_ports' will be ignored. */ + bool is_gw_router; + + /* OVN northd only needs to know about logical router gateway ports for + * NAT/LB on a distributed router. The "distributed gateway ports" are + * populated only when there is a gateway chassis or ha chassis group + * specified for some of the ports on the logical router. Otherwise this + * will be NULL. */ + struct ovn_port **l3dgw_ports; + size_t n_l3dgw_ports; + + /* NAT entries configured on the router. */ + struct ovn_nat *nat_entries; + size_t n_nat_entries; + + bool has_distributed_nat; + + /* Set of nat external ips on the router. */ + struct sset external_ips; + + /* SNAT IPs owned by the router (shash of 'struct ovn_snat_ip'). */ + struct shash snat_ips; + + struct lport_addresses dnat_force_snat_addrs; + struct lport_addresses lb_force_snat_addrs; + bool lb_force_snat_router_ip; + /* The "routable" ssets are subsets of the load balancer + * IPs for which IP routes and ARP resolution flows are automatically + * added + */ + struct sset lb_ips_v4; + struct sset lb_ips_v4_routable; + struct sset lb_ips_v4_reachable; + struct sset lb_ips_v6; + struct sset lb_ips_v6_routable; + struct sset lb_ips_v6_reachable; + + struct ovn_port **localnet_ports; + size_t n_localnet_ports; + + struct ovs_list lr_list; /* In list of logical router datapaths. */ + /* The logical router group to which this datapath belongs. + * Valid only if it is logical router datapath. NULL otherwise. */ + struct lrouter_group *lr_group; + + /* Port groups related to the datapath, used only when nbs is NOT NULL. */ + struct hmap nb_pgs; + + struct ovs_list port_list; +}; + void northd_run(struct northd_input *input_data, struct northd_data *data, struct ovsdb_idl_txn *ovnnb_txn, From patchwork Thu Aug 11 14:20:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1665594 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=MPy1GyRk; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4M3TVM0kNGz9sG0 for ; Fri, 12 Aug 2022 00:20:27 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id E906A40DC2; Thu, 11 Aug 2022 14:20:24 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org E906A40DC2 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=MPy1GyRk X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 87ZGor6Z8tZd; Thu, 11 Aug 2022 14:20:21 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id D3F2840CC9; Thu, 11 Aug 2022 14:20:19 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org D3F2840CC9 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5670AC007F; Thu, 11 Aug 2022 14:20:18 +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 8B491C0080 for ; Thu, 11 Aug 2022 14:20:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 4B96983131 for ; Thu, 11 Aug 2022 14:20:16 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 4B96983131 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=MPy1GyRk X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 35fwsFUD1Itf for ; Thu, 11 Aug 2022 14:20:15 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org AACA283123 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 AACA283123 for ; Thu, 11 Aug 2022 14:20:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660227613; 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: in-reply-to:in-reply-to:references:references; bh=53XLs5z9HrLTAgIZlUo9JVxKcSYXP3XsRLlAwyXy5rA=; b=MPy1GyRkjZWFjVg0Qd1wo2JgyDKiO6THE9maQLp1t5RqoqnxCpjfYXPcVm1RNixnlnQbhL gF9gWybXINl+kAxjO1rUjypPy6/a8gFnsdlm22AJON+meWiQ2Gaeaav3aF13N744gg6cpD C/hCisL9m49FkShIgW16LVOAtIrCUfs= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-44-xtCF4jssP5u9BCY1vE_CKw-1; Thu, 11 Aug 2022 10:20:10 -0400 X-MC-Unique: xtCF4jssP5u9BCY1vE_CKw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 56F4029ABA07; Thu, 11 Aug 2022 14:20:10 +0000 (UTC) Received: from amusil.redhat.com (unknown [10.40.192.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC952492C3B; Thu, 11 Aug 2022 14:20:08 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Thu, 11 Aug 2022 16:20:00 +0200 Message-Id: <20220811142001.106287-5-amusil@redhat.com> In-Reply-To: <20220811142001.106287-1-amusil@redhat.com> References: <20220811142001.106287-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: dceara@redhat.com Subject: [ovs-dev] [PATCH ovn v5 4/5] northd: Add MAC binding aging mechanism 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" Add MAC binding aging mechanism, that utilizes the timestamp column of MAC_Binding table. When the MAC binding exceeds the threshold it is removed from SB DB, this is postponed only in case we receive update ARP with update to MAC address. The threshold is configurable via option "mac_binding_age_threshold" that can be specified for each logical router. The option is defaulting to 0 which means that by default the aging is disabled and the MAC binding rows will be persisted the same way as before. Reported-at: https://bugzilla.redhat.com/2084668 Signed-off-by: Ales Musil Acked-by: Mark Michelson --- v4: Rebase on top of current main. Skip one row instead of all if time elapsed is negative. Add note to NEWS. v5: Rebase on top of current main. Address comments from Han, Numan and Dumitru. --- NEWS | 3 + northd/automake.mk | 2 + northd/inc-proc-northd.c | 15 ++++ northd/mac-binding-aging.c | 161 +++++++++++++++++++++++++++++++++++++ northd/mac-binding-aging.h | 33 ++++++++ ovn-nb.xml | 7 ++ tests/ovn.at | 111 +++++++++++++++++++++++++ 7 files changed, 332 insertions(+) create mode 100644 northd/mac-binding-aging.c create mode 100644 northd/mac-binding-aging.h diff --git a/NEWS b/NEWS index 20cea579e..eff8e472a 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,9 @@ Post v22.06.0 NAT-T UDP encapsulation. Requires OVS support for IPsec custom tunnel options (which will be available in OVS 2.18). - Removed possibility of disabling logical datapath groups. + - Added MAC binding aging mechanism, that is disabled by default. + It can be enabled per logical router with option + "mac_binding_age_threshold". OVN v22.06.0 - 03 Jun 2022 -------------------------- diff --git a/northd/automake.mk b/northd/automake.mk index 4862ec7b7..81582867d 100644 --- a/northd/automake.mk +++ b/northd/automake.mk @@ -1,6 +1,8 @@ # ovn-northd bin_PROGRAMS += northd/ovn-northd northd_ovn_northd_SOURCES = \ + northd/mac-binding-aging.c \ + northd/mac-binding-aging.h \ northd/northd.c \ northd/northd.h \ northd/ovn-northd.c \ diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c index 43093cb5a..fc0d9e670 100644 --- a/northd/inc-proc-northd.c +++ b/northd/inc-proc-northd.c @@ -22,9 +22,11 @@ #include "ip-mcast-index.h" #include "static-mac-binding-index.h" #include "lib/inc-proc-eng.h" +#include "lib/mac-binding-index.h" #include "lib/ovn-nb-idl.h" #include "lib/ovn-sb-idl.h" #include "mcast-group-index.h" +#include "northd/mac-binding-aging.h" #include "openvswitch/poll-loop.h" #include "openvswitch/vlog.h" #include "inc-proc-northd.h" @@ -149,6 +151,8 @@ enum sb_engine_node { * avoid sparse errors. */ static ENGINE_NODE(northd, "northd"); static ENGINE_NODE(lflow, "lflow"); +static ENGINE_NODE(mac_binding_aging, "mac_binding_aging"); +static ENGINE_NODE(mac_binding_aging_waker, "mac_binding_aging_waker"); void inc_proc_northd_init(struct ovsdb_idl_loop *nb, struct ovsdb_idl_loop *sb) @@ -211,12 +215,18 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, engine_add_input(&en_northd, &en_sb_load_balancer, NULL); engine_add_input(&en_northd, &en_sb_fdb, NULL); engine_add_input(&en_northd, &en_sb_static_mac_binding, NULL); + engine_add_input(&en_mac_binding_aging, &en_sb_mac_binding, NULL); + engine_add_input(&en_mac_binding_aging, &en_northd, NULL); + engine_add_input(&en_mac_binding_aging, &en_mac_binding_aging_waker, NULL); engine_add_input(&en_lflow, &en_nb_bfd, NULL); engine_add_input(&en_lflow, &en_sb_bfd, NULL); engine_add_input(&en_lflow, &en_sb_logical_flow, NULL); engine_add_input(&en_lflow, &en_sb_multicast_group, NULL); engine_add_input(&en_lflow, &en_sb_igmp_group, NULL); engine_add_input(&en_lflow, &en_northd, NULL); + /* XXX: The "en_mac_binding_aging" should be separate "root" node + * once I-P engine allows multiple root nodes. */ + engine_add_input(&en_lflow, &en_mac_binding_aging, NULL); struct engine_arg engine_arg = { .nb_idl = nb->idl, @@ -235,6 +245,8 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, chassis_hostname_index_create(sb->idl); struct ovsdb_idl_index *sbrec_static_mac_binding_by_lport_ip = static_mac_binding_index_create(sb->idl); + struct ovsdb_idl_index *sbrec_mac_binding_by_datapath + = mac_binding_by_datapath_index_create(sb->idl); engine_init(&en_lflow, &engine_arg); @@ -256,6 +268,9 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, engine_ovsdb_node_add_index(&en_sb_static_mac_binding, "sbrec_static_mac_binding_by_lport_ip", sbrec_static_mac_binding_by_lport_ip); + engine_ovsdb_node_add_index(&en_sb_mac_binding, + "sbrec_mac_binding_by_datapath", + sbrec_mac_binding_by_datapath); } void inc_proc_northd_run(struct ovsdb_idl_txn *ovnnb_txn, diff --git a/northd/mac-binding-aging.c b/northd/mac-binding-aging.c new file mode 100644 index 000000000..3859c050b --- /dev/null +++ b/northd/mac-binding-aging.c @@ -0,0 +1,161 @@ +/* Copyright (c) 2022, Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "lib/inc-proc-eng.h" +#include "lib/ovn-nb-idl.h" +#include "lib/ovn-sb-idl.h" +#include "lib/timeval.h" +#include "northd/mac-binding-aging.h" +#include "northd/northd.h" +#include "openvswitch/hmap.h" +#include "openvswitch/poll-loop.h" +#include "openvswitch/util.h" +#include "openvswitch/vlog.h" + +VLOG_DEFINE_THIS_MODULE(mac_binding_aging); + +struct mac_binding_waker { + bool should_schedule; + long long next_wake_msec; +}; + +static void +mac_binding_aging_run_for_datapath(const struct sbrec_datapath_binding *dp, + const struct nbrec_logical_router *nbr, + struct ovsdb_idl_index *mb_by_datapath, + int64_t now, int64_t *wake_delay) +{ + uint64_t threshold = smap_get_uint(&nbr->options, + "mac_binding_age_threshold", + 0) * 1000; + if (!threshold) { + return; + } + + struct sbrec_mac_binding *mb_index_row = + sbrec_mac_binding_index_init_row(mb_by_datapath); + sbrec_mac_binding_index_set_datapath(mb_index_row, dp); + + const struct sbrec_mac_binding *mb; + SBREC_MAC_BINDING_FOR_EACH_EQUAL (mb, mb_index_row, mb_by_datapath) { + int64_t elapsed = now - mb->timestamp; + + if (elapsed < 0) { + continue; + } else if (elapsed >= threshold) { + sbrec_mac_binding_delete(mb); + } else { + *wake_delay = MIN(*wake_delay, threshold - elapsed); + } + } + sbrec_mac_binding_index_destroy_row(mb_index_row); +} + +void +en_mac_binding_aging_run(struct engine_node *node, void *data OVS_UNUSED) +{ + const struct engine_context *eng_ctx = engine_get_context(); + + if (!eng_ctx->ovnsb_idl_txn) { + return; + } + + int64_t next_expire_msec = INT64_MAX; + int64_t now = time_wall_msec(); + struct northd_data *northd_data = engine_get_input_data("northd", node); + struct mac_binding_waker *waker = + engine_get_input_data("mac_binding_aging_waker", node); + struct ovsdb_idl_index *sbrec_mac_binding_by_datapath = + engine_ovsdb_node_get_index(engine_get_input("SB_mac_binding", node), + "sbrec_mac_binding_by_datapath"); + + struct ovn_datapath *od; + HMAP_FOR_EACH (od, key_node, &northd_data->datapaths) { + if (od->sb && od->nbr) { + mac_binding_aging_run_for_datapath(od->sb, od->nbr, + sbrec_mac_binding_by_datapath, + now, &next_expire_msec); + } + } + + if (next_expire_msec < INT64_MAX) { + waker->should_schedule = true; + waker->next_wake_msec = time_msec() + next_expire_msec; + poll_timer_wait_until(waker->next_wake_msec); + } else { + waker->should_schedule = false; + } + + /* This node is part of lflow, but lflow does not depend on it. Setting + * state as unchanged does not trigger lflow node when it is not needed. */ + engine_set_node_state(node, EN_UNCHANGED); +} + +void * +en_mac_binding_aging_init(struct engine_node *node OVS_UNUSED, + struct engine_arg *arg OVS_UNUSED) +{ + return NULL; +} + +void +en_mac_binding_aging_cleanup(void *data OVS_UNUSED) +{ +} + +/* The waker node is an input node, but the data about when to wake up + * the aging node are populated by the aging node. + * The reason being that engine periodically runs input nodes to check + * if we there are updates, so it could process the other nodes, however + * the waker cannot be dependent on other node because it wouldn't be + * input node anymore. */ +void +en_mac_binding_aging_waker_run(struct engine_node *node, void *data) +{ + struct mac_binding_waker *waker = data; + + engine_set_node_state(node, EN_UNCHANGED); + + if (!waker->should_schedule) { + return; + } + + if (time_msec() >= waker->next_wake_msec) { + waker->should_schedule = false; + engine_set_node_state(node, EN_UPDATED); + return; + } + + poll_timer_wait_until(waker->next_wake_msec); +} + +void * +en_mac_binding_aging_waker_init(struct engine_node *node OVS_UNUSED, + struct engine_arg *arg OVS_UNUSED) +{ + struct mac_binding_waker *waker = xmalloc(sizeof *waker); + + waker->should_schedule = false; + waker->next_wake_msec = 0; + + return waker; +} + +void +en_mac_binding_aging_waker_cleanup(void *data OVS_UNUSED) +{ +} diff --git a/northd/mac-binding-aging.h b/northd/mac-binding-aging.h new file mode 100644 index 000000000..296a7ab38 --- /dev/null +++ b/northd/mac-binding-aging.h @@ -0,0 +1,33 @@ +/* Copyright (c) 2022, Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MAC_BINDING_AGING_H +#define MAC_BINDING_AGING_H 1 + +#include "lib/inc-proc-eng.h" + +/* The MAC binding aging node functions. */ +void en_mac_binding_aging_run(struct engine_node *node, void *data); +void *en_mac_binding_aging_init(struct engine_node *node, + struct engine_arg *arg); +void en_mac_binding_aging_cleanup(void *data); + +/* The MAC binding aging waker node functions. */ +void en_mac_binding_aging_waker_run(struct engine_node *node, void *data); +void *en_mac_binding_aging_waker_init(struct engine_node *node, + struct engine_arg *arg); +void en_mac_binding_aging_waker_cleanup(void *data); + +#endif /* northd/mac-binding-aging.h */ diff --git a/ovn-nb.xml b/ovn-nb.xml index e26afd83c..57c7d6174 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -2392,6 +2392,13 @@ and other sources. This way, OVN and the other sources can make use of the same conntrack zone. + + + MAC binding aging threshold value in seconds. MAC binding + exceeding this timeout will be automatically removed. The value + defaults to 0, which means disabled. + diff --git a/tests/ovn.at b/tests/ovn.at index c8cc8cde4..11094eff5 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -32404,3 +32404,114 @@ AT_CHECK([test $(ovn-sbctl list fdb | grep -c "00:00:00:00:10:30") = 0]) OVN_CLEANUP([hv1]) AT_CLEANUP ]) + +OVN_FOR_EACH_NORTHD([ +AT_SETUP([MAC binding aging]) +ovn_start + +net_add n1 + +AT_CHECK([ovn-nbctl ls-add public]) +AT_CHECK([ovn-nbctl ls-add internal]) + +AT_CHECK([ovn-nbctl lsp-add public ln_port]) +AT_CHECK([ovn-nbctl lsp-set-addresses ln_port unknown]) +AT_CHECK([ovn-nbctl lsp-set-type ln_port localnet]) +AT_CHECK([ovn-nbctl lsp-set-options ln_port network_name=physnet1]) + +AT_CHECK([ovn-nbctl lsp-add public public-gw]) +AT_CHECK([ovn-nbctl lsp-set-type public-gw router]) +AT_CHECK([ovn-nbctl lsp-set-addresses public-gw 00:00:00:00:10:00 router]) +AT_CHECK([ovn-nbctl lsp-set-options public-gw router-port=gw-public]) + +AT_CHECK([ovn-nbctl lsp-add internal internal-gw]) +AT_CHECK([ovn-nbctl lsp-set-type internal-gw router]) +AT_CHECK([ovn-nbctl lsp-set-addresses internal-gw 00:00:00:00:20:00 router]) +AT_CHECK([ovn-nbctl lsp-set-options internal-gw router-port=gw-internal]) + +AT_CHECK([ovn-nbctl lsp-add internal vif1]) +AT_CHECK([ovn-nbctl lsp-set-addresses vif1 "00:00:00:00:20:10 192.168.20.10"]) + +AT_CHECK([ovn-nbctl lsp-add internal vif2]) +AT_CHECK([ovn-nbctl lsp-set-addresses vif2 "00:00:00:00:20:20 192.168.20.20"]) + +AT_CHECK([ovn-nbctl lr-add gw]) +AT_CHECK([ovn-nbctl lrp-add gw gw-public 00:00:00:00:10:00 192.168.10.1/24]) +AT_CHECK([ovn-nbctl lrp-add gw gw-internal 00:00:00:00:20:00 192.168.20.1/24]) + +sim_add hv1 +as hv1 +ovs-vsctl add-br br-underlay +ovn_attach n1 br-underlay 192.168.0.1 +ovs-vsctl add-br br-phys +ovs-vsctl -- add-port br-int vif1 -- \ + set interface vif1 external-ids:iface-id=vif1 \ + options:tx_pcap=hv1/vif1-tx.pcap \ + options:rxq_pcap=hv1/vif1-rx.pcap \ + ofport-request=1 +ovs-vsctl -- add-port br-phys ext1 -- \ + set interface ext1 \ + options:tx_pcap=hv1/ext1-tx.pcap \ + options:rxq_pcap=hv1/ext1-rx.pcap \ + ofport-request=2 +ovs-vsctl set open . external_ids:ovn-bridge-mappings=physnet1:br-phys + +sim_add hv2 +as hv2 +ovs-vsctl add-br br-underlay +ovn_attach n1 br-underlay 192.168.0.2 +ovs-vsctl add-br br-phys +ovs-vsctl -- add-port br-int vif2 -- \ + set interface vif2 external-ids:iface-id=vif2 \ + options:tx_pcap=hv2/vif2-tx.pcap \ + options:rxq_pcap=hv2/vif2-rx.pcap \ + ofport-request=1 +ovs-vsctl -- add-port br-phys ext2 -- \ + set interface ext2 \ + options:tx_pcap=hv2/ext2-tx.pcap \ + options:rxq_pcap=hv2/ext2-rx.pcap \ + ofport-request=2 +ovs-vsctl set open . external_ids:ovn-bridge-mappings=physnet1:br-phys + +OVN_POPULATE_ARP + +send_garp() { + hv=$1 + dev=$2 + mac_byte=$3 + ip_byte=${4-$3} + + mac="0000000010$mac_byte" + ip=`ip_to_hex 192 168 10 $ip_byte` + packet=ffffffffffff${mac}08060001080006040002${mac}${ip}${mac}${ip} + as $hv ovs-appctl netdev-dummy/receive $dev $packet +} + +# Check if the option is not present by default +AT_CHECK([fetch_column nb:logical_router options name="gw" | grep -q mac_binding_age_threshold], [1]) + +# Send GARP to populate MAC binding table records +send_garp hv1 ext1 10 +send_garp hv2 ext2 20 + +OVS_WAIT_UNTIL([ovn-sbctl list mac_binding | grep -q "192.168.10.10"]) +OVS_WAIT_UNTIL([ovn-sbctl list mac_binding | grep -q "192.168.10.20"]) + +# Set the MAC binding aging threshold +AT_CHECK([ovn-nbctl set logical_router gw options:mac_binding_age_threshold=1]) +AT_CHECK([fetch_column nb:logical_router options | grep -q mac_binding_age_threshold=1]) +AT_CHECK([ovn-nbctl --wait=sb sync]) + +# Set the timeout for OVS_WAIT* functions to 5 seconds +OVS_CTL_TIMEOUT=5 +# Check if the records are removed after some inactivity +OVS_WAIT_UNTIL([ + test "0" = "$(ovn-sbctl list mac_binding | grep -c '192.168.10.10')" +]) +OVS_WAIT_UNTIL([ + test "0" = "$(ovn-sbctl list mac_binding | grep -c '192.168.10.20')" +]) + +OVN_CLEANUP([hv1], [hv2]) +AT_CLEANUP +]) From patchwork Thu Aug 11 14:20:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1665595 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=Es/sHByd; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4M3TVP0SP1z9sG0 for ; Fri, 12 Aug 2022 00:20:29 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id CEBBF61145; Thu, 11 Aug 2022 14:20:26 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org CEBBF61145 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=Es/sHByd X-Virus-Scanned: amavisd-new at osuosl.org 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 o7BPM4efCFhR; Thu, 11 Aug 2022 14:20:24 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id DD7836112E; Thu, 11 Aug 2022 14:20:22 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org DD7836112E Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9DBF6C0035; Thu, 11 Aug 2022 14:20:22 +0000 (UTC) X-Original-To: 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 2885EC0081 for ; Thu, 11 Aug 2022 14:20:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 515AD61115 for ; Thu, 11 Aug 2022 14:20:18 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 515AD61115 X-Virus-Scanned: amavisd-new at osuosl.org 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 f8e06DG-8E3M for ; Thu, 11 Aug 2022 14:20:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org A36AA61106 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id A36AA61106 for ; Thu, 11 Aug 2022 14:20:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660227615; 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: in-reply-to:in-reply-to:references:references; bh=+JR1hzjs+yq128fw1hhhEDyACc7A+8L2nknWKj3ZNhQ=; b=Es/sHBydPtHCHqDNo4SGY5pQFos5cuJku4oUGNqiSNRxUtOJu8Yj49bPJE1OA4el/0WWtB MyIyPBQGnV1CxPGjDhwYFVM1yS3qtlq4qJF8ULu3U+0wMgwaM4QAUKz7ckDNtJ+7B2pDyt nvn5WAoycKWm0M5WIVaJfljCw3/JBuc= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-141-3aswpYh3M0K0WSjHCHAiiw-1; Thu, 11 Aug 2022 10:20:12 -0400 X-MC-Unique: 3aswpYh3M0K0WSjHCHAiiw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CA1431C07568; Thu, 11 Aug 2022 14:20:11 +0000 (UTC) Received: from amusil.redhat.com (unknown [10.40.192.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id AADD4492C3B; Thu, 11 Aug 2022 14:20:10 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Thu, 11 Aug 2022 16:20:01 +0200 Message-Id: <20220811142001.106287-6-amusil@redhat.com> In-Reply-To: <20220811142001.106287-1-amusil@redhat.com> References: <20220811142001.106287-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: dceara@redhat.com Subject: [ovs-dev] [PATCH ovn v5 5/5] northd: Add config to limit bulk removal of MAC binding 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" Add configuration option into NB global table called "mac_binding_removal_limit" defaulting to 0. This option allows to limit number of MAC bindings that can be removed by the aging mechanism in a single transaction. The 0 means that the mechanism is disabled. If the limit is reached next removal will be delayed by 10 ms. This option when being set has a downside that in theory we could never finish the removal, however in practice it is unlikely considering that not all routers will have aging enabled and the enabled will be with reasonable threshold. Reported-at: https://bugzilla.redhat.com/2084668 Signed-off-by: Ales Musil Acked-by: Mark Michelson --- v4: Rebase on top of current main. Address comment from Numan. v5: Rebase on top of current main. Adress comment from Dumitru. --- northd/inc-proc-northd.c | 1 + northd/mac-binding-aging.c | 33 +++++++++++++++++++++++++++++++-- ovn-nb.xml | 8 ++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c index fc0d9e670..54e0ad3b0 100644 --- a/northd/inc-proc-northd.c +++ b/northd/inc-proc-northd.c @@ -215,6 +215,7 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, engine_add_input(&en_northd, &en_sb_load_balancer, NULL); engine_add_input(&en_northd, &en_sb_fdb, NULL); engine_add_input(&en_northd, &en_sb_static_mac_binding, NULL); + engine_add_input(&en_mac_binding_aging, &en_nb_nb_global, NULL); engine_add_input(&en_mac_binding_aging, &en_sb_mac_binding, NULL); engine_add_input(&en_mac_binding_aging, &en_northd, NULL); engine_add_input(&en_mac_binding_aging, &en_mac_binding_aging_waker, NULL); diff --git a/northd/mac-binding-aging.c b/northd/mac-binding-aging.c index 3859c050b..36d0a6fd7 100644 --- a/northd/mac-binding-aging.c +++ b/northd/mac-binding-aging.c @@ -28,6 +28,8 @@ VLOG_DEFINE_THIS_MODULE(mac_binding_aging); +#define MAC_BINDING_BULK_REMOVAL_DELAY_MSEC 10 + struct mac_binding_waker { bool should_schedule; long long next_wake_msec; @@ -37,7 +39,8 @@ static void mac_binding_aging_run_for_datapath(const struct sbrec_datapath_binding *dp, const struct nbrec_logical_router *nbr, struct ovsdb_idl_index *mb_by_datapath, - int64_t now, int64_t *wake_delay) + int64_t now, int64_t *wake_delay, + uint32_t removal_limit, uint32_t *removed_n) { uint64_t threshold = smap_get_uint(&nbr->options, "mac_binding_age_threshold", @@ -58,6 +61,10 @@ mac_binding_aging_run_for_datapath(const struct sbrec_datapath_binding *dp, continue; } else if (elapsed >= threshold) { sbrec_mac_binding_delete(mb); + (*removed_n)++; + if (removal_limit && *removed_n == removal_limit) { + break; + } } else { *wake_delay = MIN(*wake_delay, threshold - elapsed); } @@ -65,6 +72,20 @@ mac_binding_aging_run_for_datapath(const struct sbrec_datapath_binding *dp, sbrec_mac_binding_index_destroy_row(mb_index_row); } +static uint32_t +get_removal_limit(struct engine_node *node) +{ + const struct nbrec_nb_global_table *nb_global_table = + EN_OVSDB_GET(engine_get_input("NB_nb_global", node)); + const struct nbrec_nb_global *nb = + nbrec_nb_global_table_first(nb_global_table); + if (!nb) { + return 0; + } + + return smap_get_uint(&nb->options, "mac_binding_removal_limit", 0); +} + void en_mac_binding_aging_run(struct engine_node *node, void *data OVS_UNUSED) { @@ -76,6 +97,8 @@ en_mac_binding_aging_run(struct engine_node *node, void *data OVS_UNUSED) int64_t next_expire_msec = INT64_MAX; int64_t now = time_wall_msec(); + uint32_t removal_limit = get_removal_limit(node); + uint32_t removed_n = 0; struct northd_data *northd_data = engine_get_input_data("northd", node); struct mac_binding_waker *waker = engine_get_input_data("mac_binding_aging_waker", node); @@ -88,7 +111,13 @@ en_mac_binding_aging_run(struct engine_node *node, void *data OVS_UNUSED) if (od->sb && od->nbr) { mac_binding_aging_run_for_datapath(od->sb, od->nbr, sbrec_mac_binding_by_datapath, - now, &next_expire_msec); + now, &next_expire_msec, + removal_limit, &removed_n); + if (removal_limit && removed_n == removal_limit) { + /* Schedule the next run after specified delay. */ + next_expire_msec = MAC_BINDING_BULK_REMOVAL_DELAY_MSEC; + break; + } } } diff --git a/ovn-nb.xml b/ovn-nb.xml index 57c7d6174..bed1a3aa1 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -162,6 +162,14 @@ dynamically assigned, e.g. 00:11:22 + + MAC binding aging bulk removal limit. This limits how many rows + can expire in a single transaction. Default value is 0 which + is unlimited. When we hit the limit next batch removal is delayed by + 10 ms. + + Value set by the CMS to enable/disable ovn-controller event reporting. Traffic into OVS can raise a 'controller' event that results in a