Blob Blame History Raw
From 89502a3b33b1bf407debe5edc6578b2a72afdd5b Mon Sep 17 00:00:00 2001
From: Dumitru Ceara <dceara@redhat.com>
Date: Thu, 8 Oct 2020 15:48:07 +0200
Subject: [PATCH] ovn-northd: Add localnet ports to Multicast_Groups created by
 IGMP_Group.

In case a logical switch is a "bridged logical switch", i.e., it has a
localnet port, add the localnet port to all multicast groups generated
from IGMP_Groups.  This is needed because multicast packets are never
tunneled between hypervisors.

Note: There still exists an issue regarding IP Multicast Relay (routing)
when traffic is received on bridged logical switches connected to
logical routers with mcast_relay=true.  That issue is not addressed
yet but an item is added to TODO.rst to track it.

Reported-at: https://bugzilla.redhat.com/1886103
Fixes: 5d1527b11e94 ("ovn-northd: Add IGMP Relay support")
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Numan Siddique <numans@ovn.org>

(cherry-picked from master commit 97778ab3e422ac071faa67f9f477fd54977e9c04)

(cherry picked from upstream commit a2563f623f2c88f78134928a4f40bdd06cc89b02)

Change-Id: I3f251a19317bfb8a3334357604605ccbb054a0f9
---
 TODO.rst            |  8 ++++++++
 northd/ovn-northd.c |  7 +++++++
 tests/ovn.at        | 40 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+)

diff --git a/TODO.rst b/TODO.rst
index 4321630..c158155 100644
--- a/TODO.rst
+++ b/TODO.rst
@@ -152,3 +152,11 @@ OVN To-do List
   <Logical_Datapath.tunnel_key_NB-Port_Group.name>. This causes an additional
   hashtable lookup in parse_port_group() which can be avoided when we are sure
   that the Southbound DB uses the new format.
+
+* IP Multicast Relay
+
+  * When connecting bridged logical switches (localnet) to logical routers
+    with IP Multicast Relay enabled packets might get duplicated. We need
+    to find a way of determining if routing has already been executed (on a
+    different hypervisor) for the IP multicast packet being processed locally
+    in the router pipeline.
diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
index 3a00c8a..c7ca0f8 100644
--- a/northd/ovn-northd.c
+++ b/northd/ovn-northd.c
@@ -4095,6 +4095,13 @@ ovn_igmp_group_aggregate_ports(struct ovn_igmp_group *igmp_group,
         ovn_igmp_group_destroy_entry(entry);
         free(entry);
     }
+
+    if (igmp_group->datapath->n_localnet_ports) {
+        ovn_multicast_add_ports(mcast_groups, igmp_group->datapath,
+                                &igmp_group->mcgroup,
+                                igmp_group->datapath->localnet_ports,
+                                igmp_group->datapath->n_localnet_ports);
+    }
 }
 
 static void
diff --git a/tests/ovn.at b/tests/ovn.at
index 7769b69..4c6adf2 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -16650,6 +16650,7 @@ ovn_start
 #   - subnet 30.0.0.0/8
 #   - 1 port bound on hv1 (sw3-p1)
 #   - 1 port bound on hv2 (sw3-p2)
