dddd63
From 89502a3b33b1bf407debe5edc6578b2a72afdd5b Mon Sep 17 00:00:00 2001
dddd63
From: Dumitru Ceara <dceara@redhat.com>
dddd63
Date: Thu, 8 Oct 2020 15:48:07 +0200
dddd63
Subject: [PATCH] ovn-northd: Add localnet ports to Multicast_Groups created by
dddd63
 IGMP_Group.
dddd63
dddd63
In case a logical switch is a "bridged logical switch", i.e., it has a
dddd63
localnet port, add the localnet port to all multicast groups generated
dddd63
from IGMP_Groups.  This is needed because multicast packets are never
dddd63
tunneled between hypervisors.
dddd63
dddd63
Note: There still exists an issue regarding IP Multicast Relay (routing)
dddd63
when traffic is received on bridged logical switches connected to
dddd63
logical routers with mcast_relay=true.  That issue is not addressed
dddd63
yet but an item is added to TODO.rst to track it.
dddd63
dddd63
Reported-at: https://bugzilla.redhat.com/1886103
dddd63
Fixes: 5d1527b11e94 ("ovn-northd: Add IGMP Relay support")
dddd63
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
dddd63
Signed-off-by: Numan Siddique <numans@ovn.org>
dddd63
dddd63
(cherry-picked from master commit 97778ab3e422ac071faa67f9f477fd54977e9c04)
dddd63
dddd63
(cherry picked from upstream commit a2563f623f2c88f78134928a4f40bdd06cc89b02)
dddd63
dddd63
Change-Id: I3f251a19317bfb8a3334357604605ccbb054a0f9
dddd63
---
dddd63
 TODO.rst            |  8 ++++++++
dddd63
 northd/ovn-northd.c |  7 +++++++
dddd63
 tests/ovn.at        | 40 ++++++++++++++++++++++++++++++++++++++++
dddd63
 3 files changed, 55 insertions(+)
dddd63
dddd63
diff --git a/TODO.rst b/TODO.rst
dddd63
index 4321630..c158155 100644
dddd63
--- a/TODO.rst
dddd63
+++ b/TODO.rst
dddd63
@@ -152,3 +152,11 @@ OVN To-do List
dddd63
   <Logical_Datapath.tunnel_key_NB-Port_Group.name>. This causes an additional
dddd63
   hashtable lookup in parse_port_group() which can be avoided when we are sure
dddd63
   that the Southbound DB uses the new format.
dddd63
+
dddd63
+* IP Multicast Relay
dddd63
+
dddd63
+  * When connecting bridged logical switches (localnet) to logical routers
dddd63
+    with IP Multicast Relay enabled packets might get duplicated. We need
dddd63
+    to find a way of determining if routing has already been executed (on a
dddd63
+    different hypervisor) for the IP multicast packet being processed locally
dddd63
+    in the router pipeline.
dddd63
diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
dddd63
index 3a00c8a..c7ca0f8 100644
dddd63
--- a/northd/ovn-northd.c
dddd63
+++ b/northd/ovn-northd.c
dddd63
@@ -4095,6 +4095,13 @@ ovn_igmp_group_aggregate_ports(struct ovn_igmp_group *igmp_group,
dddd63
         ovn_igmp_group_destroy_entry(entry);
dddd63
         free(entry);
dddd63
     }
dddd63
+
dddd63
+    if (igmp_group->datapath->n_localnet_ports) {
dddd63
+        ovn_multicast_add_ports(mcast_groups, igmp_group->datapath,
dddd63
+                                &igmp_group->mcgroup,
dddd63
+                                igmp_group->datapath->localnet_ports,
dddd63
+                                igmp_group->datapath->n_localnet_ports);
dddd63
+    }
dddd63
 }
dddd63
 
dddd63
 static void
dddd63
diff --git a/tests/ovn.at b/tests/ovn.at
dddd63
index 7769b69..4c6adf2 100644
dddd63
--- a/tests/ovn.at
dddd63
+++ b/tests/ovn.at
dddd63
@@ -16650,6 +16650,7 @@ ovn_start
dddd63
 #   - subnet 30.0.0.0/8
dddd63
 #   - 1 port bound on hv1 (sw3-p1)
dddd63
 #   - 1 port bound on hv2 (sw3-p2)
dddd63
+#   - 1 localnet port (sw3-ln)
dddd63
 
