From patchwork Fri May 7 04:06:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 1475330 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Fbxlg6Cgrz9sPf for ; Fri, 7 May 2021 14:09:03 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 0D8F883DEB; Fri, 7 May 2021 04:09:02 +0000 (UTC) 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 uq9T-MLS-NJF; Fri, 7 May 2021 04:08:57 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTP id 960428447D; Fri, 7 May 2021 04:08:24 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6B46AC000E; Fri, 7 May 2021 04:08:24 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1CB3EC000E for ; Fri, 7 May 2021 04:08:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 6ABDF40382 for ; Fri, 7 May 2021 04:07:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id H_WV36icVsZQ for ; Fri, 7 May 2021 04:07:47 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by smtp2.osuosl.org (Postfix) with ESMTPS id 1107940E49 for ; Fri, 7 May 2021 04:07:37 +0000 (UTC) X-Originating-IP: 75.54.222.30 Received: from sigfpe.attlocal.net (75-54-222-30.lightspeed.rdcyca.sbcglobal.net [75.54.222.30]) (Authenticated sender: blp@ovn.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 12676C0006; Fri, 7 May 2021 04:07:34 +0000 (UTC) From: Ben Pfaff To: dev@openvswitch.org Date: Thu, 6 May 2021 21:06:50 -0700 Message-Id: <20210507040659.26830-19-blp@ovn.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210507040659.26830-1-blp@ovn.org> References: <20210507040659.26830-1-blp@ovn.org> MIME-Version: 1.0 Cc: Leonid Ryzhyk , Ben Pfaff Subject: [ovs-dev] [PATCH ovn v3 18/27] ovn-northd-ddlog: Intern the SwitchPort table. 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" From: Leonid Ryzhyk Change the type of record in the `SwitchPort` table from `Ref` to `Intern`. Signed-off-by: Leonid Ryzhyk Signed-off-by: Ben Pfaff --- northd/ipam.dl | 22 +++++++-------- northd/lswitch.dl | 64 +++++++++++++++++++++++--------------------- northd/ovn_northd.dl | 2 +- 3 files changed, 46 insertions(+), 42 deletions(-) diff --git a/northd/ipam.dl b/northd/ipam.dl index e7373f250a7f..40d542ec0687 100644 --- a/northd/ipam.dl +++ b/northd/ipam.dl @@ -212,7 +212,7 @@ SwitchPortAllocatedIPv4DynAddress(lsport, dyn_addr) :- Some{port0} -> { match (port0.sw.subnet) { None -> { - abort("needs_dynamic_ipv4address is true, but subnet is undefined in port ${uuid2str(deref(port0).lsp._uuid)}"); + abort("needs_dynamic_ipv4address is true, but subnet is undefined in port ${uuid2str(port0.lsp._uuid)}"); (0, 0) }, Some{(_, _, start_ipv4, total_ipv4s)} -> (start_ipv4, total_ipv4s) @@ -220,27 +220,27 @@ SwitchPortAllocatedIPv4DynAddress(lsport, dyn_addr) :- } }; for (port in ports) { - //warn("port(${deref(port).lsp._uuid})"); - match (deref(port).dynamic_address) { + //warn("port(${port.lsp._uuid})"); + match (port.dynamic_address) { None -> { /* no dynamic address yet -- allocate one now */ - //warn("need_addr(${deref(port).lsp._uuid})"); - need_addr.push(deref(port).lsp._uuid) + //warn("need_addr(${port.lsp._uuid})"); + need_addr.push(port.lsp._uuid) }, Some{dynaddr} -> { match (dynaddr.ipv4_addrs.nth(0)) { None -> { /* dynamic address does not have IPv4 component -- allocate one now */ - //warn("need_addr(${deref(port).lsp._uuid})"); - need_addr.push(deref(port).lsp._uuid) + //warn("need_addr(${port.lsp._uuid})"); + need_addr.push(port.lsp._uuid) }, Some{addr} -> { var haddr = addr.addr.a; if (haddr < start_ipv4 or haddr >= start_ipv4 + total_ipv4s) { - need_addr.push(deref(port).lsp._uuid) + need_addr.push(port.lsp._uuid) } else if (used_addrs.contains(haddr)) { - need_addr.push(deref(port).lsp._uuid); - warn("Duplicate IP set on switch ${deref(port).lsp.name}: ${addr.addr}") + need_addr.push(port.lsp._uuid); + warn("Duplicate IP set on switch ${port.lsp.name}: ${addr.addr}") } else { /* has valid dynamic address -- record it in used_addrs */ used_addrs.insert(haddr); @@ -459,7 +459,7 @@ SwitchPortNewMACDynAddress(lsp._uuid, addr) :- * Dynamic IPv6 address allocation. * `needs_dynamic_ipv6address` -> mac.to_ipv6_eui64(ipv6_prefix) */ -relation SwitchPortNewDynamicAddress(port: Ref, address: Option) +relation SwitchPortNewDynamicAddress(port: Intern, address: Option) SwitchPortNewDynamicAddress(port, None) :- port in &SwitchPort(.lsp = lsp), diff --git a/northd/lswitch.dl b/northd/lswitch.dl index b5f53412d313..a91e7275a4ea 100644 --- a/northd/lswitch.dl +++ b/northd/lswitch.dl @@ -25,7 +25,7 @@ import vec function is_enabled(lsp: nb::Logical_Switch_Port): bool { is_enabled(lsp.enabled) } function is_enabled(lsp: Ref): bool { lsp.deref().is_enabled() } function is_enabled(sp: SwitchPort): bool { sp.lsp.is_enabled() } -function is_enabled(sp: Ref): bool { sp.lsp.is_enabled() } +function is_enabled(sp: Intern): bool { sp.lsp.is_enabled() } relation SwitchRouterPeerRef(lsp: uuid, rport: Option>) @@ -445,7 +445,7 @@ LBVIPBackendStatus(lbvip, backend, true) :- /* SwitchPortDHCPv4Options: many-to-one relation between logical switches and DHCPv4 options */ relation SwitchPortDHCPv4Options( - port: Ref, + port: Intern, dhcpv4_options: Ref) SwitchPortDHCPv4Options(port, options) :- @@ -456,7 +456,7 @@ SwitchPortDHCPv4Options(port, options) :- /* SwitchPortDHCPv6Options: many-to-one relation between logical switches and DHCPv4 options */ relation SwitchPortDHCPv6Options( - port: Ref, + port: Intern, dhcpv6_options: Ref) SwitchPortDHCPv6Options(port, options) :- @@ -551,7 +551,7 @@ SwitchPortHAChassisGroup(lsp_uuid, None) :- * - `up` - true if the port is bound to a chassis or has type "" * - 'hac_group_uuid' - uuid of sb::HA_Chassis_Group, only for "external" ports */ -relation &SwitchPort( +typedef SwitchPort = SwitchPort { lsp: nb::Logical_Switch_Port, json_name: string, sw: Intern, @@ -571,27 +571,31 @@ relation &SwitchPort( up: bool, mcast_cfg: Ref, hac_group_uuid: Option -) - -&SwitchPort(.lsp = lsp, - .json_name = json_string_escape(lsp.name), - .sw = sw, - .peer = peer, - .static_addresses = static_addresses, - .dynamic_address = dynamic_address, - .static_dynamic_mac = static_dynamic_mac, - .static_dynamic_ipv4 = static_dynamic_ipv4, - .static_dynamic_ipv6 = static_dynamic_ipv6, - .ps_addresses = ps_addresses, - .ps_eth_addresses = ps_eth_addresses, - .parent_name = parent_name, - .needs_dynamic_ipv4address = needs_dynamic_ipv4address, - .needs_dynamic_macaddress = needs_dynamic_macaddress, - .needs_dynamic_ipv6address = needs_dynamic_ipv6address, - .needs_dynamic_tag = needs_dynamic_tag, - .up = up, - .mcast_cfg = mcast_cfg, - .hac_group_uuid = hac_group_uuid) :- +} + +relation SwitchPort[Intern] + +SwitchPort[SwitchPort{ + .lsp = lsp, + .json_name = json_string_escape(lsp.name), + .sw = sw, + .peer = peer, + .static_addresses = static_addresses, + .dynamic_address = dynamic_address, + .static_dynamic_mac = static_dynamic_mac, + .static_dynamic_ipv4 = static_dynamic_ipv4, + .static_dynamic_ipv6 = static_dynamic_ipv6, + .ps_addresses = ps_addresses, + .ps_eth_addresses = ps_eth_addresses, + .parent_name = parent_name, + .needs_dynamic_ipv4address = needs_dynamic_ipv4address, + .needs_dynamic_macaddress = needs_dynamic_macaddress, + .needs_dynamic_ipv6address = needs_dynamic_ipv6address, + .needs_dynamic_tag = needs_dynamic_tag, + .up = up, + .mcast_cfg = mcast_cfg, + .hac_group_uuid = hac_group_uuid + }.intern()] :- nb::Logical_Switch_Port[lsp], LogicalSwitchPort(lsp._uuid, lswitch_uuid), sw in &Switch(._uuid = lswitch_uuid, @@ -667,7 +671,7 @@ relation &SwitchPort( .hac_group_uuid = hac_group_uuid). /* Switch port port security addresses */ -relation SwitchPortPSAddresses(port: Ref, +relation SwitchPortPSAddresses(port: Intern, ps_addrs: lport_addresses) SwitchPortPSAddresses(port, ps_addrs) :- @@ -676,7 +680,7 @@ SwitchPortPSAddresses(port, ps_addrs) :- /* All static addresses associated with a port parsed into * the lport_addresses data structure */ -relation SwitchPortStaticAddresses(port: Ref, +relation SwitchPortStaticAddresses(port: Intern, addrs: lport_addresses) SwitchPortStaticAddresses(port, addrs) :- port in &SwitchPort(.static_addresses = static_addresses), @@ -684,7 +688,7 @@ SwitchPortStaticAddresses(port, addrs) :- /* All static and dynamic addresses associated with a port parsed into * the lport_addresses data structure */ -relation SwitchPortAddresses(port: Ref, +relation SwitchPortAddresses(port: Intern, addrs: lport_addresses) SwitchPortAddresses(port, addrs) :- SwitchPortStaticAddresses(port, addrs). @@ -715,7 +719,7 @@ SwitchPortAddresses(port, addrs) :- }. /* All static and dynamic IPv4 addresses associated with a port */ -relation SwitchPortIPv4Address(port: Ref, +relation SwitchPortIPv4Address(port: Intern, ea: eth_addr, addr: ipv4_netaddr) @@ -724,7 +728,7 @@ SwitchPortIPv4Address(port, ea, addr) :- var addr = FlatMap(addrs). /* All static and dynamic IPv6 addresses associated with a port */ -relation SwitchPortIPv6Address(port: Ref, +relation SwitchPortIPv6Address(port: Intern, ea: eth_addr, addr: ipv6_netaddr) diff --git a/northd/ovn_northd.dl b/northd/ovn_northd.dl index 95de5c0c5d70..502e204f02c5 100644 --- a/northd/ovn_northd.dl +++ b/northd/ovn_northd.dl @@ -3541,7 +3541,7 @@ function json_string_escape_vec(names: Vec): string * there's more than one localnet port since the C version uses multiple flows * in that case.) */ -function match_dhcp_input(lsp: Ref): (string, string) = +function match_dhcp_input(lsp: Intern): (string, string) = { if (lsp.lsp.__type == "external" and not lsp.sw.localnet_ports.is_empty()) { ("inport == " ++ json_string_escape_vec(lsp.sw.localnet_ports.map(|x| x.1)) ++ " && ",