From patchwork Fri Aug 9 17:10:37 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: 1971035 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=T4BpEEec; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WgVmW040vz1ybS for ; Sat, 10 Aug 2024 03:10:50 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 57EE7842A1; Fri, 9 Aug 2024 17:10:49 +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 qyXk5ew7XugP; Fri, 9 Aug 2024 17:10:48 +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 smtp1.osuosl.org 257E081BD4 Authentication-Results: smtp1.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=T4BpEEec Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 257E081BD4; Fri, 9 Aug 2024 17:10:48 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D4E9EC0035; Fri, 9 Aug 2024 17:10:47 +0000 (UTC) X-Original-To: ovs-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 32AA9C0033 for ; Fri, 9 Aug 2024 17:10:47 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 2291361356 for ; Fri, 9 Aug 2024 17:10:47 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id I5OYCgIe2-cq for ; Fri, 9 Aug 2024 17:10:46 +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 smtp3.osuosl.org CBDF86058D Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org CBDF86058D Authentication-Results: smtp3.osuosl.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=T4BpEEec 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 CBDF86058D for ; Fri, 9 Aug 2024 17:10:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723223444; 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=SGpDB/JGuKNNoHLRALPjFI+OST8PiCu3N4Vwi2twu40=; b=T4BpEEecuMJRzBUVkMPS5+pzVm3x/gJomVlwRNWTBzQu4qtK+URrjKJQTW94w+WURcGZKn QD2pl0VNCw8qBXruVxXfxCoofIZJhPuzHfYF43TYZIfUpLOMVaVvT4zixL18COhwUfxPxM 3cY2tIn+TUdwP7eBc057sweX53bil/g= 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-284-0xyphEncP4ugOZPjxUbMyw-1; Fri, 09 Aug 2024 13:10:42 -0400 X-MC-Unique: 0xyphEncP4ugOZPjxUbMyw-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 D388A1944D3B; Fri, 9 Aug 2024 17:10:41 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.16.95]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4C58B300018D; Fri, 9 Aug 2024 17:10:40 +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 13:10:37 -0400 Message-ID: <20240809171037.1369742-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 v2] 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 | 9 ++++++++- tests/ovn-northd.at | 13 +++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/northd/northd.c b/northd/northd.c index 0c73e70df..70a9d1984 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, @@ -18346,6 +18347,12 @@ build_static_mac_binding_table( sb_smb->ip); if (!nb_smb) { sbrec_static_mac_binding_delete(sb_smb); + continue; + } + + struct ovn_port *op = op = ovn_port_find(lr_ports, nb_smb->logical_port); + if (!op || !op->nbrp || !op->od || !op->od->sb) { + 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