+#   - 1 localnet port (sw3-ln)
 
 reset_pcap_file() {
     local iface=$1
@@ -16776,6 +16777,9 @@ ovn-nbctl lsp-add sw2 sw2-p1
 ovn-nbctl lsp-add sw2 sw2-p2
 ovn-nbctl lsp-add sw3 sw3-p1
 ovn-nbctl lsp-add sw3 sw3-p2
+ovn-nbctl lsp-add sw3 sw3-ln                    \
+    -- lsp-set-type sw3-ln localnet             \
+    -- lsp-set-options sw3-ln network_name=phys
 
 ovn-nbctl lr-add rtr
 ovn-nbctl lrp-add rtr rtr-sw1 00:00:00:00:01:00 10.0.0.254/24
@@ -16820,6 +16824,7 @@ ovs-vsctl -- add-port br-int hv1-vif4 -- \
     options:tx_pcap=hv1/vif4-tx.pcap \
     options:rxq_pcap=hv1/vif4-rx.pcap \
     ofport-request=1
+ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys
 
 sim_add hv2
 as hv2
@@ -16845,6 +16850,7 @@ ovs-vsctl -- add-port br-int hv2-vif4 -- \
     options:tx_pcap=hv2/vif4-tx.pcap \
     options:rxq_pcap=hv2/vif4-rx.pcap \
     ofport-request=1
+ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys
 
 OVN_POPULATE_ARP
 
@@ -17128,6 +17134,18 @@ store_ip_multicast_pkt \
     $(ip_to_hex 10 0 0 42) $(ip_to_hex 239 0 1 68) 1e 20 ca70 11 \
     e518e518000a3b3a0000 expected_switched
 
+# TODO: IGMP Relay duplicates IP multicast packets in some conditions, for
+# more details see TODO.rst, section "IP Multicast Relay". Once that issue is
+# fixed the duplicated packets should not appear anymore.
+store_ip_multicast_pkt \
+    000000000100 01005e000144 \
+    $(ip_to_hex 10 0 0 42) $(ip_to_hex 239 0 1 68) 1e 1f cb70 11 \
+    e518e518000a3b3a0000 expected_routed_sw1
+store_ip_multicast_pkt \
+    000000000200 01005e000144 \
+    $(ip_to_hex 10 0 0 42) $(ip_to_hex 239 0 1 68) 1e 1f cb70 11 \
+    e518e518000a3b3a0000 expected_routed_sw2
+
 OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [expected_routed_sw1])
 OVN_CHECK_PACKETS([hv2/vif3-tx.pcap], [expected_routed_sw2])
 OVN_CHECK_PACKETS([hv1/vif4-tx.pcap], [expected_switched])
@@ -17275,6 +17293,7 @@ ovn_start
 #   - subnet 30::/64
 #   - 1 port bound on hv1 (sw3-p1)
 #   - 1 port bound on hv2 (sw3-p2)
+#   - 1 localnet port (sw3-ln)
 
 reset_pcap_file() {
     local iface=$1
@@ -17400,6 +17419,9 @@ ovn-nbctl lsp-add sw2 sw2-p1
 ovn-nbctl lsp-add sw2 sw2-p2
 ovn-nbctl lsp-add sw3 sw3-p1
 ovn-nbctl lsp-add sw3 sw3-p2
+ovn-nbctl lsp-add sw3 sw3-ln                    \
+    -- lsp-set-type sw3-ln localnet             \
+    -- lsp-set-options sw3-ln network_name=phys
 
 ovn-nbctl lr-add rtr
 ovn-nbctl lrp-add rtr rtr-sw1 00:00:00:00:01:00 10::fe/64
@@ -17459,6 +17481,7 @@ ovs-vsctl -- add-port br-int hv1-vif4 -- \
     options:tx_pcap=hv1/vif4-tx.pcap \
     options:rxq_pcap=hv1/vif4-rx.pcap \
     ofport-request=1
+ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys
 
 sim_add hv2
 as hv2
@@ -17484,6 +17507,7 @@ ovs-vsctl -- add-port br-int hv2-vif4 -- \
     options:tx_pcap=hv2/vif4-tx.pcap \
     options:rxq_pcap=hv2/vif4-rx.pcap \
     ofport-request=1
+ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys
 
 OVN_POPULATE_ARP
 
@@ -17794,6 +17818,22 @@ store_ip_multicast_pkt \
     93407a69000e1b5e61736461640a \
     expected_switched
 
+# TODO: MLD Relay duplicates IP multicast packets in some conditions, for
+# more details see TODO.rst, section "IP Multicast Relay". Once that issue is
+# fixed the duplicated packets should not appear anymore.
+store_ip_multicast_pkt \
+    000000000100 333300000001 \
+    10000000000000000000000000000042 ff0adeadbeef00000000000000000001 \
+    000e 01 11 \
+    93407a69000e1b5e61736461640a \
+    expected_routed_sw1
+store_ip_multicast_pkt \
+    000000000200 333300000001 \
+    10000000000000000000000000000042 ff0adeadbeef00000000000000000001 \
+    000e 01 11 \
+    93407a69000e1b5e61736461640a \
+    expected_routed_sw2
+
 OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [expected_routed_sw1])
 OVN_CHECK_PACKETS([hv2/vif3-tx.pcap], [expected_routed_sw2])
 OVN_CHECK_PACKETS([hv1/vif4-tx.pcap], [expected_switched])
-- 
1.8.3.1