From patchwork Wed Aug 17 07:18:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1667114 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::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bJ7gYYUh; dkim-atps=neutral Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (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 4M6zsD6d9Gz1ygJ for ; Wed, 17 Aug 2022 17:18:56 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 047A36107A; Wed, 17 Aug 2022 07:18:54 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 047A36107A Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bJ7gYYUh X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hYT5_hpyymlx; Wed, 17 Aug 2022 07:18:53 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 285136106C; Wed, 17 Aug 2022 07:18:52 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 285136106C Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5C33DC007E; Wed, 17 Aug 2022 07:18:51 +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 3A55CC0032 for ; Wed, 17 Aug 2022 07:18:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 030E1419B0 for ; Wed, 17 Aug 2022 07:18:44 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 030E1419B0 Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bJ7gYYUh 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 Erd7J2yJC49Q for ; Wed, 17 Aug 2022 07:18:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 3B886419A9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id 3B886419A9 for ; Wed, 17 Aug 2022 07:18:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660720722; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y43LDSOKhja2O/teoMfoH1Sy2CAPsz/MpkxE6QD08yA=; b=bJ7gYYUhHJ4sBHcvi3x+bd58pcOQ6NkVDfDM+XxyX432MUbONe934lAiFhmsPbsPpogdN+ GkCmyjwasWKQKrSum66U9sodOySZpiULGXhPs1UTpTfXOy/8Z+QWmX7XuQp9JiW6Skc7RY li23KEikgJEn6R6eDy1sW7EM0dDpbfQ= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-48-lWZtjWJjNXyPz2TVr0AjgA-1; Wed, 17 Aug 2022 03:18:38 -0400 X-MC-Unique: lWZtjWJjNXyPz2TVr0AjgA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9AFC11C04B76; Wed, 17 Aug 2022 07:18:38 +0000 (UTC) Received: from amusil.redhat.com (unknown [10.34.130.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1EA794585; Wed, 17 Aug 2022 07:18:37 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Wed, 17 Aug 2022 09:18:30 +0200 Message-Id: <20220817071833.129230-4-amusil@redhat.com> In-Reply-To: <20220817071833.129230-1-amusil@redhat.com> References: <20220817071833.129230-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: dceara@redhat.com Subject: [ovs-dev] [PATCH ovn v7 3/6] northd: Move struct ovn_datapath and related structs to northd.h 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" The struct ovn_datapath could not be used outside the northd.c move it to northd.h that it can be used by other .c files later on. Reported-at: https://bugzilla.redhat.com/2084668 Acked-by: Dumitru Ceara Acked-by: Mark Michelson Acked-by: Han Zhou Signed-off-by: Ales Musil --- v7: Rebase on top of current main. --- northd/northd.c | 155 ---------------------------------------------- northd/northd.h | 159 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 159 insertions(+), 155 deletions(-) diff --git a/northd/northd.c b/northd/northd.c index b1e9ffc87..76d79c5ce 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -514,74 +514,6 @@ port_has_qos_params(const struct smap *opts) } -/* - * Multicast snooping and querier per datapath configuration. - */ -struct mcast_switch_info { - - bool enabled; /* True if snooping enabled. */ - bool querier; /* True if querier enabled. */ - bool flood_unregistered; /* True if unregistered multicast should be - * flooded. - */ - bool flood_relay; /* True if the switch is connected to a - * multicast router and unregistered multicast - * should be flooded to the mrouter. Only - * applicable if flood_unregistered == false. - */ - bool flood_reports; /* True if the switch has at least one port - * configured to flood reports. - */ - bool flood_static; /* True if the switch has at least one port - * configured to flood traffic. - */ - int64_t table_size; /* Max number of IP multicast groups. */ - int64_t idle_timeout; /* Timeout after which an idle group is - * flushed. - */ - int64_t query_interval; /* Interval between multicast queries. */ - char *eth_src; /* ETH src address of the queries. */ - char *ipv4_src; /* IPv4 src address of the queries. */ - char *ipv6_src; /* IPv6 src address of the queries. */ - - int64_t query_max_response; /* Expected time after which reports should - * be received for queries that were sent out. - */ - - atomic_uint64_t active_v4_flows; /* Current number of active IPv4 multicast - * flows. - */ - atomic_uint64_t active_v6_flows; /* Current number of active IPv6 multicast - * flows. - */ -}; - -struct mcast_router_info { - bool relay; /* True if the router should relay IP multicast. */ - bool flood_static; /* True if the router has at least one port configured - * to flood traffic. - */ -}; - -struct mcast_info { - - struct hmap group_tnlids; /* Group tunnel IDs in use on this DP. */ - uint32_t group_tnlid_hint; /* Hint for allocating next group tunnel ID. */ - struct ovs_list groups; /* List of groups learnt on this DP. */ - - union { - struct mcast_switch_info sw; /* Switch specific multicast info. */ - struct mcast_router_info rtr; /* Router specific multicast info. */ - }; -}; - -struct mcast_port_info { - bool flood; /* True if the port should flood IP multicast traffic - * regardless if it's registered or not. */ - bool flood_reports; /* True if the port should flood IP multicast reports - * (e.g., IGMP join/leave). */ -}; - static void init_mcast_port_info(struct mcast_port_info *mcast_info, const struct nbrec_logical_switch_port *nbsp, @@ -611,93 +543,6 @@ ovn_mcast_group_allocate_key(struct mcast_info *mcast_info) &mcast_info->group_tnlid_hint); } -/* The 'key' comes from nbs->header_.uuid or nbr->header_.uuid or - * sb->external_ids:logical-switch. */ -struct ovn_datapath { - struct hmap_node key_node; /* Index on 'key'. */ - struct uuid key; /* (nbs/nbr)->header_.uuid. */ - - const struct nbrec_logical_switch *nbs; /* May be NULL. */ - const struct nbrec_logical_router *nbr; /* May be NULL. */ - const struct sbrec_datapath_binding *sb; /* May be NULL. */ - - struct ovs_list list; /* In list of similar records. */ - - uint32_t tunnel_key; - - /* Logical switch data. */ - struct ovn_port **router_ports; - size_t n_router_ports; - size_t n_allocated_router_ports; - - struct hmap port_tnlids; - uint32_t port_key_hint; - - bool has_stateful_acl; - bool has_lb_vip; - bool has_unknown; - bool has_acls; - bool has_vtep_lports; - - /* IPAM data. */ - struct ipam_info ipam_info; - - /* Multicast data. */ - struct mcast_info mcast_info; - - /* Applies to only logical router datapath. - * True if logical router is a gateway router. i.e options:chassis is set. - * If this is true, then 'l3dgw_ports' will be ignored. */ - bool is_gw_router; - - /* OVN northd only needs to know about logical router gateway ports for - * NAT/LB on a distributed router. The "distributed gateway ports" are - * populated only when there is a gateway chassis or ha chassis group - * specified for some of the ports on the logical router. Otherwise this - * will be NULL. */ - struct ovn_port **l3dgw_ports; - size_t n_l3dgw_ports; - - /* NAT entries configured on the router. */ - struct ovn_nat *nat_entries; - size_t n_nat_entries; - - bool has_distributed_nat; - - /* Set of nat external ips on the router. */ - struct sset external_ips; - - /* SNAT IPs owned by the router (shash of 'struct ovn_snat_ip'). */ - struct shash snat_ips; - - struct lport_addresses dnat_force_snat_addrs; - struct lport_addresses lb_force_snat_addrs; - bool lb_force_snat_router_ip; - /* The "routable" ssets are subsets of the load balancer - * IPs for which IP routes and ARP resolution flows are automatically - * added - */ - struct sset lb_ips_v4; - struct sset lb_ips_v4_routable; - struct sset lb_ips_v4_reachable; - struct sset lb_ips_v6; - struct sset lb_ips_v6_routable; - struct sset lb_ips_v6_reachable; - - struct ovn_port **localnet_ports; - size_t n_localnet_ports; - - struct ovs_list lr_list; /* In list of logical router datapaths. */ - /* The logical router group to which this datapath belongs. - * Valid only if it is logical router datapath. NULL otherwise. */ - struct lrouter_group *lr_group; - - /* Port groups related to the datapath, used only when nbs is NOT NULL. */ - struct hmap nb_pgs; - - struct ovs_list port_list; -}; - /* Contains a NAT entry with the external addresses pre-parsed. */ struct ovn_nat { const struct nbrec_nat *nb; diff --git a/northd/northd.h b/northd/northd.h index 677b35877..dcbed1b1f 100644 --- a/northd/northd.h +++ b/northd/northd.h @@ -16,6 +16,10 @@ #include "ovsdb-idl.h" +#include "lib/ovn-util.h" +#include "lib/ovs-atomic.h" +#include "lib/sset.h" +#include "northd/ipam.h" #include "openvswitch/hmap.h" struct northd_input { @@ -98,6 +102,161 @@ struct lflow_input { bool ovn_internal_version_changed; }; +/* + * Multicast snooping and querier per datapath configuration. + */ +struct mcast_switch_info { + + bool enabled; /* True if snooping enabled. */ + bool querier; /* True if querier enabled. */ + bool flood_unregistered; /* True if unregistered multicast should be + * flooded. + */ + bool flood_relay; /* True if the switch is connected to a + * multicast router and unregistered multicast + * should be flooded to the mrouter. Only + * applicable if flood_unregistered == false. + */ + bool flood_reports; /* True if the switch has at least one port + * configured to flood reports. + */ + bool flood_static; /* True if the switch has at least one port + * configured to flood traffic. + */ + int64_t table_size; /* Max number of IP multicast groups. */ + int64_t idle_timeout; /* Timeout after which an idle group is + * flushed. + */ + int64_t query_interval; /* Interval between multicast queries. */ + char *eth_src; /* ETH src address of the queries. */ + char *ipv4_src; /* IPv4 src address of the queries. */ + char *ipv6_src; /* IPv6 src address of the queries. */ + + int64_t query_max_response; /* Expected time after which reports should + * be received for queries that were sent out. + */ + + atomic_uint64_t active_v4_flows; /* Current number of active IPv4 + * multicast flows. + */ + atomic_uint64_t active_v6_flows; /* Current number of active IPv6 + * multicast flows. + */ +}; + +struct mcast_router_info { + bool relay; /* True if the router should relay IP multicast. */ + bool flood_static; /* True if the router has at least one port configured + * to flood traffic. + */ +}; + +struct mcast_info { + + struct hmap group_tnlids; /* Group tunnel IDs in use on this DP. */ + uint32_t group_tnlid_hint; /* Hint for allocating next group tunnel ID. */ + struct ovs_list groups; /* List of groups learnt on this DP. */ + + union { + struct mcast_switch_info sw; /* Switch specific multicast info. */ + struct mcast_router_info rtr; /* Router specific multicast info. */ + }; +}; + +struct mcast_port_info { + bool flood; /* True if the port should flood IP multicast traffic + * regardless if it's registered or not. */ + bool flood_reports; /* True if the port should flood IP multicast reports + * (e.g., IGMP join/leave). */ +}; + +/* The 'key' comes from nbs->header_.uuid or nbr->header_.uuid or + * sb->external_ids:logical-switch. */ +struct ovn_datapath { + struct hmap_node key_node; /* Index on 'key'. */ + struct uuid key; /* (nbs/nbr)->header_.uuid. */ + + const struct nbrec_logical_switch *nbs; /* May be NULL. */ + const struct nbrec_logical_router *nbr; /* May be NULL. */ + const struct sbrec_datapath_binding *sb; /* May be NULL. */ + + struct ovs_list list; /* In list of similar records. */ + + uint32_t tunnel_key; + + /* Logical switch data. */ + struct ovn_port **router_ports; + size_t n_router_ports; + size_t n_allocated_router_ports; + + struct hmap port_tnlids; + uint32_t port_key_hint; + + bool has_stateful_acl; + bool has_lb_vip; + bool has_unknown; + bool has_acls; + bool has_vtep_lports; + + /* IPAM data. */ + struct ipam_info ipam_info; + + /* Multicast data. */ + struct mcast_info mcast_info; + + /* Applies to only logical router datapath. + * True if logical router is a gateway router. i.e options:chassis is set. + * If this is true, then 'l3dgw_ports' will be ignored. */ + bool is_gw_router; + + /* OVN northd only needs to know about logical router gateway ports for + * NAT/LB on a distributed router. The "distributed gateway ports" are + * populated only when there is a gateway chassis or ha chassis group + * specified for some of the ports on the logical router. Otherwise this + * will be NULL. */ + struct ovn_port **l3dgw_ports; + size_t n_l3dgw_ports; + + /* NAT entries configured on the router. */ + struct ovn_nat *nat_entries; + size_t n_nat_entries; + + bool has_distributed_nat; + + /* Set of nat external ips on the router. */ + struct sset external_ips; + + /* SNAT IPs owned by the router (shash of 'struct ovn_snat_ip'). */ + struct shash snat_ips; + + struct lport_addresses dnat_force_snat_addrs; + struct lport_addresses lb_force_snat_addrs; + bool lb_force_snat_router_ip; + /* The "routable" ssets are subsets of the load balancer + * IPs for which IP routes and ARP resolution flows are automatically + * added + */ + struct sset lb_ips_v4; + struct sset lb_ips_v4_routable; + struct sset lb_ips_v4_reachable; + struct sset lb_ips_v6; + struct sset lb_ips_v6_routable; + struct sset lb_ips_v6_reachable; + + struct ovn_port **localnet_ports; + size_t n_localnet_ports; + + struct ovs_list lr_list; /* In list of logical router datapaths. */ + /* The logical router group to which this datapath belongs. + * Valid only if it is logical router datapath. NULL otherwise. */ + struct lrouter_group *lr_group; + + /* Port groups related to the datapath, used only when nbs is NOT NULL. */ + struct hmap nb_pgs; + + struct ovs_list port_list; +}; + void northd_run(struct northd_input *input_data, struct northd_data *data, struct ovsdb_idl_txn *ovnnb_txn,