From patchwork Fri Aug 9 13:25:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosemarie O'Riorden X-Patchwork-Id: 1970949 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=i5kYdZ0K; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WgPnP34CRz1ybS for ; Fri, 9 Aug 2024 23:26:17 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 344A54043C; Fri, 9 Aug 2024 13:26:15 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id oY-TX9CQkqC3; Fri, 9 Aug 2024 13:26:14 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org C3F8D40BD8 Authentication-Results: smtp2.osuosl.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=i5kYdZ0K Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id C3F8D40BD8; Fri, 9 Aug 2024 13:26:13 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 18AB2C0035; Fri, 9 Aug 2024 13:26:13 +0000 (UTC) X-Original-To: ovs-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 66D43C0033 for ; Fri, 9 Aug 2024 13:26:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 49C4B81BC5 for ; Fri, 9 Aug 2024 13:26:12 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 5Vj4peWoPgbC for ; Fri, 9 Aug 2024 13:26:11 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=roriorden@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org E6EC081B36 Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org E6EC081B36 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=i5kYdZ0K 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 E6EC081B36 for ; Fri, 9 Aug 2024 13:26:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723209969; 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=tkzVQjWtDJw1BOcM2jSyBIPxvVxT483FbtjyvWZvdOM=; b=i5kYdZ0KhP6d3yTA2pbsvoSMaoMbsadRH30EywK5vQMYwyYwtqQvllUbpgc0HijsMLCdi1 /bF8HAnPWyIbPs9QtixLMNPVOP8tPrZ72kQWXk6i/wKBLuvkWCgHEpS070rzmtmr6Avjsd 05sFhLZdabcIIhoaEjCB4QRdJsjqaO0= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-288-Jw8k7qtqO6GzQAq42X6ehA-1; Fri, 09 Aug 2024 09:26:06 -0400 X-MC-Unique: Jw8k7qtqO6GzQAq42X6ehA-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 05D4F1977455; Fri, 9 Aug 2024 13:26:05 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.9.44]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BA0013000710; Fri, 9 Aug 2024 13:26:02 +0000 (UTC) From: Rosemarie O'Riorden To: ovs-dev@openvswitch.org Cc: roriorden@redhat.com, dceara@redhat.com, i.maximets@ovn.org Date: Fri, 9 Aug 2024 09:25:59 -0400 Message-ID: <20240809132559.939657-1-roriorden@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn] northd: Clean up SB MAC bindings for deleted ports. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Static_MAC_Binding (SMB) records are only deleted from the southbound-db via ovn-northd when there is no such SMB found in the northbound-db. This leads to problems when a port becomes stale (ex. through lr deletion), because the Logical_Router and Logical_Router_Port records are removed from the nb-db, but not the Static_MAC_Binding record. So, when ovn-northd attempts to remove the corresponding Datapath_Binding and Port_Binding records from sb-db, it fails because of a referential integrity violation: the Static_MAC_Binding record contains a reference to Datapath_Binding. The corrected behavior is that SMB's are now deleted: 1. when there's no such SMB in the nb-db, and 2. when there is no port in the nb-db with the SMB's associated port name. Thus, all three records, Datapath_Binding, Port_Binding, and Static_MAC_Binding, are removed within the same transaction. Also added a unit test to verify correct behavior. Fixes: b22684d4e37c ("Add a northbound interface to program MAC_Binding table") Reported-at: https://issues.redhat.com/browse/FDP-723 Signed-off-by: Rosemarie O'Riorden --- northd/northd.c | 14 ++++++++++++-- tests/ovn-northd.at | 13 +++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/northd/northd.c b/northd/northd.c index 0c73e70df..15c15a4c2 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -18336,7 +18336,8 @@ build_static_mac_binding_table( struct hmap *lr_ports) { /* Cleanup SB Static_MAC_Binding entries which do not have corresponding - * NB Static_MAC_Binding entries. */ + * NB Static_MAC_Binding entries, and SB Static_MAC_Binding entries for + * which there is not a NB Port_Binding of the same name. */ const struct nbrec_static_mac_binding *nb_smb; const struct sbrec_static_mac_binding *sb_smb; SBREC_STATIC_MAC_BINDING_TABLE_FOR_EACH_SAFE (sb_smb, @@ -18344,7 +18345,16 @@ build_static_mac_binding_table( nb_smb = static_mac_binding_by_port_ip(nbrec_static_mb_table, sb_smb->logical_port, sb_smb->ip); - if (!nb_smb) { + struct ovn_port *op = NULL; + struct ovn_datapath *od = NULL; + if (nb_smb) { + op = ovn_port_find(lr_ports, nb_smb->logical_port); + if (op) { + od = op->od; + } + } + bool delete_smb = !nb_smb || !op || !op->nbrp || !od || !od->sb; + if (delete_smb) { sbrec_static_mac_binding_delete(sb_smb); } } diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at index f2f42275a..8d0ac6c3c 100644 --- a/tests/ovn-northd.at +++ b/tests/ovn-northd.at @@ -8080,6 +8080,19 @@ wait_row_count Static_MAC_Binding 1 logical_port=lr0-p0 ip=192.168.10.100 mac="0 AT_CLEANUP ]) +OVN_FOR_EACH_NORTHD_NO_HV([ +AT_SETUP([LR NB Static_MAC_Binding garbage collection]) +ovn_start + +check ovn-nbctl lr-add lr -- lrp-add lr lr-lrp 00:00:00:00:00:01 1.1.1.1/24 +check ovn-nbctl static-mac-binding-add lr-lrp 1.1.1.2 00:00:00:00:00:02 +wait_row_count sb:Static_MAC_Binding 1 logical_port=lr-lrp ip=1.1.1.2 mac="00\:00\:00\:00\:00\:02" +check ovn-nbctl lr-del lr +wait_row_count sb:Static_MAC_Binding 0 + +AT_CLEANUP +]) + OVN_FOR_EACH_NORTHD_NO_HV([ AT_SETUP([LR neighbor lookup and learning flows]) ovn_start