Reconfigure dynamic assigned addresses if subnet is modified removing IP out of configured netmask if present
Signed-off-by: Lorenzo Bianconi <[email protected]> --- Changes since v1: - do not remove invalid address in ipam_get_unused_ip() --- northd/ovn-northd.c | 2 +- tests/ovn.at | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index 91da31941..afc9b4e91 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -1793,7 +1793,7 @@ dynamic_ip4_changed(const char *lsp_addrs, } uint32_t index = ip4 - ipam->start_ipv4; - if (index > ipam->total_ipv4s || + if (index >= ipam->total_ipv4s - 1 || bitmap_is_set(ipam->allocated_ipv4s, index)) { /* Previously assigned dynamic IPv4 address can no longer be used. * It's either outside the subnet, conflicts with an excluded IP, diff --git a/tests/ovn.at b/tests/ovn.at index 7769b69ed..f1041bf0b 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -7473,6 +7473,20 @@ AT_CHECK([ovn-nbctl get Logical-Switch-Port p103 dynamic_addresses], [0], ["22:33:44:55:66:77 172.16.1.250" ]) +ovn-nbctl ls-add sw12 +for i in $(seq 0 1); do + for j in $(seq 1 99); do + idx=$((i*100+j)) + ovn-nbctl lsp-add sw12 sw12-p${idx} -- \ + lsp-set-addresses sw12-p${idx} "00:00:00:00:$i:$j dynamic" + done +done +ovn-nbctl set Logical-Switch sw12 other_config:subnet=192.10.2.0/24 +ovn-nbctl set Logical-Switch sw12 other_config:subnet=192.10.2.0/25 +AT_CHECK([ovn-nbctl list Logical-Switch-Port | grep -q 192.10.2.127], [1]) +AT_CHECK([ovn-nbctl list Logical-Switch-Port | grep -q 192.10.2.128], [1]) +AT_CHECK([ovn-nbctl list Logical-Switch-Port | grep -q 192.10.2.180], [1]) + as ovn-sb OVS_APP_EXIT_AND_WAIT([ovsdb-server]) -- 2.26.2 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
