diff mbox series

[ovs-dev,12/21] ovn-northd-ddlog: Intern the SwitchPort table.

Message ID 20210327003147.2955790-13-blp@ovn.org
State Superseded
Headers show
Series ddlog 5x performance improvement | expand

Commit Message

Ben Pfaff March 27, 2021, 12:31 a.m. UTC
From: Leonid Ryzhyk <lryzhyk@vmware.com>

Change the type of record in the `SwitchPort` table from
`Ref<SwitchPort>` to `Intern<SwitchPort>`.

Signed-off-by: Leonid Ryzhyk <lryzhyk@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 northd/ipam.dl       | 22 +++++++--------
 northd/lswitch.dl    | 64 +++++++++++++++++++++++---------------------
 northd/ovn_northd.dl |  2 +-
 3 files changed, 46 insertions(+), 42 deletions(-)

Comments

0-day Robot March 27, 2021, 1:08 a.m. UTC | #1
Bleep bloop.  Greetings Ben Pfaff, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
WARNING: Unexpected sign-offs from developers who are not authors or co-authors or committers: Ben Pfaff <blp@ovn.org>
Lines checked: 229, Warnings: 1, Errors: 0


Please check this out.  If you feel there has been an error, please email aconole@redhat.com

Thanks,
0-day Robot
diff mbox series

Patch

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<SwitchPort>, address: Option<lport_addresses>)
+relation SwitchPortNewDynamicAddress(port: Intern<SwitchPort>, address: Option<lport_addresses>)
 
 SwitchPortNewDynamicAddress(port, None) :-
     port in &SwitchPort(.lsp = lsp),
diff --git a/northd/lswitch.dl b/northd/lswitch.dl
index 25abd0aa8189..c089fadac863 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<nb::Logical_Switch_Port>): bool { lsp.deref().is_enabled() }
 function is_enabled(sp: SwitchPort): bool { sp.lsp.is_enabled() }
-function is_enabled(sp: Ref<SwitchPort>): bool { sp.lsp.is_enabled() }
+function is_enabled(sp: Intern<SwitchPort>): bool { sp.lsp.is_enabled() }
 
 relation SwitchRouterPeerRef(lsp: uuid, rport: Option<Ref<RouterPort>>)
 
@@ -445,7 +445,7 @@  LBVIPBackendStatus(lbvip, backend, true) :-
 
 /* SwitchPortDHCPv4Options: many-to-one relation between logical switches and DHCPv4 options */
 relation SwitchPortDHCPv4Options(
-    port: Ref<SwitchPort>,
+    port: Intern<SwitchPort>,
     dhcpv4_options: Ref<nb::DHCP_Options>)
 
 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<SwitchPort>,
+    port: Intern<SwitchPort>,
     dhcpv6_options: Ref<nb::DHCP_Options>)
 
 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<Switch>,
@@ -571,27 +571,31 @@  relation &SwitchPort(
     up:                         bool,
     mcast_cfg:                  Ref<McastPortCfg>,
     hac_group_uuid:             Option<uuid>
-)
-
-&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[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<SwitchPort>,
+relation SwitchPortPSAddresses(port:     Intern<SwitchPort>,
                                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<SwitchPort>,
+relation SwitchPortStaticAddresses(port: Intern<SwitchPort>,
                                    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<SwitchPort>,
+relation SwitchPortAddresses(port: Intern<SwitchPort>,
                              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<SwitchPort>,
+relation SwitchPortIPv4Address(port: Intern<SwitchPort>,
                                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<SwitchPort>,
+relation SwitchPortIPv6Address(port:   Intern<SwitchPort>,
                                ea:     eth_addr,
                                addr:   ipv6_netaddr)
 
diff --git a/northd/ovn_northd.dl b/northd/ovn_northd.dl
index 1745adcf8949..c4d46b2a8406 100644
--- a/northd/ovn_northd.dl
+++ b/northd/ovn_northd.dl
@@ -3576,7 +3576,7 @@  function json_string_escape_vec(names: Vec<string>): string
  * there's more than one localnet port since the C version uses multiple flows
  * in that case.)
  */
-function match_dhcp_input(lsp: Ref<SwitchPort>): (string, string) =
+function match_dhcp_input(lsp: Intern<SwitchPort>): (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)) ++ " && ",