dddd63
 reset_pcap_file() {
dddd63
     local iface=$1
dddd63
@@ -16776,6 +16777,9 @@ ovn-nbctl lsp-add sw2 sw2-p1
dddd63
 ovn-nbctl lsp-add sw2 sw2-p2
dddd63
 ovn-nbctl lsp-add sw3 sw3-p1
dddd63
 ovn-nbctl lsp-add sw3 sw3-p2
dddd63
+ovn-nbctl lsp-add sw3 sw3-ln                    \
dddd63
+    -- lsp-set-type sw3-ln localnet             \
dddd63
+    -- lsp-set-options sw3-ln network_name=phys
dddd63
 
dddd63
 ovn-nbctl lr-add rtr
dddd63
 ovn-nbctl lrp-add rtr rtr-sw1 00:00:00:00:01:00 10.0.0.254/24
dddd63
@@ -16820,6 +16824,7 @@ ovs-vsctl -- add-port br-int hv1-vif4 -- \
dddd63
     options:tx_pcap=hv1/vif4-tx.pcap \
dddd63
     options:rxq_pcap=hv1/vif4-rx.pcap \
dddd63
     ofport-request=1
dddd63
+ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys
dddd63
 
dddd63
 sim_add hv2
dddd63
 as hv2
dddd63
@@ -16845,6 +16850,7 @@ ovs-vsctl -- add-port br-int hv2-vif4 -- \
dddd63
     options:tx_pcap=hv2/vif4-tx.pcap \
dddd63
     options:rxq_pcap=hv2/vif4-rx.pcap \
dddd63
     ofport-request=1
dddd63
+ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys
dddd63
 
dddd63
 OVN_POPULATE_ARP
dddd63
 
dddd63
@@ -17128,6 +17134,18 @@ store_ip_multicast_pkt \
dddd63
     $(ip_to_hex 10 0 0 42) $(ip_to_hex 239 0 1 68) 1e 20 ca70 11 \
dddd63
     e518e518000a3b3a0000 expected_switched
dddd63
 
dddd63
+# TODO: IGMP Relay duplicates IP multicast packets in some conditions, for
dddd63
+# more details see TODO.rst, section "IP Multicast Relay". Once that issue is
dddd63
+# fixed the duplicated packets should not appear anymore.
dddd63
+store_ip_multicast_pkt \
dddd63
+    000000000100 01005e000144 \
dddd63
+    $(ip_to_hex 10 0 0 42) $(ip_to_hex 239 0 1 68) 1e 1f cb70 11 \
dddd63
+    e518e518000a3b3a0000 expected_routed_sw1
dddd63
+store_ip_multicast_pkt \
dddd63
+    000000000200 01005e000144 \
dddd63
+    $(ip_to_hex 10 0 0 42) $(ip_to_hex 239 0 1 68) 1e 1f cb70 11 \
dddd63
+    e518e518000a3b3a0000 expected_routed_sw2
dddd63
+
dddd63
 OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [expected_routed_sw1])
dddd63
 OVN_CHECK_PACKETS([hv2/vif3-tx.pcap], [expected_routed_sw2])
dddd63
 OVN_CHECK_PACKETS([hv1/vif4-tx.pcap], [expected_switched])
dddd63
@@ -17275,6 +17293,7 @@ ovn_start
dddd63
 #   - subnet 30::/64
dddd63
 #   - 1 port bound on hv1 (sw3-p1)
dddd63
 #   - 1 port bound on hv2 (sw3-p2)
dddd63
+#   - 1 localnet port (sw3-ln)
dddd63
 
dddd63
 reset_pcap_file() {
dddd63
     local iface=$1
dddd63
@@ -17400,6 +17419,9 @@ ovn-nbctl lsp-add sw2 sw2-p1
dddd63
 ovn-nbctl lsp-add sw2 sw2-p2
dddd63
 ovn-nbctl lsp-add sw3 sw3-p1
dddd63
 ovn-nbctl lsp-add sw3 sw3-p2
dddd63
+ovn-nbctl lsp-add sw3 sw3-ln                    \
dddd63
+    -- lsp-set-type sw3-ln localnet             \
dddd63
+    -- lsp-set-options sw3-ln network_name=phys
dddd63
 
dddd63
 ovn-nbctl lr-add rtr
dddd63
 ovn-nbctl lrp-add rtr rtr-sw1 00:00:00:00:01:00 10::fe/64
dddd63
@@ -17459,6 +17481,7 @@ ovs-vsctl -- add-port br-int hv1-vif4 -- \
dddd63
     options:tx_pcap=hv1/vif4-tx.pcap \
dddd63
     options:rxq_pcap=hv1/vif4-rx.pcap \
dddd63
     ofport-request=1
dddd63
+ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys
dddd63
 
dddd63
 sim_add hv2
dddd63
 as hv2
dddd63
@@ -17484,6 +17507,7 @@ ovs-vsctl -- add-port br-int hv2-vif4 -- \
dddd63
     options:tx_pcap=hv2/vif4-tx.pcap \
dddd63
     options:rxq_pcap=hv2/vif4-rx.pcap \
dddd63
     ofport-request=1
dddd63
+ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys
dddd63
 
dddd63
 OVN_POPULATE_ARP
dddd63
 
dddd63
@@ -17794,6 +17818,22 @@ store_ip_multicast_pkt \
dddd63
     93407a69000e1b5e61736461640a \
dddd63
     expected_switched
dddd63
 
dddd63
+# TODO: MLD Relay duplicates IP multicast packets in some conditions, for
dddd63
+# more details see TODO.rst, section "IP Multicast Relay". Once that issue is
dddd63
+# fixed the duplicated packets should not appear anymore.
dddd63
+store_ip_multicast_pkt \
dddd63
+    000000000100 333300000001 \
dddd63
+    10000000000000000000000000000042 ff0adeadbeef00000000000000000001 \
dddd63
+    000e 01 11 \
dddd63
+    93407a69000e1b5e61736461640a \
dddd63
+    expected_routed_sw1
dddd63
+store_ip_multicast_pkt \
dddd63
+    000000000200 333300000001 \
dddd63
+    10000000000000000000000000000042 ff0adeadbeef00000000000000000001 \
dddd63
+    000e 01 11 \
dddd63
+    93407a69000e1b5e61736461640a \
dddd63
+    expected_routed_sw2
dddd63
+
dddd63
 OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [expected_routed_sw1])
dddd63
 OVN_CHECK_PACKETS([hv2/vif3-tx.pcap], [expected_routed_sw2])
dddd63
 OVN_CHECK_PACKETS([hv1/vif4-tx.pcap], [expected_switched])
dddd63
-- 
dddd63
1.8.3.1
dddd63