This patch moves the logic responsible for adding ports to the 'unknown'
multicast group. This logic is now part of the build_mcast_groups()
function.  This not only improves readability but also removes the
unnecessary dependency of mcast_groups from build_lflows().

Signed-off-by: Han Zhou <hz...@ovn.org>
Reviewed-by: Ales Musil <amu...@redhat.com>
---
 northd/northd.c | 73 ++++++++++++++++++-------------------------------
 1 file changed, 27 insertions(+), 46 deletions(-)

diff --git a/northd/northd.c b/northd/northd.c
index 1a4e24978642..196653ad3d0e 100644
--- a/northd/northd.c
+++ b/northd/northd.c
@@ -2587,6 +2587,9 @@ join_logical_ports(const struct sbrec_port_binding_table 
*sbrec_pb_table,
             parse_lsp_addrs(op);
 
             op->od = od;
+            if (op->has_unknown) {
+                od->has_unknown = true;
+            }
             hmap_insert(&od->ports, &op->dp_node,
                         hmap_node_hash(&op->key_node));
             tag_alloc_add_existing_tags(tag_alloc_table, nbsp);
@@ -6235,6 +6238,8 @@ build_lswitch_learn_fdb_od(
     ovs_assert(od->nbs);
     ovn_lflow_add(lflows, od, S_SWITCH_IN_LOOKUP_FDB, 0, "1", "next;");
     ovn_lflow_add(lflows, od, S_SWITCH_IN_PUT_FDB, 0, "1", "next;");
+    ovn_lflow_add(lflows, od, S_SWITCH_IN_L2_LKUP, 0, "1",
+                  "outport = get_fdb(eth.dst); next;");
 }
 
 /* Egress tables 8: Egress port security - IP (priority 0)
@@ -8914,36 +8919,20 @@ is_vlan_transparent(const struct ovn_datapath *od)
 }
 
 static void
-build_lswitch_flows(const struct ovn_datapaths *ls_datapaths,
-                    struct hmap *lflows)
-{
-    /* This flow table structure is documented in ovn-northd(8), so please
-     * update ovn-northd.8.xml if you change anything. */
-
-    struct ovn_datapath *od;
-
-    /* Ingress table 25/26: Destination lookup for unknown MACs
-     * (priority 0). */
-    HMAP_FOR_EACH (od, key_node, &ls_datapaths->datapaths) {
-        if (!od->nbs) {
-            continue;
-        }
-
-        ovn_lflow_add(lflows, od, S_SWITCH_IN_L2_LKUP, 0, "1",
-                      "outport = get_fdb(eth.dst); next;");
-
-        if (od->has_unknown) {
-            ovn_lflow_add(lflows, od, S_SWITCH_IN_L2_UNKNOWN, 50,
-                          "outport == \"none\"",
-                          "outport = \""MC_UNKNOWN "\"; output;");
-        } else {
-            ovn_lflow_add(lflows, od, S_SWITCH_IN_L2_UNKNOWN, 50,
-                          "outport == \"none\"",  debug_drop_action());
-        }
-        ovn_lflow_add(lflows, od, S_SWITCH_IN_L2_UNKNOWN, 0, "1",
-                      "output;");
+build_lswitch_lflows_l2_unknown(struct ovn_datapath *od,
+                                struct hmap *lflows)
+{
+    /* Ingress table 25/26: Destination lookup for unknown MACs. */
+    if (od->has_unknown) {
+        ovn_lflow_add(lflows, od, S_SWITCH_IN_L2_UNKNOWN, 50,
+                      "outport == \"none\"",
+                      "outport = \""MC_UNKNOWN "\"; output;");
+    } else {
+        ovn_lflow_add(lflows, od, S_SWITCH_IN_L2_UNKNOWN, 50,
+                      "outport == \"none\"",  debug_drop_action());
     }
-
+    ovn_lflow_add(lflows, od, S_SWITCH_IN_L2_UNKNOWN, 0, "1",
+                  "output;");
 }
 
 /* Build pre-ACL and ACL tables for both ingress and egress.
@@ -9693,13 +9682,10 @@ build_lswitch_ip_mcast_igmp_mld(struct ovn_igmp_group 
*igmp_group,
     }
 }
 
-static struct ovs_mutex mcgroup_mutex = OVS_MUTEX_INITIALIZER;
-
 /* Ingress table 25: Destination lookup, unicast handling (priority 50), */
 static void
 build_lswitch_ip_unicast_lookup(struct ovn_port *op,
                                 struct hmap *lflows,
-                                struct hmap *mcgroups,
                                 struct ds *actions,
                                 struct ds *match)
 {
@@ -9738,12 +9724,7 @@ build_lswitch_ip_unicast_lookup(struct ovn_port *op,
                                     ds_cstr(actions),
                                     &op->nbsp->header_);
         } else if (!strcmp(op->nbsp->addresses[i], "unknown")) {
-            if (lsp_enabled) {
-                ovs_mutex_lock(&mcgroup_mutex);
-                ovn_multicast_add(mcgroups, &mc_unknown, op);
-                ovs_mutex_unlock(&mcgroup_mutex);
-                op->od->has_unknown = true;
-            }
+            continue;
         } else if (is_dynamic_lsp_address(op->nbsp->addresses[i])) {
             if (!op->nbsp->dynamic_addresses
                 || !ovs_scan(op->nbsp->dynamic_addresses,
@@ -15237,7 +15218,6 @@ struct lswitch_flow_build_info {
     const struct hmap *lr_ports;
     const struct hmap *port_groups;
     struct hmap *lflows;
-    struct hmap *mcgroups;
     struct hmap *igmp_groups;
     const struct shash *meter_groups;
     const struct hmap *lbs;
@@ -15275,6 +15255,7 @@ build_lswitch_and_lrouter_iterate_by_ls(struct 
ovn_datapath *od,
                                             lsi->meter_groups);
     build_lswitch_output_port_sec_od(od, lsi->lflows);
     build_lswitch_lb_affinity_default_flows(od, lsi->lflows);
+    build_lswitch_lflows_l2_unknown(od, lsi->lflows);
 }
 
 /* Helper function to combine all lflow generation which is iterated by
@@ -15336,8 +15317,8 @@ build_lswitch_and_lrouter_iterate_by_lsp(struct 
ovn_port *op,
     build_lswitch_dhcp_options_and_response(op, lsi->lflows,
                                             lsi->meter_groups);
     build_lswitch_external_port(op, lsi->lflows);
-    build_lswitch_ip_unicast_lookup(op, lsi->lflows, lsi->mcgroups,
-                                    &lsi->actions, &lsi->match);
+    build_lswitch_ip_unicast_lookup(op, lsi->lflows, &lsi->actions,
+                                    &lsi->match);
 
     /* Build Logical Router Flows. */
     build_ip_routing_flows_for_router_type_lsp(op, lsi->lr_ports,
@@ -15530,7 +15511,6 @@ build_lswitch_and_lrouter_flows(const struct 
ovn_datapaths *ls_datapaths,
                                 const struct hmap *lr_ports,
                                 const struct hmap *port_groups,
                                 struct hmap *lflows,
-                                struct hmap *mcgroups,
                                 struct hmap *igmp_groups,
                                 const struct shash *meter_groups,
                                 const struct hmap *lbs,
@@ -15558,7 +15538,6 @@ build_lswitch_and_lrouter_flows(const struct 
ovn_datapaths *ls_datapaths,
             lsiv[index].ls_ports = ls_ports;
             lsiv[index].lr_ports = lr_ports;
             lsiv[index].port_groups = port_groups;
-            lsiv[index].mcgroups = mcgroups;
             lsiv[index].igmp_groups = igmp_groups;
             lsiv[index].meter_groups = meter_groups;
             lsiv[index].lbs = lbs;
@@ -15593,7 +15572,6 @@ build_lswitch_and_lrouter_flows(const struct 
ovn_datapaths *ls_datapaths,
             .lr_ports = lr_ports,
             .port_groups = port_groups,
             .lflows = lflows,
-            .mcgroups = mcgroups,
             .igmp_groups = igmp_groups,
             .meter_groups = meter_groups,
             .lbs = lbs,
@@ -15652,7 +15630,6 @@ build_lswitch_and_lrouter_flows(const struct 
ovn_datapaths *ls_datapaths,
     }
 
     free(svc_check_match);
-    build_lswitch_flows(ls_datapaths, lflows);
 }
 
 static ssize_t max_seen_lflow_size = 128;
@@ -15720,7 +15697,7 @@ void build_lflows(struct ovsdb_idl_txn *ovnsb_txn,
                                     input_data->ls_ports,
                                     input_data->lr_ports,
                                     input_data->port_groups, lflows,
-                                    &mcast_groups, &igmp_groups,
+                                    &igmp_groups,
                                     input_data->meter_groups, input_data->lbs,
                                     input_data->bfd_connections,
                                     input_data->features);
@@ -16583,6 +16560,10 @@ build_mcast_groups(const struct sbrec_igmp_group_table 
*sbrec_igmp_group_table,
                 ovn_multicast_add(mcast_groups, &mc_flood_l2, op);
             }
 
+            if (op->has_unknown) {
+                ovn_multicast_add(mcast_groups, &mc_unknown, op);
+            }
+
             /* If this port is connected to a multicast router then add it
              * to the MC_MROUTER_FLOOD group.
              */
-- 
2.30.2

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to