From patchwork Fri Nov 4 07:57:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1699359 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Jq1GKbWa; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4N3XzW1Z45z23lK for ; Fri, 4 Nov 2022 18:57:43 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 2557781FDF; Fri, 4 Nov 2022 07:57:41 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 2557781FDF 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=Jq1GKbWa 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 aV4v5YiNnM0Y; Fri, 4 Nov 2022 07:57:40 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 4452481FB5; Fri, 4 Nov 2022 07:57:39 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 4452481FB5 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id F1613C0032; Fri, 4 Nov 2022 07:57:38 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 900CAC002D for ; Fri, 4 Nov 2022 07:57:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 51EFC4187A for ; Fri, 4 Nov 2022 07:57:36 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 51EFC4187A Authentication-Results: smtp4.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Jq1GKbWa 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 hOCguI4yCoHp for ; Fri, 4 Nov 2022 07:57:35 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 0D6CF41878 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id 0D6CF41878 for ; Fri, 4 Nov 2022 07:57:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667548653; 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=WypvXJalCSFdo7avr4ZzyWiPRSJ//clowyRtX/kLftQ=; b=Jq1GKbWaIwhp9KD+dGiOm3Hr4n7E1SQI2QH8Tf+PItMugnf5Pn9SPpv9pabDeTdzvK5H/b KWXfAr306rS+WljICfg7csXBuH8c2at3jfydsAaSCnrJv885iTP774c75oew3UqjvPIuIK RGc0tWVPdnZLDTNBEXjzKk0P4hy68rc= 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-300--6MADAdJMvaINkacFKEBGg-1; Fri, 04 Nov 2022 03:57:32 -0400 X-MC-Unique: -6MADAdJMvaINkacFKEBGg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4FC231C006C9; Fri, 4 Nov 2022 07:57:32 +0000 (UTC) Received: from amusil.redhat.com (ovpn-192-80.brq.redhat.com [10.40.192.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8AE52C04483; Fri, 4 Nov 2022 07:57:30 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 4 Nov 2022 08:57:22 +0100 Message-Id: <20221104075729.219169-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: Dumitru Ceara Subject: [ovs-dev] [PATCH ovn v2 1/8] 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 Acked-by: Mark Michelson Acked-by: Han Zhou Signed-off-by: Ales Musil --- v2: Fix the SBDB schema version --- 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 9fe7859d5..ad79cda6e 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -4212,8 +4212,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..de1a3c113 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": "1811467130 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 42b3d4d68..1a555175c 100644 --- a/ovn-sb.xml +++ b/ovn-sb.xml @@ -3672,6 +3672,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 Fri Nov 4 07:57:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1699360 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TKReTVkP; dkim-atps=neutral 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4N3Xzb6JfYz23lK for ; Fri, 4 Nov 2022 18:57:47 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id DDD9C40C05; Fri, 4 Nov 2022 07:57:44 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org DDD9C40C05 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=TKReTVkP 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 dHdPHNv1y8Op; Fri, 4 Nov 2022 07:57:43 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id 9797240B56; Fri, 4 Nov 2022 07:57:42 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 9797240B56 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 65DE7C002D; Fri, 4 Nov 2022 07:57:42 +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 35463C007D for ; Fri, 4 Nov 2022 07:57:40 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 0A44A404F1 for ; Fri, 4 Nov 2022 07:57:40 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 0A44A404F1 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 ICXGmqEIIAlw for ; Fri, 4 Nov 2022 07:57:39 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org DC08240124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id DC08240124 for ; Fri, 4 Nov 2022 07:57:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667548657; 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=mfzlJK1KK+OIft3tQ4BOX5TAeCXFAv7pzRpvV93o0G4=; b=TKReTVkPtrHElUELZM8IxJFgfVjo8ArjagnMuMAYm3ArIINB4ucwpCRUzh7p6K2H50xzx6 YMDxMuP3Y53dx8lgfiBQe/bZ4TIfGLw8hQdMcCqqm/g6xzYFZvuCkCZvfNl45DEO/bExvM nj6uhNeFlThbqHZa+XBMjMHfSNiowc4= 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-459--EeLNrRoNY6jB_vm4WhG5A-1; Fri, 04 Nov 2022 03:57:34 -0400 X-MC-Unique: -EeLNrRoNY6jB_vm4WhG5A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2862718153EC; Fri, 4 Nov 2022 07:57:34 +0000 (UTC) Received: from amusil.redhat.com (ovpn-192-80.brq.redhat.com [10.40.192.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD663C15995; Fri, 4 Nov 2022 07:57:32 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 4 Nov 2022 08:57:23 +0100 Message-Id: <20221104075729.219169-2-amusil@redhat.com> In-Reply-To: <20221104075729.219169-1-amusil@redhat.com> References: <20221104075729.219169-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: Dumitru Ceara Subject: [ovs-dev] [PATCH ovn v2 2/8] 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 Acked-by: Mark Michelson Acked-by: Han Zhou Signed-off-by: Ales Musil --- 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 000d57c41..57061b830 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 Fri Nov 4 07:57:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1699362 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KcKy5DJQ; dkim-atps=neutral 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4N3Xzh5PsPz23lK for ; Fri, 4 Nov 2022 18:57:52 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id A680440C24; Fri, 4 Nov 2022 07:57:50 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org A680440C24 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=KcKy5DJQ 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 l7dFW0wlVlUJ; Fri, 4 Nov 2022 07:57:47 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 2CEBA40BF5; Fri, 4 Nov 2022 07:57:46 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 2CEBA40BF5 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A3DA2C0082; Fri, 4 Nov 2022 07:57:45 +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 1093DC0032 for ; Fri, 4 Nov 2022 07:57:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id CC85F81FE2 for ; Fri, 4 Nov 2022 07:57:41 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org CC85F81FE2 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=KcKy5DJQ 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 YwWFpkRQsVKU for ; Fri, 4 Nov 2022 07:57:40 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 8C7B581FDA 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 8C7B581FDA for ; Fri, 4 Nov 2022 07:57:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667548659; 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=nEjEzCDuyKf6OQQd/wzq6u2+YFqYTY4BC3Hj+T+e1c8=; b=KcKy5DJQd9+b/j5jw2jBfBBxHt5BkLpQgFFy2PiOeUPgtoLRGGv/HHob+9R+0Rh4MGr7V/ w54810VHYIy6KfwxKmDEi6OUlyDEev8LokpTyPdX8+Uij+6tmmOZham9NE6jgqrkvmU0pn B2yuaJjpEX4KD+c1jdxh8aurrajGR6A= 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-646-E2C-Msj-MWWUit28Rv1Big-1; Fri, 04 Nov 2022 03:57:36 -0400 X-MC-Unique: E2C-Msj-MWWUit28Rv1Big-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E97FD2804BAF; Fri, 4 Nov 2022 07:57:35 +0000 (UTC) Received: from amusil.redhat.com (ovpn-192-80.brq.redhat.com [10.40.192.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87081C2DF63; Fri, 4 Nov 2022 07:57:34 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 4 Nov 2022 08:57:24 +0100 Message-Id: <20221104075729.219169-3-amusil@redhat.com> In-Reply-To: <20221104075729.219169-1-amusil@redhat.com> References: <20221104075729.219169-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: Dumitru Ceara Subject: [ovs-dev] [PATCH ovn v2 3/8] 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 Acked-by: Mark Michelson Acked-by: Han Zhou Signed-off-by: Ales Musil --- northd/northd.c | 147 ---------------------------------------------- northd/northd.h | 151 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+), 147 deletions(-) diff --git a/northd/northd.c b/northd/northd.c index 62f511613..bb92bbc6f 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,85 +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; - - /* Load Balancer vIPs relevant for this datapath. */ - struct ovn_lb_ip_set *lb_ips; - - 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 4de809a3d..68c55bff4 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 { @@ -101,6 +105,153 @@ 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; + + /* Load Balancer vIPs relevant for this datapath. */ + struct ovn_lb_ip_set *lb_ips; + + 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 Fri Nov 4 07:57:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1699361 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WoX0Cdpt; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4N3Xzc672qz23lQ for ; Fri, 4 Nov 2022 18:57:48 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id EF73281FF5; Fri, 4 Nov 2022 07:57:46 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org EF73281FF5 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=WoX0Cdpt 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 HocRSArnavML; Fri, 4 Nov 2022 07:57:45 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 179E881FE8; Fri, 4 Nov 2022 07:57:44 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 179E881FE8 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9D170C007B; Fri, 4 Nov 2022 07:57:43 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 11155C0032 for ; Fri, 4 Nov 2022 07:57:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id C4F3C60BEE for ; Fri, 4 Nov 2022 07:57:40 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org C4F3C60BEE Authentication-Results: smtp3.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WoX0Cdpt 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 oWbJy8VJ4iUR for ; Fri, 4 Nov 2022 07:57:39 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 5923761042 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id 5923761042 for ; Fri, 4 Nov 2022 07:57:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667548658; 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=GZ7p6nqaYIuW0MGEL8o7zus1JoVLL/LeC9c5jjO3ytE=; b=WoX0Cdpt/0mzdJqfsSIF9MiGxLz/oNI2+nPH5Pbytclvka+Cxp6UB2NoWoVamTKYc2bnWK ffg18165QeL0FKFLvxCMKIdruI92ifasQ6xcsXPUS40sRTIpfHDwcvGsRXyb4GaN/wFOSj iiN9q3IK08SidFvgDEwwjO4Gmwm3kX4= 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-584-ayV05oaROKi3yHIH0o5d6g-1; Fri, 04 Nov 2022 03:57:37 -0400 X-MC-Unique: ayV05oaROKi3yHIH0o5d6g-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 210552804BAB for ; Fri, 4 Nov 2022 07:57:37 +0000 (UTC) Received: from amusil.redhat.com (ovpn-192-80.brq.redhat.com [10.40.192.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 478EFC04483; Fri, 4 Nov 2022 07:57:36 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 4 Nov 2022 08:57:25 +0100 Message-Id: <20221104075729.219169-4-amusil@redhat.com> In-Reply-To: <20221104075729.219169-1-amusil@redhat.com> References: <20221104075729.219169-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: Dumitru Ceara Subject: [ovs-dev] [PATCH ovn v2 4/8] 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 Acked-by: Dumitru Ceara Signed-off-by: Ales Musil --- 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 | 113 ++++++++++++++++++++++++++ 7 files changed, 334 insertions(+) create mode 100644 northd/mac-binding-aging.c create mode 100644 northd/mac-binding-aging.h diff --git a/NEWS b/NEWS index 1c8a3d165..236d0007f 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,9 @@ OVN v22.06.1 - xx xxx xxxx NAT-T UDP encapsulation. Requires OVS support for IPsec custom tunnel options (which is available in OVS 3.0). - Bump python version required for building OVN to 3.6. + - 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 47fd5a544..d137d68cf 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 f8ff2b64f..cf6d29727 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -32316,3 +32316,116 @@ check ovn-nbctl --wait=hv sync 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 +wait_for_ports_up +AT_CHECK([ovn-nbctl --wait=hv sync]) + +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 Fri Nov 4 07:57:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1699363 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Oysu7Kqg; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4N3Xzl0mRnz23lK for ; Fri, 4 Nov 2022 18:57:55 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 9779081FF7; Fri, 4 Nov 2022 07:57:52 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 9779081FF7 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=Oysu7Kqg 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 n_nPSS1VqnzP; Fri, 4 Nov 2022 07:57:51 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id ECB7682001; Fri, 4 Nov 2022 07:57:48 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org ECB7682001 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A215DC007D; Fri, 4 Nov 2022 07:57:48 +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 03288C007B for ; Fri, 4 Nov 2022 07:57:43 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 220BF81FCA for ; Fri, 4 Nov 2022 07:57:42 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 220BF81FCA 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 Sh630djgH5Pa for ; Fri, 4 Nov 2022 07:57:41 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 083C881FDE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 083C881FDE for ; Fri, 4 Nov 2022 07:57:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667548660; 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=KUOgLAV2HUdSpFpoc5yXWo5LrPDq5ahbh94W7Iyg7uM=; b=Oysu7Kqgaxy/LEwHWLnBJ+PFc1SXHJY80nY4vVpED8j8NYFNFg7rOEZEnn82La9n0OZ9xy MPbumdpvdgGfFPprKVMFhfVAp8MR35bSCI1pH2+PEFa4llibe//Owg5BdzOwYf8PWZmKzd 8UesfBXnMp1sd7ae8VlWC+tKkwBVbuw= 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-547-kXSQdXZ6P3ihOEW9OrUhoQ-1; Fri, 04 Nov 2022 03:57:38 -0400 X-MC-Unique: kXSQdXZ6P3ihOEW9OrUhoQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A270A86F12F for ; Fri, 4 Nov 2022 07:57:38 +0000 (UTC) Received: from amusil.redhat.com (ovpn-192-80.brq.redhat.com [10.40.192.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5ED5FC16932; Fri, 4 Nov 2022 07:57:37 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 4 Nov 2022 08:57:26 +0100 Message-Id: <20221104075729.219169-5-amusil@redhat.com> In-Reply-To: <20221104075729.219169-1-amusil@redhat.com> References: <20221104075729.219169-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: Dumitru Ceara Subject: [ovs-dev] [PATCH ovn v2 5/8] 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 Acked-by: Mark Michelson Acked-by: Dumitru Ceara Signed-off-by: Ales Musil --- 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 d137d68cf..2747b0a7d 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 From patchwork Fri Nov 4 07:57:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1699365 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JcZmY2jn; dkim-atps=neutral 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4N3Xzp3dmQz23lQ for ; Fri, 4 Nov 2022 18:57:58 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 01005418EE; Fri, 4 Nov 2022 07:57:55 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 01005418EE 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=JcZmY2jn 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 61gYQXR6KcNe; Fri, 4 Nov 2022 07:57:54 +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 7D51C418C0; Fri, 4 Nov 2022 07:57:51 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 7D51C418C0 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0FAC4C0081; Fri, 4 Nov 2022 07:57:50 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 64647C0071 for ; Fri, 4 Nov 2022 07:57:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id B311D40BFC for ; Fri, 4 Nov 2022 07:57:43 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org B311D40BFC 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=JcZmY2jn 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 7jQJtZX9fhJs for ; Fri, 4 Nov 2022 07:57:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org E7B3340124 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 E7B3340124 for ; Fri, 4 Nov 2022 07:57:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667548661; 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=AMTYldjD3BVG54x8OkdZduf8RTEZSEwSmGKIRw+HVpw=; b=JcZmY2jnaJljq1YBNz9EbFWrO4sKRUHZAW7tuPRJozPNbm0cLoy9QlUbXcPSlrat0cFD5W Bt7py9Yz+F+cLaNuZzwglVar3YntWWXybV7IEp+awWznMMaUASiWlae3XdzPWO+xfEabN3 1uzA9qhy/5/CVShfJV3zaLjK4qIp/2U= 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-122-5Jirej7sMjiw8K2Ye4fQsg-1; Fri, 04 Nov 2022 03:57:40 -0400 X-MC-Unique: 5Jirej7sMjiw8K2Ye4fQsg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 62AE41C004FD for ; Fri, 4 Nov 2022 07:57:40 +0000 (UTC) Received: from amusil.redhat.com (ovpn-192-80.brq.redhat.com [10.40.192.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E195C04483; Fri, 4 Nov 2022 07:57:38 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 4 Nov 2022 08:57:27 +0100 Message-Id: <20221104075729.219169-6-amusil@redhat.com> In-Reply-To: <20221104075729.219169-1-amusil@redhat.com> References: <20221104075729.219169-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: Dumitru Ceara Subject: [ovs-dev] [PATCH ovn v2 6/8] northd, controller: Add MAC binding timestamp feature indication 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" It can happen that northd and SB DB are updated before ovn-controller in that case the new MAC binding would be added with timestamp=0. In combination with enabled MAC binding aging, the affected rows would be deleted over and over until the controller is upgraded. To prevent the before mentioned issue add indication if the controller supports MAC binding timestamps. Signed-off-by: Ales Musil Acked-by: Dumitru Ceara --- controller/chassis.c | 7 +++++++ include/ovn/features.h | 1 + northd/mac-binding-aging.c | 5 +++-- northd/northd.c | 24 ++++++++++++++++++------ northd/northd.h | 1 + 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/controller/chassis.c b/controller/chassis.c index 92850fcc1..c6a1c50ae 100644 --- a/controller/chassis.c +++ b/controller/chassis.c @@ -351,6 +351,7 @@ chassis_build_other_config(const struct ovs_chassis_cfg *ovs_cfg, ovs_cfg->is_interconn ? "true" : "false"); smap_replace(config, OVN_FEATURE_PORT_UP_NOTIF, "true"); smap_replace(config, OVN_FEATURE_CT_NO_MASKED_LABEL, "true"); + smap_replace(config, OVN_FEATURE_MAC_BINDING_TIMESTAMP, "true"); } /* @@ -462,6 +463,12 @@ chassis_other_config_changed(const struct ovs_chassis_cfg *ovs_cfg, return true; } + if (!smap_get_bool(&chassis_rec->other_config, + OVN_FEATURE_MAC_BINDING_TIMESTAMP, + false)) { + return true; + } + return false; } diff --git a/include/ovn/features.h b/include/ovn/features.h index 8fbdbf19a..679f67457 100644 --- a/include/ovn/features.h +++ b/include/ovn/features.h @@ -23,6 +23,7 @@ /* ovn-controller supported feature names. */ #define OVN_FEATURE_PORT_UP_NOTIF "port-up-notif" #define OVN_FEATURE_CT_NO_MASKED_LABEL "ct-no-masked-label" +#define OVN_FEATURE_MAC_BINDING_TIMESTAMP "mac-binding-timestamp" /* OVS datapath supported features. Based on availability OVN might generate * different types of openflows. diff --git a/northd/mac-binding-aging.c b/northd/mac-binding-aging.c index 36d0a6fd7..4a2dfbbf8 100644 --- a/northd/mac-binding-aging.c +++ b/northd/mac-binding-aging.c @@ -90,8 +90,10 @@ void en_mac_binding_aging_run(struct engine_node *node, void *data OVS_UNUSED) { const struct engine_context *eng_ctx = engine_get_context(); + struct northd_data *northd_data = engine_get_input_data("northd", node); - if (!eng_ctx->ovnsb_idl_txn) { + if (!eng_ctx->ovnsb_idl_txn || + !northd_data->features.mac_binding_timestamp) { return; } @@ -99,7 +101,6 @@ en_mac_binding_aging_run(struct engine_node *node, void *data OVS_UNUSED) 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); struct ovsdb_idl_index *sbrec_mac_binding_by_datapath = diff --git a/northd/northd.c b/northd/northd.c index bb92bbc6f..e7b53410b 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -407,14 +407,23 @@ build_chassis_features(const struct northd_input *input_data, const struct sbrec_chassis *chassis; SBREC_CHASSIS_TABLE_FOR_EACH (chassis, input_data->sbrec_chassis) { - if (!smap_get_bool(&chassis->other_config, - OVN_FEATURE_CT_NO_MASKED_LABEL, - false)) { + bool ct_no_masked_label = + smap_get_bool(&chassis->other_config, + OVN_FEATURE_CT_NO_MASKED_LABEL, + false); + if (!ct_no_masked_label && chassis_features->ct_no_masked_label) { chassis_features->ct_no_masked_label = false; - return; + } + + bool mac_binding_timestamp = + smap_get_bool(&chassis->other_config, + OVN_FEATURE_MAC_BINDING_TIMESTAMP, + false); + if (!mac_binding_timestamp && + chassis_features->mac_binding_timestamp) { + chassis_features->mac_binding_timestamp = false; } } - chassis_features->ct_no_masked_label = true; } struct ovn_chassis_qdisc_queues { @@ -15324,7 +15333,10 @@ northd_init(struct northd_data *data) hmap_init(&data->lb_groups); hmap_init(&data->bfd_connections); ovs_list_init(&data->lr_list); - memset(&data->features, 0, sizeof data->features); + data->features = (struct chassis_features) { + .ct_no_masked_label = true, + .mac_binding_timestamp = true, + }; data->ovn_internal_version_changed = false; } diff --git a/northd/northd.h b/northd/northd.h index 68c55bff4..4319c49fa 100644 --- a/northd/northd.h +++ b/northd/northd.h @@ -66,6 +66,7 @@ struct northd_input { struct chassis_features { bool ct_no_masked_label; + bool mac_binding_timestamp; }; struct northd_data { From patchwork Fri Nov 4 07:57:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1699364 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=EQU1Ic7z; dkim-atps=neutral Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4N3Xzp1pTyz23lK for ; Fri, 4 Nov 2022 18:57:58 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 53BE861067; Fri, 4 Nov 2022 07:57:56 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 53BE861067 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=EQU1Ic7z 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 11S1laMXapAT; Fri, 4 Nov 2022 07:57:55 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id DE3946108E; Fri, 4 Nov 2022 07:57:53 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org DE3946108E Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A872AC0082; Fri, 4 Nov 2022 07:57:52 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0A58DC0032 for ; Fri, 4 Nov 2022 07:57:50 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 654BE40BFF for ; Fri, 4 Nov 2022 07:57:46 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 654BE40BFF 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=EQU1Ic7z 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 fLRoyBC_W2Ve for ; Fri, 4 Nov 2022 07:57:45 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 8581D40C00 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 8581D40C00 for ; Fri, 4 Nov 2022 07:57:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667548663; 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=S/ve7y3RTAwHAp6SnEiVZc4b3ckJTnVlLkVrFLrK/ro=; b=EQU1Ic7zonKdk8LoVDkx+r3xbT0TG5c65ovkeHigWcjhwUIJWezB4DF2C4P+E8wbV2lqRg A0u1/dqvayHjG0LxRDHcwJlatQXpjPLG942cIkPiCf9O/Gi0Pq4Opv7nvXro3TFbuPWWzc wztaRMUqGBL55OyQTp9eh7PZrlhCURU= 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-642-2QbR3QdYMIW2rY0_I087Cw-1; Fri, 04 Nov 2022 03:57:42 -0400 X-MC-Unique: 2QbR3QdYMIW2rY0_I087Cw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2AF2A1C004FD for ; Fri, 4 Nov 2022 07:57:42 +0000 (UTC) Received: from amusil.redhat.com (ovpn-192-80.brq.redhat.com [10.40.192.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC0A0C16932; Fri, 4 Nov 2022 07:57:40 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 4 Nov 2022 08:57:28 +0100 Message-Id: <20221104075729.219169-7-amusil@redhat.com> In-Reply-To: <20221104075729.219169-1-amusil@redhat.com> References: <20221104075729.219169-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: Dumitru Ceara Subject: [ovs-dev] [PATCH ovn v2 7/8] northd: Increase the MAC binding removal delay 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" Reported-at: https://bugzilla.redhat.com/2084668 Signed-off-by: Ales Musil Acked-by: Dumitru Ceara Signed-off-by: Mark Michelson --- northd/mac-binding-aging.c | 2 +- ovn-nb.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/northd/mac-binding-aging.c b/northd/mac-binding-aging.c index 4a2dfbbf8..0196a116b 100644 --- a/northd/mac-binding-aging.c +++ b/northd/mac-binding-aging.c @@ -28,7 +28,7 @@ VLOG_DEFINE_THIS_MODULE(mac_binding_aging); -#define MAC_BINDING_BULK_REMOVAL_DELAY_MSEC 10 +#define MAC_BINDING_BULK_REMOVAL_DELAY_MSEC 5000 struct mac_binding_waker { bool should_schedule; diff --git a/ovn-nb.xml b/ovn-nb.xml index 2747b0a7d..8aa125093 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -167,7 +167,7 @@ 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. + 5 s. From patchwork Fri Nov 4 07:57:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1699366 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=crywkBiD; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4N3Y003mP1z23lK for ; Fri, 4 Nov 2022 18:58:08 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 2ED798207D; Fri, 4 Nov 2022 07:58:06 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 2ED798207D 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=crywkBiD 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 HAtnXOOzQHQu; Fri, 4 Nov 2022 07:58:04 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 2815E82047; Fri, 4 Nov 2022 07:57:58 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 2815E82047 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E63B7C002D; Fri, 4 Nov 2022 07:57:57 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2A101C007B for ; Fri, 4 Nov 2022 07:57:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 7701D40C1B for ; Fri, 4 Nov 2022 07:57:48 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 7701D40C1B 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=crywkBiD 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 WkB9ox5q081a for ; Fri, 4 Nov 2022 07:57:47 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 43BD040C10 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 43BD040C10 for ; Fri, 4 Nov 2022 07:57:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667548666; 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=L/5oBH+IpIYoj1rAtgL8dpv4tTcBVZCKMQSed4FthyQ=; b=crywkBiDYIY1r4bN1yPYteo+Rjb/1ZuTrxK1mf+moX7aVMgsut9rxaVJG/n4YwE2dwPa2P 3EthikD6ImfvAB7gS8tbmvfOaOd6AA3ncCUUWny3YDE664DeWRZ+M1uvLPjEUk3TZptUxt 65YCEvbEdkZw+pjyNt+nT0VvhqTCjuo= 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-563-WtEaEKZTNQSvwAuTh2Yf1Q-1; Fri, 04 Nov 2022 03:57:43 -0400 X-MC-Unique: WtEaEKZTNQSvwAuTh2Yf1Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 73CB1800B23; Fri, 4 Nov 2022 07:57:43 +0000 (UTC) Received: from amusil.redhat.com (ovpn-192-80.brq.redhat.com [10.40.192.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83816C04483; Fri, 4 Nov 2022 07:57:42 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 4 Nov 2022 08:57:29 +0100 Message-Id: <20221104075729.219169-8-amusil@redhat.com> In-Reply-To: <20221104075729.219169-1-amusil@redhat.com> References: <20221104075729.219169-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn v2 8/8] northd: Properly check the wakeup time in MAC banding aging 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" We shouldn't run the MAC binding aging if the waker did not expire. This wouldn't cause any issue if the bulk removal limit is not configured. When the limit is configured and hit there will be some MAC bindings expired, just waiting for the bulk removal delay. If something wakes up the aging run earlier it could remove those rows without respecting the delay. Add check if we are past the next wake to prevent that. Signed-off-by: Ales Musil Signed-off-by: Han Zhou --- northd/mac-binding-aging.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/northd/mac-binding-aging.c b/northd/mac-binding-aging.c index 0196a116b..f65353a69 100644 --- a/northd/mac-binding-aging.c +++ b/northd/mac-binding-aging.c @@ -91,9 +91,12 @@ en_mac_binding_aging_run(struct engine_node *node, void *data OVS_UNUSED) { const struct engine_context *eng_ctx = engine_get_context(); 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); if (!eng_ctx->ovnsb_idl_txn || - !northd_data->features.mac_binding_timestamp) { + !northd_data->features.mac_binding_timestamp || + time_msec() < waker->next_wake_msec) { return; } @@ -101,8 +104,6 @@ en_mac_binding_aging_run(struct engine_node *node, void *data OVS_UNUSED) int64_t now = time_wall_msec(); uint32_t removal_limit = get_removal_limit(node); uint32_t removed_n = 0; - 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");