destroy_nat_entries() iterates over nat_entries using the
number of NAT entries from the NB database. When using I-P,
this behaviour is incorrect as the number of NAT entries in
the NBDB may differ from that stored in 'struct ovn_datapath'
causing unexpected behaviour.

Signed-off-by: Mark Gray <[email protected]>
---
 northd/northd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/northd/northd.c b/northd/northd.c
index 724baa3994d5..829c4479f14b 100644
--- a/northd/northd.c
+++ b/northd/northd.c
@@ -605,6 +605,8 @@ struct ovn_datapath {
 
     /* 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. */
@@ -789,6 +791,7 @@ init_nat_entries(struct ovn_datapath *od)
             od->has_distributed_nat = true;
         }
     }
+    od->n_nat_entries = od->nbr->n_nat;
 }
 
 static void
@@ -802,7 +805,7 @@ destroy_nat_entries(struct ovn_datapath *od)
     destroy_lport_addresses(&od->dnat_force_snat_addrs);
     destroy_lport_addresses(&od->lb_force_snat_addrs);
 
-    for (size_t i = 0; i < od->nbr->n_nat; i++) {
+    for (size_t i = 0; i < od->n_nat_entries; i++) {
         destroy_lport_addresses(&od->nat_entries[i].ext_addrs);
     }
 }
-- 
2.27.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to