From patchwork Fri Nov 4 08:03:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1699369 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=ifIVb5pX; 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 4N3Y6g4BvFz1yqS for ; Fri, 4 Nov 2022 19:03:55 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id A1CD561064; Fri, 4 Nov 2022 08:03:53 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org A1CD561064 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=ifIVb5pX 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 kAaxBjo8fyYS; Fri, 4 Nov 2022 08:03:52 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id CF270605B5; Fri, 4 Nov 2022 08:03:51 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org CF270605B5 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A6D3FC0032; Fri, 4 Nov 2022 08:03:51 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 61FE0C002D for ; Fri, 4 Nov 2022 08:03:50 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 48B3440425 for ; Fri, 4 Nov 2022 08:03:50 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 48B3440425 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=ifIVb5pX 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 qkmhpH0lSXul for ; Fri, 4 Nov 2022 08:03:49 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org CA0AE401BC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id CA0AE401BC for ; Fri, 4 Nov 2022 08:03:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667549027; 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=ifIVb5pXbTXhiS28+WScZ9PJ1XNt/Z9ko7XJTEvJKmqwRvXBVEMbXiEdt3otfn2nHXVQaH VyKi55rGv5K9Mao0BCxeWJ3kgSb1OXWutMFCiJ074TReZE741Y6rYXXo/zXF0DTjAXCMTr yTHCPz9tvd05jbnmjNUgpjucbu9VHkw= 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-495-uDfPF_k6Pn6vztolAvZNSA-1; Fri, 04 Nov 2022 04:03:45 -0400 X-MC-Unique: uDfPF_k6Pn6vztolAvZNSA-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 6FF963814958; Fri, 4 Nov 2022 08:03:45 +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 C7276C16932; Fri, 4 Nov 2022 08:03:43 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 4 Nov 2022 09:03:35 +0100 Message-Id: <20221104080342.248001-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 branch-22.06 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 08:03:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1699370 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=KzvG8ZeG; 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 4N3Y6k6j4Sz1yqS for ; Fri, 4 Nov 2022 19:03:58 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id D43F982004; Fri, 4 Nov 2022 08:03:56 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org D43F982004 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=KzvG8ZeG 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 qZtmaqUotfam; Fri, 4 Nov 2022 08:03:55 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 7D5F780BD7; Fri, 4 Nov 2022 08:03:54 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 7D5F780BD7 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 69EC3C007F; Fri, 4 Nov 2022 08:03: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 906E8C002D for ; Fri, 4 Nov 2022 08:03:50 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 5EB5440BF5 for ; Fri, 4 Nov 2022 08:03:50 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 5EB5440BF5 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=KzvG8ZeG 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 4oJJ48rpXgx8 for ; Fri, 4 Nov 2022 08:03:49 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 4B70840BF1 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 4B70840BF1 for ; Fri, 4 Nov 2022 08:03:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667549028; 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=KzvG8ZeGbl5R44gxtkmnWqqvcwWKfzvbo2nmbS2ppG98JWBmwSl3xqDefqQ/IjFBo9bwlh MZ2vPdx5iBBeHb7CGtyU/4qu00L4cVUkRf+46hVuljWKLVCz8iimuaknDNFjsvVcHnrEN2 BApSLm7D8JO49HPca8iMzDIIPto9gVM= 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-633-TTWZrPSGPB6l_8vHNt7TBg-1; Fri, 04 Nov 2022 04:03:47 -0400 X-MC-Unique: TTWZrPSGPB6l_8vHNt7TBg-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 33122800B23; Fri, 4 Nov 2022 08:03:47 +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 D3238C42391; Fri, 4 Nov 2022 08:03:45 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 4 Nov 2022 09:03:36 +0100 Message-Id: <20221104080342.248001-2-amusil@redhat.com> In-Reply-To: <20221104080342.248001-1-amusil@redhat.com> References: <20221104080342.248001-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 branch-22.06 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 08:03:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1699373 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.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=TPFM8jF6; dkim-atps=neutral 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4N3Y6w5xzKz1yqS for ; Fri, 4 Nov 2022 19:04:08 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 6127C610A7; Fri, 4 Nov 2022 08:04:03 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 6127C610A7 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=TPFM8jF6 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 vsuwxRGF9tLD; Fri, 4 Nov 2022 08:03:58 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 238426107A; Fri, 4 Nov 2022 08:03:56 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 238426107A Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 66912C0088; Fri, 4 Nov 2022 08:03:54 +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 E79FCC0082 for ; Fri, 4 Nov 2022 08:03:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id AEC2240BFB for ; Fri, 4 Nov 2022 08:03:52 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org AEC2240BFB 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=TPFM8jF6 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 VVPWogjLKgAM for ; Fri, 4 Nov 2022 08:03:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 410E540BF1 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 410E540BF1 for ; Fri, 4 Nov 2022 08:03:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667549030; 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=TPFM8jF6FxZ/Y2MGzrazPob1WgQ65oqaSJKzD7lR1DNBFl4Y74/fahsAf9+cIpv8GCgZwR VTc31V0RtpBkzc5EFlywNqXX4mdLIt/zBlVAkP3gj29exQlZhjd5F4qtBGRPSJnSOUM9F3 LTyiRAbPWbe45VPCaq6kL8jI+r7srU8= 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-149-drq07WSsOYOxnvJcimhN_A-1; Fri, 04 Nov 2022 04:03:49 -0400 X-MC-Unique: drq07WSsOYOxnvJcimhN_A-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 E7F32811E7A; Fri, 4 Nov 2022 08:03:48 +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 9CBB2C2C8DD; Fri, 4 Nov 2022 08:03:47 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 4 Nov 2022 09:03:37 +0100 Message-Id: <20221104080342.248001-3-amusil@redhat.com> In-Reply-To: <20221104080342.248001-1-amusil@redhat.com> References: <20221104080342.248001-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 branch-22.06 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 08:03:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1699371 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.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=S+FY3/Ru; dkim-atps=neutral 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4N3Y6t19WBz1yqS for ; Fri, 4 Nov 2022 19:04:06 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 60E2C61080; Fri, 4 Nov 2022 08:04:03 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 60E2C61080 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=S+FY3/Ru 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 PgxyGQ-gRevO; Fri, 4 Nov 2022 08:04:00 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 02DBB61087; Fri, 4 Nov 2022 08:03:57 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 02DBB61087 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 46C8CC007F; Fri, 4 Nov 2022 08:03:56 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 28FA4C0071 for ; Fri, 4 Nov 2022 08:03:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 1194681FE4 for ; Fri, 4 Nov 2022 08:03:54 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 1194681FE4 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=S+FY3/Ru 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 kQ-57mG0b5Re for ; Fri, 4 Nov 2022 08:03:52 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 7CC7280BD7 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 7CC7280BD7 for ; Fri, 4 Nov 2022 08:03:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667549031; 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=S+FY3/RucJCIrnIa8EDTLTzzu6TI7quJ1gFR47Dkdqjt+gV9DRZ+ziYuDgVHF6OdRHuuid A/mbFI1MoxYk7DpQBepSXcVADJwHQmYr6zfm08Gk+iBBePQKxHEh8iXC9YeT5WpKafNROt HumfzQGoR++liWBtN3HoBJcJ+oOqFMI= 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-556-wp1C2ZqkO9eQlaRYNGVRzg-1; Fri, 04 Nov 2022 04:03:50 -0400 X-MC-Unique: wp1C2ZqkO9eQlaRYNGVRzg-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 2CA6F381494F for ; Fri, 4 Nov 2022 08:03:50 +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 3B251C15995; Fri, 4 Nov 2022 08:03:49 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 4 Nov 2022 09:03:38 +0100 Message-Id: <20221104080342.248001-4-amusil@redhat.com> In-Reply-To: <20221104080342.248001-1-amusil@redhat.com> References: <20221104080342.248001-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 branch-22.06 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 08:03:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1699372 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=b7yLe3g1; 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 4N3Y6v1n1zz1yqS for ; Fri, 4 Nov 2022 19:04:07 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 00E9182020; Fri, 4 Nov 2022 08:04:04 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 00E9182020 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=b7yLe3g1 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 v4nJ_no9xqJ2; Fri, 4 Nov 2022 08:04:01 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id CD8708201C; Fri, 4 Nov 2022 08:03:59 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org CD8708201C Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D14C2C0084; Fri, 4 Nov 2022 08:03:56 +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 478D8C008A for ; Fri, 4 Nov 2022 08:03:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 1F42D41893 for ; Fri, 4 Nov 2022 08:03:55 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 1F42D41893 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=b7yLe3g1 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 tkBdiCsp0gZx for ; Fri, 4 Nov 2022 08:03:54 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org C620A416E2 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 C620A416E2 for ; Fri, 4 Nov 2022 08:03:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667549032; 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=b7yLe3g1x94IqXxPIIcC8rzo3tis4sBx4fBlhrtRobkk5kob6KG/FJt/DSjXUSemhYAR+x 6khFkIbmvbVcORX/JCiG6uPs/P7h7upBM4b8ZMakJndQp+O0PqJ8VSnH1Bn2VhNlpllogo qcUs/uPsODOPmxeAxbppR+21Z3QWcEk= 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-306-x1F32P9OOiCuKvpB1PR1qQ-1; Fri, 04 Nov 2022 04:03:51 -0400 X-MC-Unique: x1F32P9OOiCuKvpB1PR1qQ-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 941D9811E7A for ; Fri, 4 Nov 2022 08:03:51 +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 8C619C16932; Fri, 4 Nov 2022 08:03:50 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 4 Nov 2022 09:03:39 +0100 Message-Id: <20221104080342.248001-5-amusil@redhat.com> In-Reply-To: <20221104080342.248001-1-amusil@redhat.com> References: <20221104080342.248001-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 branch-22.06 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 08:03:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1699374 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=MAkfz+e8; 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 4N3Y6y6MD1z1yqS for ; Fri, 4 Nov 2022 19:04:10 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 0062B8207C; Fri, 4 Nov 2022 08:04:09 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 0062B8207C 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=MAkfz+e8 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 t9z87BasBV2D; Fri, 4 Nov 2022 08:04:05 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 36E2282003; Fri, 4 Nov 2022 08:04:02 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 36E2282003 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D547EC0088; Fri, 4 Nov 2022 08:03:57 +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 CA84EC002D for ; Fri, 4 Nov 2022 08:03:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 8822C61063 for ; Fri, 4 Nov 2022 08:03:55 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 8822C61063 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=MAkfz+e8 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 WnT-SmSxXEWH for ; Fri, 4 Nov 2022 08:03:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org C0E3061070 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 C0E3061070 for ; Fri, 4 Nov 2022 08:03:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667549033; 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=MAkfz+e8E0BxpGCDOf/fDzpqsouXomV8vyJ+ST2ynEDTTpCBANZUUSCW8szS5dZVHN8USm uI94fscPjGJ9ATfi5b+n4d0MjMiWmmNRZQcNovMkb904MxHBRvYqkNGszIgZ+E/qfaG+6k utEqw/Qk/adY+M3DZ6a6CU1qdZXGuE8= 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-630-9QAEfIjLNlqpWAgOSP4c3w-1; Fri, 04 Nov 2022 04:03:52 -0400 X-MC-Unique: 9QAEfIjLNlqpWAgOSP4c3w-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 8FD9029A9CCC for ; Fri, 4 Nov 2022 08:03:52 +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 DCAECC15995; Fri, 4 Nov 2022 08:03:51 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 4 Nov 2022 09:03:40 +0100 Message-Id: <20221104080342.248001-6-amusil@redhat.com> In-Reply-To: <20221104080342.248001-1-amusil@redhat.com> References: <20221104080342.248001-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 branch-22.06 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 08:03:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1699375 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=bI0rd3Ov; 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 4N3Y703RLhz1yqS for ; Fri, 4 Nov 2022 19:04:12 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id F1CF940C13; Fri, 4 Nov 2022 08:04:09 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org F1CF940C13 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=bI0rd3Ov 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 MacZhBF3Rz5t; Fri, 4 Nov 2022 08:04:06 +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 E513140C1B; Fri, 4 Nov 2022 08:04:04 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org E513140C1B Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B9B19C0091; Fri, 4 Nov 2022 08:03:58 +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 B4227C0032 for ; Fri, 4 Nov 2022 08:03:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 4FFD040C09 for ; Fri, 4 Nov 2022 08:03:57 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 4FFD040C09 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 cPqGijqLTQrS for ; Fri, 4 Nov 2022 08:03:56 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 0A5B140C16 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 0A5B140C16 for ; Fri, 4 Nov 2022 08:03:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667549035; 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=bI0rd3Ovi50VJ6D4L/PHuD/GRz/BseTpjJ/Mne9YHEfjZ87DVFuHt31AoJv9GumedYweiR jbHG1n9+Z/NI3yZALeyjddfI9KhIe0Q55vynx/pSBiwU4bZnt40NTehS/9xptXSRYUOnA5 Q/TCPPskQtaM+cl2BbyapIYE4FGbuAI= 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-463-CbW23DN7M3iarhYFKOEP2w-1; Fri, 04 Nov 2022 04:03:54 -0400 X-MC-Unique: CbW23DN7M3iarhYFKOEP2w-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 D0834811E84 for ; Fri, 4 Nov 2022 08:03:53 +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 07ACEC16932; Fri, 4 Nov 2022 08:03:52 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 4 Nov 2022 09:03:41 +0100 Message-Id: <20221104080342.248001-7-amusil@redhat.com> In-Reply-To: <20221104080342.248001-1-amusil@redhat.com> References: <20221104080342.248001-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 branch-22.06 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 08:03:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1699376 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=ea4YuKCy; 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 4N3Y7613BNz1yqS for ; Fri, 4 Nov 2022 19:04:18 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id AB9C540C81; Fri, 4 Nov 2022 08:04:15 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org AB9C540C81 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=ea4YuKCy 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 MtI81HniZJps; Fri, 4 Nov 2022 08:04:13 +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 F151440C2E; Fri, 4 Nov 2022 08:04:06 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org F151440C2E Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A4D17C007B; Fri, 4 Nov 2022 08:04:03 +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 15068C0080 for ; Fri, 4 Nov 2022 08:04:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id B7B3340C41 for ; Fri, 4 Nov 2022 08:04:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org B7B3340C41 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 vJLi1f4O3A0T for ; Fri, 4 Nov 2022 08:03:59 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 61D7640C28 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 61D7640C28 for ; Fri, 4 Nov 2022 08:03:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667549038; 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=ea4YuKCy0EK/XfqfplrcZQmMFDmMQrOWHdFyRSgDLU4q6bbf/cJwLtxf/h/yALgQMtUXj8 K9PmH9oSKRidqd1C47KloPeUrraiXvxYRiWSkfdKbZ5P8b2xAjox1F7H5epDdSMZPnGQ2x y7T/UtuzKRRRP7a0HSXX7PiUOeZwJHE= 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-333-kJ0ZjmxlN0K2Z-dmuc_p0g-1; Fri, 04 Nov 2022 04:03:55 -0400 X-MC-Unique: kJ0ZjmxlN0K2Z-dmuc_p0g-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 0A495811E7A; Fri, 4 Nov 2022 08:03:55 +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 3F4CDC2C8DD; Fri, 4 Nov 2022 08:03:54 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 4 Nov 2022 09:03:42 +0100 Message-Id: <20221104080342.248001-8-amusil@redhat.com> In-Reply-To: <20221104080342.248001-1-amusil@redhat.com> References: <20221104080342.248001-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 branch-22.06 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");