Skip to content

Commit

Permalink
northd: Clean up SB MAC bindings for deleted ports.
Browse files Browse the repository at this point in the history
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: b22684d ("Add a northbound interface to program MAC_Binding table")
Reported-at: https://issues.redhat.com/browse/FDP-723
Signed-off-by: Rosemarie O'Riorden <roriorden@redhat.com>
Acked-by: Ilya Maximets <i.maximets@ovn.org>
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
(cherry picked from commit 417f141)
  • Loading branch information
roseoriorden authored and dceara committed Aug 12, 2024
1 parent b01f3b5 commit 9d1b50e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
9 changes: 8 additions & 1 deletion northd/northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -17142,7 +17142,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 Logical_Router_Port 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,
Expand All @@ -17152,6 +17153,12 @@ build_static_mac_binding_table(
sb_smb->ip);
if (!nb_smb) {
sbrec_static_mac_binding_delete(sb_smb);
continue;
}

struct ovn_port *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);
}
}

Expand Down
13 changes: 13 additions & 0 deletions tests/ovn-northd.at
Original file line number Diff line number Diff line change
Expand Up @@ -7825,6 +7825,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
Expand Down

0 comments on commit 9d1b50e

Please sign in to comment.