|
|
bbaaef |
From 3dde59a7b7f0bb634fa5943b185b1cf1d4ed6907 Mon Sep 17 00:00:00 2001
|
|
|
bbaaef |
Message-Id: <3dde59a7b7f0bb634fa5943b185b1cf1d4ed6907.1594372314.git.lorenzo.bianconi@redhat.com>
|
|
|
bbaaef |
From: Mark Michelson <mmichels@redhat.com>
|
|
|
bbaaef |
Date: Tue, 2 Jun 2020 09:06:32 -0400
|
|
|
bbaaef |
Subject: [PATCH] northd: Fix IPAM IPv4 start address calculation.
|
|
|
bbaaef |
|
|
|
bbaaef |
IPAM assumes the other_config:subnet of the logical switch is a network
|
|
|
bbaaef |
address, which can result in unusual address assignments.
|
|
|
bbaaef |
|
|
|
bbaaef |
As an example, consider the following configuration:
|
|
|
bbaaef |
|
|
|
bbaaef |
ovn-nbctl set logical_switch ls other_config:subnet=172.16.1.254/29
|
|
|
bbaaef |
|
|
|
bbaaef |
172.16.1.254 is not a network address of a /29 network, but ovn-northd
|
|
|
bbaaef |
doesn't care. ovn-northd starts IP address allocation at 172.16.1.254, with 7
|
|
|
bbaaef |
assignable addresses in the subnet. The first address (172.16.1.255) is
|
|
|
bbaaef |
reserved for router port use. The first IP addresses to a logical switch
|
|
|
bbaaef |
port is 172.16.2.0, then 172.16.2.1, and so on.
|
|
|
bbaaef |
|
|
|
bbaaef |
This patch changes the behavior by using the provided netmask to change
|
|
|
bbaaef |
the starting IP address to the network address of the subnet. In the
|
|
|
bbaaef |
previous example, the provided 172.16.1.254/29 would be converted
|
|
|
bbaaef |
internally to 172.16.1.248/29 . Therefore, the first IP address
|
|
|
bbaaef |
allocated to a switch port would be 172.16.1.250. Further allocations would
|
|
|
bbaaef |
continue up until 172.16.1.254.
|
|
|
bbaaef |
|
|
|
bbaaef |
Reported at: https://bugzilla.redhat.com/show_bug.cgi?id=1823287
|
|
|
bbaaef |
|
|
|
bbaaef |
Acked-by: Numan Siddique <numans@ovn.org>
|
|
|
bbaaef |
Signed-off-by: Mark Michelson <mmichels@redhat.com>
|
|
|
bbaaef |
Signed-off-by: Numan Siddique <numans@ovn.org>
|
|
|
bbaaef |
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
|
|
|
bbaaef |
---
|
|
|
bbaaef |
ovn/northd/ovn-northd.c | 2 +-
|
|
|
bbaaef |
tests/ovn.at | 11 +++++++++++
|
|
|
bbaaef |
2 files changed, 12 insertions(+), 1 deletion(-)
|
|
|
bbaaef |
|
|
|
bbaaef |
--- a/ovn/northd/ovn-northd.c
|
|
|
bbaaef |
+++ b/ovn/northd/ovn-northd.c
|
|
|
bbaaef |
@@ -764,7 +764,7 @@ init_ipam_info_for_datapath(struct ovn_d
|
|
|
bbaaef |
return;
|
|
|
bbaaef |
}
|
|
|
bbaaef |
|
|
|
bbaaef |
- od->ipam_info.start_ipv4 = ntohl(subnet) + 1;
|
|
|
bbaaef |
+ od->ipam_info.start_ipv4 = ntohl(subnet & mask) + 1;
|
|
|
bbaaef |
od->ipam_info.total_ipv4s = ~ntohl(mask);
|
|
|
bbaaef |
od->ipam_info.allocated_ipv4s =
|
|
|
bbaaef |
bitmap_allocate(od->ipam_info.total_ipv4s);
|
|
|
bbaaef |
--- a/tests/ovn.at
|
|
|
bbaaef |
+++ b/tests/ovn.at
|
|
|
bbaaef |
@@ -6636,6 +6636,17 @@ AT_CHECK([ovn-nbctl get Logical-Switch-P
|
|
|
bbaaef |
["00:11:22:a8:6e:0b 192.168.110.10 ae01::2"
|
|
|
bbaaef |
])
|
|
|
bbaaef |
|
|
|
bbaaef |
+# Configure subnet using address from middle of the subnet and ensure
|
|
|
bbaaef |
+# address is allocated from the beginning.
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+ovn-nbctl ls-add sw11
|
|
|
bbaaef |
+ovn-nbctl --wait=sb set Logical-Switch sw11 other_config:subnet=172.16.1.254/29
|
|
|
bbaaef |
+ovn-nbctl --wait=sb lsp-add sw11 p103 -- lsp-set-addresses p103 "22:33:44:55:66:77 dynamic"
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+AT_CHECK([ovn-nbctl get Logical-Switch-Port p103 dynamic_addresses], [0],
|
|
|
bbaaef |
+ ["22:33:44:55:66:77 172.16.1.250"
|
|
|
bbaaef |
+])
|
|
|
bbaaef |
+
|
|
|
bbaaef |
as ovn-sb
|
|
|
bbaaef |
OVS_APP_EXIT_AND_WAIT([ovsdb-server])
|
|
|
bbaaef |
|