summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMark Michelson <mmichels@redhat.com>2018-08-02 08:52:56 -0400
committerBen Pfaff <blp@ovn.org>2018-08-02 12:52:14 -0700
commit451624fe113151253ac49e3a7c4fa7287e65663e (patch)
tree45256e54f976fef006086ed2440fab685be6e16e /tests
parent4d0214a365aeb28c369c6395fa4dfd8c8bed9afa (diff)
downloadopenvswitch-451624fe113151253ac49e3a7c4fa7287e65663e.tar.gz
ovn: Allow for automatic dynamic updates of IPAM
OVN offers a method of IP address management that allows for an IPv4 subnet or IPv6 prefix to be specified on a logical switch. Then by specifying a switch port's address as "dynamic" or "<mac address> dynamic", OVN will automatically assign addresses to the switch port. While this works great for initial assignment of addresses, addresses do not automatically adjust when changes are made to the switch's configuration. For instance: * If the subnet, ipv6_prefix, or exclude_ips for a logical switch changes, the affected switch ports are not updated. * If a switch port with a static IP address is added to the switch, and that address conflicts with a dynamically assigned IP address, the dynamic address is not updated. * If a MAC address switched from being statically assigned to dynamically assigned, the MAC address would not be updated. * If a statically assigned MAC address changed, then the IPv6 address would not be updated. This patch solves all of the above issues by changing the algorithm for IPAM assignment. There are essentially three steps. 1) While joining logical ports, all statically-assigned addresses (i.e. any ports without "dynamic" addresses) have their addresses registered to IPAM. This gives them top priority. 2) All logical ports with dynamic addresses are inspected. Any changes that must be made to the addresses are collected to be made later. Any addresses that do not require change are registered to IPAM. This allows for previously assigned dynamic addresses to be kept. 3) All gathered changes are enacted. The change contains new tests that ensure that dynamic addresses are updated when appropriate. This patch also alters some existing IPAM tests. Those tests assumed that dynamic addresses would not be updated automatically, so those tests either had to be altered or removed. Signed-off-by: Mark Michelson <mmichels@redhat.com> Acked-by: Jakub Sitnicki <jsitnicki@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/ovn.at101
1 files changed, 75 insertions, 26 deletions
diff --git a/tests/ovn.at b/tests/ovn.at
index 1b25b6e4d..8fa2555db 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -5159,7 +5159,7 @@ AT_CHECK([ovn-nbctl get Logical-Switch-Port p19 dynamic_addresses], [0],
# Change a port's address to test for multiple ip's for a single address entry
# and addresses set by the user.
-ovn-nbctl lsp-set-addresses p0 "0a:00:00:00:00:15 192.168.1.12 192.168.1.14"
+ovn-nbctl lsp-set-addresses p0 "0a:00:00:00:00:15 192.168.1.2 192.168.1.12 192.168.1.14"
ovn-nbctl --wait=sb lsp-add sw0 p20 -- lsp-set-addresses p20 dynamic
AT_CHECK([ovn-nbctl get Logical-Switch-Port p20 dynamic_addresses], [0],
["0a:00:00:00:00:16 192.168.1.13"
@@ -5227,7 +5227,6 @@ AT_CHECK([ovn-nbctl get Logical-Switch-Port p31 dynamic_addresses], [0],
# Update the static MAC address with dynamically allocated IP and check
# if the MAC address is updated in 'Logical_Switch_Port.dynamic_adddresses'
ovn-nbctl --wait=sb lsp-set-addresses p31 "fe:dc:ba:98:76:55 dynamic"
-ovn-nbctl get Logical-Switch-Port p31 dynamic_addresses
AT_CHECK([ovn-nbctl get Logical-Switch-Port p31 dynamic_addresses], [0],
["fe:dc:ba:98:76:55 192.168.1.18"
@@ -5235,7 +5234,7 @@ AT_CHECK([ovn-nbctl get Logical-Switch-Port p31 dynamic_addresses], [0],
ovn-nbctl --wait=sb lsp-set-addresses p31 "dynamic"
AT_CHECK([ovn-nbctl get Logical-Switch-Port p31 dynamic_addresses], [0],
- ["fe:dc:ba:98:76:55 192.168.1.18"
+ ["0a:00:00:00:00:21 192.168.1.18"
])
ovn-nbctl --wait=sb lsp-set-addresses p31 "fe:dc:ba:98:76:56 dynamic"
@@ -5252,21 +5251,21 @@ ovn-nbctl --wait=sb lsp-add sw0 p32 -- lsp-set-addresses p32 \
"dynamic"
# 192.168.1.20 should be assigned as 192.168.1.19 is excluded.
AT_CHECK([ovn-nbctl get Logical-Switch-Port p32 dynamic_addresses], [0],
- ["0a:00:00:00:00:21 192.168.1.20"
+ ["0a:00:00:00:00:22 192.168.1.20"
])
ovn-nbctl --wait=sb lsp-add sw0 p33 -- lsp-set-addresses p33 \
"dynamic"
# 192.168.1.22 should be assigned as 192.168.1.21 is excluded.
AT_CHECK([ovn-nbctl get Logical-Switch-Port p33 dynamic_addresses], [0],
- ["0a:00:00:00:00:22 192.168.1.22"
+ ["0a:00:00:00:00:23 192.168.1.22"
])
ovn-nbctl --wait=sb lsp-add sw0 p34 -- lsp-set-addresses p34 \
"dynamic"
# 192.168.1.51 should be assigned as 192.168.1.23-192.168.1.50 is excluded.
AT_CHECK([ovn-nbctl get Logical-Switch-Port p34 dynamic_addresses], [0],
- ["0a:00:00:00:00:23 192.168.1.51"
+ ["0a:00:00:00:00:24 192.168.1.51"
])
# Now clear the exclude_ips list. 192.168.1.19 should be assigned.
@@ -5274,7 +5273,7 @@ ovn-nbctl --wait=sb set Logical-switch sw0 other_config:exclude_ips="invalid"
ovn-nbctl --wait=sb lsp-add sw0 p35 -- lsp-set-addresses p35 \
"dynamic"
AT_CHECK([ovn-nbctl get Logical-Switch-Port p35 dynamic_addresses], [0],
- ["0a:00:00:00:00:24 192.168.1.19"
+ ["0a:00:00:00:00:25 192.168.1.19"
])
# Set invalid data in exclude_ips list. It should be ignored.
@@ -5283,7 +5282,7 @@ ovn-nbctl --wait=sb lsp-add sw0 p36 -- lsp-set-addresses p36 \
"dynamic"
# 192.168.1.21 should be assigned as that's the next free one.
AT_CHECK([ovn-nbctl get Logical-Switch-Port p36 dynamic_addresses], [0],
- ["0a:00:00:00:00:25 192.168.1.21"
+ ["0a:00:00:00:00:26 192.168.1.21"
])
# Clear the dynamic addresses assignment request.
@@ -5300,16 +5299,17 @@ ovn-nbctl --wait=sb lsp-add sw0 p37 -- lsp-set-addresses p37 \
# With prefix aef0 and mac 0a:00:00:00:00:26, the dynamic IPv6 should be
# - aef0::800:ff:fe00:26 (EUI64)
AT_CHECK([ovn-nbctl get Logical-Switch-Port p37 dynamic_addresses], [0],
- ["0a:00:00:00:00:26 192.168.1.21 aef0::800:ff:fe00:26"
+ ["0a:00:00:00:00:27 192.168.1.21 aef0::800:ff:fe00:27"
])
ovn-nbctl --wait=sb ls-add sw4
-ovn-nbctl --wait=sb set Logical-switch sw4 other_config:ipv6_prefix="bef0::"
+ovn-nbctl --wait=sb set Logical-switch sw4 other_config:ipv6_prefix="bef0::" \
+-- set Logical-switch sw4 other_config:subnet=192.168.2.0/30
ovn-nbctl --wait=sb lsp-add sw4 p38 -- lsp-set-addresses p38 \
"dynamic"
AT_CHECK([ovn-nbctl get Logical-Switch-Port p38 dynamic_addresses], [0],
- ["0a:00:00:00:00:27 bef0::800:ff:fe00:27"
+ ["0a:00:00:00:00:28 192.168.2.2 bef0::800:ff:fe00:28"
])
ovn-nbctl --wait=sb lsp-add sw4 p39 -- lsp-set-addresses p39 \
@@ -5319,29 +5319,78 @@ AT_CHECK([ovn-nbctl get Logical-Switch-Port p39 dynamic_addresses], [0],
["f0:00:00:00:10:12 bef0::f200:ff:fe00:1012"
])
-# Clear the other_config for sw4. No dynamic ip should be assigned.
-ovn-nbctl --wait=sb clear Logical-switch sw4 other_config
+# Test the case where IPv4 addresses are exhausted and IPv6 prefix is set
+# p40 should not have an IPv4 address since the pool is exhausted
ovn-nbctl --wait=sb lsp-add sw4 p40 -- lsp-set-addresses p40 \
"dynamic"
-
AT_CHECK([ovn-nbctl get Logical-Switch-Port p40 dynamic_addresses], [0],
+ ["0a:00:00:00:00:29 bef0::800:ff:fe00:29"
+])
+
+# Test dynamic changes on switch ports.
+#
+ovn-nbctl --wait=sb ls-add sw5
+ovn-nbctl --wait=sb lsp-add sw5 p41 -- lsp-set-addresses p41 \
+"dynamic"
+# p41 will start with nothing
+AT_CHECK([ovn-nbctl get Logical-Switch-Port p41 dynamic_addresses], [0],
[[[]]
])
-# Test the case where IPv4 addresses are exhausted and IPv6 prefix is set
-ovn-nbctl --wait=sb set Logical-switch sw4 other_config:subnet=192.168.2.0/30 \
--- set Logical-switch sw4 other_config:ipv6_prefix="bef0::"
+# Set a subnet. Now p41 should have an ipv4 address, too
+ovn-nbctl --wait=sb add Logical-Switch sw5 other_config subnet=192.168.1.0/24
+AT_CHECK([ovn-nbctl get Logical-Switch-Port p41 dynamic_addresses], [0],
+ ["0a:00:00:00:00:2a 192.168.1.2"
+])
-# Now p40 should be assigned with dynamic addresses.
-AT_CHECK([ovn-nbctl get Logical-Switch-Port p40 dynamic_addresses], [0],
- ["0a:00:00:00:00:28 192.168.2.2 bef0::800:ff:fe00:28"
+# Clear the other_config. The IPv4 address should be gone
+ovn-nbctl --wait=sb clear Logical-Switch sw5 other_config
+AT_CHECK([ovn-nbctl get Logical-Switch-Port p41 dynamic_addresses], [0],
+ [[[]]
])
-ovn-nbctl --wait=sb lsp-add sw4 p41 -- lsp-set-addresses p41 \
-"dynamic"
-# p41 should not have IPv4 address (as the pool is exhausted).
+# Set an IPv6 prefix. Now p41 should have an IPv6 address.
+ovn-nbctl --wait=sb set Logical-Switch sw5 other_config:ipv6_prefix="aef0::"
AT_CHECK([ovn-nbctl get Logical-Switch-Port p41 dynamic_addresses], [0],
- ["0a:00:00:00:00:29 bef0::800:ff:fe00:29"
+ ["0a:00:00:00:00:2b aef0::800:ff:fe00:2b"
+])
+
+# Change the MAC address to a static one. The IPv6 address should update.
+ovn-nbctl --wait=sb lsp-set-addresses p41 "f0:00:00:00:10:2b dynamic"
+AT_CHECK([ovn-nbctl get Logical-Switch-Port p41 dynamic_addresses], [0],
+ ["f0:00:00:00:10:2b aef0::f200:ff:fe00:102b"
+])
+
+# Change the IPv6 prefix. The IPv6 address should update.
+ovn-nbctl --wait=sb set Logical-Switch sw5 other_config:ipv6_prefix="bef0::"
+AT_CHECK([ovn-nbctl get Logical-Switch-Port p41 dynamic_addresses], [0],
+ ["f0:00:00:00:10:2b bef0::f200:ff:fe00:102b"
+])
+
+# Clear the other_config. The IPv6 address should be gone
+ovn-nbctl --wait=sb clear Logical-Switch sw5 other_config
+AT_CHECK([ovn-nbctl get Logical-Switch-Port p41 dynamic_addresses], [0],
+ [[[]]
+])
+
+# Set the subnet again. Now p41 should get the IPv4 address again.
+ovn-nbctl --wait=sb add Logical-Switch sw5 other_config subnet=192.168.1.0/24
+AT_CHECK([ovn-nbctl get Logical-Switch-Port p41 dynamic_addresses], [0],
+ ["f0:00:00:00:10:2b 192.168.1.2"
+])
+
+# Add another port with a conflicting static IPv4 address. p41 should update.
+ovn-nbctl --wait=sb lsp-add sw5 p42 -- lsp-set-addresses p42 \
+"f0:00:00:00:10:2c 192.168.1.2"
+AT_CHECK([ovn-nbctl get Logical-Switch-Port p41 dynamic_addresses], [0],
+ ["f0:00:00:00:10:2b 192.168.1.3"
+])
+
+# Add an excluded IP address that conflicts with p41. p41 should update.
+ovn-nbctl --wait=sb add Logical-Switch sw5 other_config \
+exclude_ips="192.168.1.3"
+AT_CHECK([ovn-nbctl get Logical-Switch-Port p41 dynamic_addresses], [0],
+ ["f0:00:00:00:10:2b 192.168.1.4"
])
as ovn-sb
@@ -10361,10 +10410,10 @@ ovn-nbctl set Logical_Switch ls1 \
dnl Check if updated address got propagated to the port group address sets
AT_CHECK([ovn-sbctl get Address_Set pg1_ip4 addresses],
- [0], [[["10.1.0.2", "10.2.0.2"]]
+ [0], [[["10.11.0.2", "10.2.0.2"]]
])
AT_CHECK([ovn-sbctl get Address_Set pg1_ip6 addresses],
- [0], [[["2001:db8:1::ff:fe00:1", "2001:db8:2::ff:fe00:2"]]
+ [0], [[["2001:db8:11::ff:fe00:1", "2001:db8:2::ff:fe00:2"]]
])
AT_CLEANUP