From patchwork Sat May 13 00:03:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 1780863 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QJ5V76Rdnz20dF for ; Sat, 13 May 2023 10:04:47 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 877E584C6C; Sat, 13 May 2023 00:04:45 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 877E584C6C X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tOTrw5nDaSAt; Sat, 13 May 2023 00:04:43 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 92123843E4; Sat, 13 May 2023 00:04:40 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 92123843E4 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 996FAC008F; Sat, 13 May 2023 00:04:38 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 18DC0C002A for ; Sat, 13 May 2023 00:04:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id D138842E6A for ; Sat, 13 May 2023 00:04:34 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org D138842E6A X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1n83OYggTEQQ for ; Sat, 13 May 2023 00:04:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 203A042E64 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by smtp4.osuosl.org (Postfix) with ESMTPS id 203A042E64 for ; Sat, 13 May 2023 00:04:32 +0000 (UTC) Received: (Authenticated sender: hzhou@ovn.org) by mail.gandi.net (Postfix) with ESMTPSA id 98ADE1C0002; Sat, 13 May 2023 00:04:30 +0000 (UTC) From: Han Zhou To: dev@openvswitch.org Date: Fri, 12 May 2023 17:03:50 -0700 Message-Id: <20230513000356.2475960-9-hzhou@ovn.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230513000356.2475960-1-hzhou@ovn.org> References: <20230513000356.2475960-1-hzhou@ovn.org> MIME-Version: 1.0 Subject: [ovs-dev] [PATCH ovn 08/14] northd: Refactor the logic related to "unknown" mc_group. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" 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 --- northd/northd.c | 73 ++++++++++++++++++------------------------------- 1 file changed, 27 insertions(+), 46 deletions(-) diff --git a/northd/northd.c b/northd/northd.c index be206d7a3622..2cb568b8e1dd 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -2651,6 +2651,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); @@ -6232,6 +6235,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) @@ -8834,36 +8839,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. @@ -9613,13 +9602,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) { @@ -9658,12 +9644,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, @@ -15157,7 +15138,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; @@ -15195,6 +15175,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 @@ -15256,8 +15237,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, @@ -15450,7 +15431,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, @@ -15478,7 +15458,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; @@ -15513,7 +15492,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, @@ -15572,7 +15550,6 @@ build_lswitch_and_lrouter_flows(const struct ovn_datapaths *ls_datapaths, } free(svc_check_match); - build_lswitch_flows(ls_datapaths, lflows); } static void @@ -15672,7 +15649,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); @@ -16576,6 +16553,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. */