[ovs-dev,v2] OVN: add selected mac address to MACAM in update_dynamic_addresses
diff mbox series

Message ID 0ba13b09d674673c042a629452ae78fddb6bfb0f.1542813399.git.lorenzo.bianconi@redhat.com
State Accepted
Headers show
Series
  • [ovs-dev,v2] OVN: add selected mac address to MACAM in update_dynamic_addresses
Related show

Commit Message

Lorenzo Bianconi Nov. 21, 2018, 4:03 p.m. UTC
Add selected dynamic mac address to MACAM in update_dynamic_addresses
and not just in in ipam_add_port_addresses/ipam_insert_lsp_addresses
since the second approach can produce a duplicated L2 address in a
IPv6-only network if ipv6_prefix is provided after logical port creation.
The issue can be triggered with the following reproducer:

$ovn-nbctl ls-add sw0
$ovn-nbctl lsp-add sw0 sw0-port1
$ovn-nbctl lsp-set-addresses sw0-port1 "dynamic"
$ovn-nbctl lsp-add sw0 sw0-port2
$ovn-nbctl lsp-set-addresses sw0-port2 "dynamic"
$ovs-vsctl add-port br-int p1 -- \
    set Interface p1 external_ids:iface-id=sw0-port1
$ovs-vsctl add-port br-int p2 -- \
    set Interface p2 external_ids:iface-id=sw0-port2
[..]
$ovn-nbctl --wait=sb set Logical-switch sw0 \
    other_config:ipv6_prefix="aef0::"

$ovn-nbctl list logical_switch_port
_uuid               : 1e0e2ed8-20c6-48dc-bfa8-d823e48c9f45
addresses           : [dynamic]
dhcpv4_options      : []
dhcpv6_options      : []
dynamic_addresses   : "0a:00:00:00:00:01 aef0::800:ff:fe00:1"
enabled             : []
external_ids        : {}
name                : "sw0-port1"
options             : {}
parent_name         : []
port_security       : []
tag                 : []
tag_request         : []
type                : ""
up                  : true

_uuid               : cfeab7fb-e20b-41f1-974c-f99e0b5293d7
addresses           : [dynamic]
dhcpv4_options      : []
dhcpv6_options      : []
dynamic_addresses   : "0a:00:00:00:00:01 aef0::800:ff:fe00:1"
enabled             : []
external_ids        : {}
name                : "sw0-port2"
options             : {}
parent_name         : []
port_security       : []
tag                 : []
tag_request         : []
type                : ""
up                  : true

Fixes: c814545b43ac ("OVN: configure L2 address according to the used IP
address")

Acked-by: Mark Michelson <mmichels@redhat.com>
Acked-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
Changes since v1:
- add automatic test support
---
 ovn/northd/ovn-northd.c |  2 ++
 tests/ovn.at            | 13 +++++++++++++
 2 files changed, 15 insertions(+)

Comments

Ben Pfaff Dec. 12, 2018, 8:03 p.m. UTC | #1
On Wed, Nov 21, 2018 at 05:03:39PM +0100, Lorenzo Bianconi wrote:
> Add selected dynamic mac address to MACAM in update_dynamic_addresses
> and not just in in ipam_add_port_addresses/ipam_insert_lsp_addresses
> since the second approach can produce a duplicated L2 address in a
> IPv6-only network if ipv6_prefix is provided after logical port creation.

I applied this to master.  Thank you!

Patch
diff mbox series

diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index 58bef7de5..4580cd705 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -1341,6 +1341,8 @@  update_dynamic_addresses(struct dynamic_address_update *update)
 
     struct ds new_addr = DS_EMPTY_INITIALIZER;
     ds_put_format(&new_addr, ETH_ADDR_FMT, ETH_ADDR_ARGS(mac));
+    ipam_insert_mac(&mac, true);
+
     if (ip4) {
         ipam_insert_ip(update->od, ntohl(ip4));
         ds_put_format(&new_addr, " "IP_FMT, IP_ARGS(ip4));
diff --git a/tests/ovn.at b/tests/ovn.at
index ab32faa6b..2e0b81ecf 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -5633,6 +5633,19 @@  AT_CHECK([ovn-nbctl get Logical-Switch-Port p53 dynamic_addresses], [0],
     ["00:11:22:a8:64:05 192.168.100.4"
 ])
 
+# verify configuration order does not break IPAM/MACAM
+ovn-nbctl ls-add sw7
+for n in $(seq 1 3); do
+    ovn-nbctl --wait=sb lsp-add sw7 "p7$n" -- lsp-set-addresses "p7$n" dynamic
+done
+ovn-nbctl --wait=sb set Logical-Switch sw7 other_config:ipv6_prefix="bef0::"
+p71_addr=$(ovn-nbctl get Logical-Switch-Port p71 dynamic_addresses)
+p72_addr=$(ovn-nbctl get Logical-Switch-Port p72 dynamic_addresses)
+p73_addr=$(ovn-nbctl get Logical-Switch-Port p73 dynamic_addresses)
+AT_CHECK([test "$p71_addr" != "$p72_addr"], [0], [])
+AT_CHECK([test "$p71_addr" != "$p73_addr"], [0], [])
+AT_CHECK([test "$p72_addr" != "$p73_addr"], [0], [])
+
 as ovn-sb
 OVS_APP_EXIT_AND_WAIT([ovsdb-server])