From: Leonid Ryzhyk <lryz...@vmware.com> Change all remaining occurrences of `Ref<T>` to `Intern<T>` throughout the DDlog code base.
Signed-off-by: Leonid Ryzhyk <lryz...@vmware.com> Signed-off-by: Ben Pfaff <b...@ovn.org> --- northd/helpers.dl | 36 +++++++++++++------------- northd/lrouter.dl | 22 ++++++++-------- northd/lswitch.dl | 61 ++++++++++++++++++++++++-------------------- northd/multicast.dl | 49 ++++++++++++++++++++--------------- northd/ovn_northd.dl | 8 +++--- 5 files changed, 95 insertions(+), 81 deletions(-) diff --git a/northd/helpers.dl b/northd/helpers.dl index 32a5526d59d5..49281fcafc9a 100644 --- a/northd/helpers.dl +++ b/northd/helpers.dl @@ -21,40 +21,40 @@ import ovn output relation Warning[string] /* ACLRef: reference to nb::ACL */ -relation &ACLRef[nb::ACL] -&ACLRef[acl] :- nb::ACL[acl]. +relation ACLRef[Intern<nb::ACL>] +ACLRef[acl.intern()] :- nb::ACL[acl]. /* DHCP_Options: reference to nb::DHCP_Options */ -relation &DHCP_OptionsRef[nb::DHCP_Options] -&DHCP_OptionsRef[options] :- nb::DHCP_Options[options]. +relation DHCP_OptionsRef[Intern<nb::DHCP_Options>] +DHCP_OptionsRef[options.intern()] :- nb::DHCP_Options[options]. /* QoS: reference to nb::QoS */ -relation &QoSRef[nb::QoS] -&QoSRef[qos] :- nb::QoS[qos]. +relation QoSRef[Intern<nb::QoS>] +QoSRef[qos.intern()] :- nb::QoS[qos]. /* LoadBalancerRef: reference to nb::Load_Balancer */ -relation &LoadBalancerRef[nb::Load_Balancer] -&LoadBalancerRef[lb] :- nb::Load_Balancer[lb]. +relation LoadBalancerRef[Intern<nb::Load_Balancer>] +LoadBalancerRef[lb.intern()] :- nb::Load_Balancer[lb]. /* LoadBalancerHealthCheckRef: reference to nb::Load_Balancer_Health_Check */ -relation &LoadBalancerHealthCheckRef[nb::Load_Balancer_Health_Check] -&LoadBalancerHealthCheckRef[lbhc] :- nb::Load_Balancer_Health_Check[lbhc]. +relation LoadBalancerHealthCheckRef[Intern<nb::Load_Balancer_Health_Check>] +LoadBalancerHealthCheckRef[lbhc.intern()] :- nb::Load_Balancer_Health_Check[lbhc]. /* MeterRef: reference to nb::Meter*/ -relation &MeterRef[nb::Meter] -&MeterRef[meter] :- nb::Meter[meter]. +relation MeterRef[Intern<nb::Meter>] +MeterRef[meter.intern()] :- nb::Meter[meter]. /* NATRef: reference to nb::NAT*/ -relation &NATRef[nb::NAT] -&NATRef[nat] :- nb::NAT[nat]. +relation NATRef[Intern<nb::NAT>] +NATRef[nat.intern()] :- nb::NAT[nat]. /* AddressSetRef: reference to nb::Address_Set */ -relation &AddressSetRef[nb::Address_Set] -&AddressSetRef[__as] :- nb::Address_Set[__as]. +relation AddressSetRef[Intern<nb::Address_Set>] +AddressSetRef[__as.intern()] :- nb::Address_Set[__as]. /* ServiceMonitor: reference to sb::Service_Monitor */ -relation &ServiceMonitorRef[sb::Service_Monitor] -&ServiceMonitorRef[sm] :- sb::Service_Monitor[sm]. +relation ServiceMonitorRef[Intern<sb::Service_Monitor>] +ServiceMonitorRef[sm.intern()] :- sb::Service_Monitor[sm]. /* Switch-to-router logical port connections */ relation SwitchRouterPeer(lsp: uuid, lsp_name: string, lrp: uuid) diff --git a/northd/lrouter.dl b/northd/lrouter.dl index e4e5cbf9f212..23d320be6cc7 100644 --- a/northd/lrouter.dl +++ b/northd/lrouter.dl @@ -263,11 +263,11 @@ LogicalRouterRedirectPort(lr, None) :- nb::Logical_Router(._uuid = lr), not DistributedGatewayPort(_, lr). -typedef ExceptionalExtIps = AllowedExtIps{ips: Ref<nb::Address_Set>} - | ExemptedExtIps{ips: Ref<nb::Address_Set>} +typedef ExceptionalExtIps = AllowedExtIps{ips: Intern<nb::Address_Set>} + | ExemptedExtIps{ips: Intern<nb::Address_Set>} typedef NAT = NAT{ - nat: Ref<nb::NAT>, + nat: Intern<nb::NAT>, external_ip: v46_ip, external_mac: Option<eth_addr>, exceptional_ext_ips: Option<ExceptionalExtIps> @@ -275,7 +275,7 @@ typedef NAT = NAT{ relation LogicalRouterNAT0( lr: uuid, - nat: Ref<nb::NAT>, + nat: Intern<nb::NAT>, external_ip: v46_ip, external_mac: Option<eth_addr>) LogicalRouterNAT0(lr, nat, external_ip, external_mac) :- @@ -399,14 +399,14 @@ LogicalRouterSnatIPs(lr._uuid, map_empty()) :- lr in nb::Logical_Router(), not LogicalRouterSnatIP(.lr = lr._uuid). -relation LogicalRouterLB(lr: uuid, nat: Ref<nb::Load_Balancer>) +relation LogicalRouterLB(lr: uuid, nat: Intern<nb::Load_Balancer>) LogicalRouterLB(lr, lb) :- nb::Logical_Router(._uuid = lr, .load_balancer = lbs), var lb_uuid = FlatMap(lbs), lb in &LoadBalancerRef[nb::Load_Balancer{._uuid = lb_uuid}]. -relation LogicalRouterLBs(lr: uuid, nat: Vec<Ref<nb::Load_Balancer>>) +relation LogicalRouterLBs(lr: uuid, nat: Vec<Intern<nb::Load_Balancer>>) LogicalRouterLBs(lr, lbs) :- LogicalRouterLB(lr, lb), @@ -448,8 +448,8 @@ typedef Router = Router { is_gateway: bool, nats: Vec<NAT>, snat_ips: Map<v46_ip, Set<NAT>>, - lbs: Vec<Ref<nb::Load_Balancer>>, - mcast_cfg: Ref<McastRouterCfg>, + lbs: Vec<Intern<nb::Load_Balancer>>, + mcast_cfg: Intern<McastRouterCfg>, learn_from_arp_request: bool, force_lb_snat: bool, } @@ -491,7 +491,7 @@ Router[Router{ var force_lb_snat = lb_force_snat_router_ip(lr.options). /* RouterLB: many-to-many relation between logical routers and nb::LB */ -relation RouterLB(router: Intern<Router>, lb: Ref<nb::Load_Balancer>) +relation RouterLB(router: Intern<Router>, lb: Intern<nb::Load_Balancer>) RouterLB(router, lb) :- router in &Router(.lbs = lbs), @@ -500,7 +500,7 @@ RouterLB(router, lb) :- /* Load balancer VIPs associated with routers */ relation RouterLBVIP( router: Intern<Router>, - lb: Ref<nb::Load_Balancer>, + lb: Intern<nb::Load_Balancer>, vip: string, backends: string) @@ -582,7 +582,7 @@ typedef RouterPort = RouterPort { router: Intern<Router>, is_redirect: bool, peer: RouterPeer, - mcast_cfg: Ref<McastPortCfg>, + mcast_cfg: Intern<McastPortCfg>, sb_options: Map<string,string>, has_bfd: bool } diff --git a/northd/lswitch.dl b/northd/lswitch.dl index 973faec5073f..df74a3731c1d 100644 --- a/northd/lswitch.dl +++ b/northd/lswitch.dl @@ -201,7 +201,7 @@ typedef Switch = Switch { localnet_ports: Vec<(uuid, string)>, // UUID and name of each localnet port. subnet: Option<(in_addr/*subnet*/, in_addr/*mask*/, bit<32>/*start_ipv4*/, bit<32>/*total_ipv4s*/)>, ipv6_prefix: Option<in6_addr>, - mcast_cfg: Ref<McastSwitchCfg>, + mcast_cfg: Intern<McastSwitchCfg>, is_vlan_transparent: bool, /* Does this switch have at least one port with type != "router"? */ @@ -276,14 +276,14 @@ Switch[Switch{ var is_vlan_transparent = ls.other_config.get_bool_def("vlan-passthru", false). /* SwitchLB: many-to-many relation between logical switches and nb::LB */ -relation SwitchLB(sw_uuid: uuid, lb: Ref<nb::Load_Balancer>) +relation SwitchLB(sw_uuid: uuid, lb: Intern<nb::Load_Balancer>) SwitchLB(sw_uuid, lb) :- nb::Logical_Switch(._uuid = sw_uuid, .load_balancer = lb_ids), var lb_id = FlatMap(lb_ids), lb in &LoadBalancerRef[nb::Load_Balancer{._uuid = lb_id}]. /* Load balancer VIPs associated with switch */ -relation SwitchLBVIP(sw_uuid: uuid, lb: Ref<nb::Load_Balancer>, vip: string, backends: string) +relation SwitchLBVIP(sw_uuid: uuid, lb: Intern<nb::Load_Balancer>, vip: string, backends: string) SwitchLBVIP(sw_uuid, lb, vip, backends) :- SwitchLB(sw_uuid, lb@(&nb::Load_Balancer{.vips = vips})), var kv = FlatMap(vips), @@ -304,10 +304,10 @@ LogicalSwitchHasLBVIP(sw_uuid, false) :- * - LBVIP parses the IP address and port (and drops VIPs where those are invalid). */ relation LBVIP0( - lb: Ref<nb::Load_Balancer>, + lb: Intern<nb::Load_Balancer>, vip_key: string, backend_ips: string, - health_check: Ref<nb::Load_Balancer_Health_Check>) + health_check: Intern<nb::Load_Balancer_Health_Check>) LBVIP0(lb, vip_key, backend_ips, health_check) :- LoadBalancerRef[lb], var vip = FlatMap(lb.vips), @@ -316,10 +316,10 @@ LBVIP0(lb, vip_key, backend_ips, health_check) :- lb.health_check.contains(health_check._uuid). relation LBVIP1( - lb: Ref<nb::Load_Balancer>, + lb: Intern<nb::Load_Balancer>, vip_key: string, backend_ips: string, - health_check: Option<Ref<nb::Load_Balancer_Health_Check>>) + health_check: Option<Intern<nb::Load_Balancer_Health_Check>>) LBVIP1(lb, vip_key, backend_ips, Some{health_check}) :- LBVIP0(lb, vip_key, backend_ips, health_check). LBVIP1(lb, vip_key, backend_ips, None) :- @@ -328,15 +328,19 @@ LBVIP1(lb, vip_key, backend_ips, None) :- (var vip_key, var backend_ips) = vip, not LBVIP0(lb, vip_key, backend_ips, _). -relation &LBVIP( - lb: Ref<nb::Load_Balancer>, +typedef LBVIP = LBVIP { + lb: Intern<nb::Load_Balancer>, vip_key: string, backend_ips: string, - health_check: Option<Ref<nb::Load_Balancer_Health_Check>>, + health_check: Option<Intern<nb::Load_Balancer_Health_Check>>, vip_addr: v46_ip, vip_port: bit<16>, - backends: Vec<lb_vip_backend>) -&LBVIP(lb, vip_key, backend_ips, health_check, vip_addr, vip_port, backends) :- + backends: Vec<lb_vip_backend> +} + +relation LBVIP[Intern<LBVIP>] + +LBVIP[LBVIP{lb, vip_key, backend_ips, health_check, vip_addr, vip_port, backends}.intern()] :- LBVIP1(lb, vip_key, backend_ips, health_check), Some{(var vip_addr, var vip_port)} = ip_address_and_port_from_lb_key(vip_key), var backends = backend_ips.split(",").filter_map( @@ -398,17 +402,20 @@ function default_protocol(protocol: Option<string>): string = { } } -relation &LBVIPWithStatus( - lb: Ref<nb::Load_Balancer>, +typedef LBVIPWithStatus = LBVIPWithStatus { + lb: Intern<nb::Load_Balancer>, vip_key: string, backend_ips: string, - health_check: Option<Ref<nb::Load_Balancer_Health_Check>>, + health_check: Option<Intern<nb::Load_Balancer_Health_Check>>, vip_addr: v46_ip, vip_port: bit<16>, - backends: Map<lb_vip_backend, bool>) -&LBVIPWithStatus(lb, vip_key, backend_ips, health_check, vip_addr, vip_port, map_empty()) :- + backends: Map<lb_vip_backend, bool> +} +relation LBVIPWithStatus[Intern<LBVIPWithStatus>] + +LBVIPWithStatus[LBVIPWithStatus{lb, vip_key, backend_ips, health_check, vip_addr, vip_port, map_empty()}.intern()] :- &LBVIP(lb, vip_key, backend_ips, health_check, vip_addr, vip_port, vec_empty()). -&LBVIPWithStatus(lb, vip_key, backend_ips, health_check, vip_addr, vip_port, backends_with_status) :- +LBVIPWithStatus[LBVIPWithStatus{lb, vip_key, backend_ips, health_check, vip_addr, vip_port, backends_with_status}.intern()] :- &LBVIP(lb, vip_key, backend_ips, health_check, vip_addr, vip_port, backends), var backend = FlatMap(backends), LBVIPBackendStatus(lbvip, backend, up), @@ -420,7 +427,7 @@ relation &LBVIPWithStatus( * Only some backends have health checking enabled. The ones that don't * are always considered to be up. */ relation LBVIPBackendStatus0( - lbvip: Ref<LBVIP>, + lbvip: Intern<LBVIP>, backend: lb_vip_backend, up: bool) LBVIPBackendStatus0(lbvip, backend, is_online(sm.status)) :- @@ -433,7 +440,7 @@ LBVIPBackendStatus0(lbvip, backend, is_online(sm.status)) :- default_protocol(lb.protocol) == default_protocol(sm.protocol). relation LBVIPBackendStatus( - lbvip: Ref<LBVIP>, + lbvip: Intern<LBVIP>, backend: lb_vip_backend, up: bool) LBVIPBackendStatus(lbvip, backend, up) :- LBVIPBackendStatus0(lbvip, backend, up). @@ -445,7 +452,7 @@ LBVIPBackendStatus(lbvip, backend, true) :- /* SwitchPortDHCPv4Options: many-to-one relation between logical switches and DHCPv4 options */ relation SwitchPortDHCPv4Options( port: Intern<SwitchPort>, - dhcpv4_options: Ref<nb::DHCP_Options>) + dhcpv4_options: Intern<nb::DHCP_Options>) SwitchPortDHCPv4Options(port, options) :- port in &SwitchPort(.lsp = lsp), @@ -456,7 +463,7 @@ SwitchPortDHCPv4Options(port, options) :- /* SwitchPortDHCPv6Options: many-to-one relation between logical switches and DHCPv4 options */ relation SwitchPortDHCPv6Options( port: Intern<SwitchPort>, - dhcpv6_options: Ref<nb::DHCP_Options>) + dhcpv6_options: Intern<nb::DHCP_Options>) SwitchPortDHCPv6Options(port, options) :- port in &SwitchPort(.lsp = lsp), @@ -465,7 +472,7 @@ SwitchPortDHCPv6Options(port, options) :- options in &DHCP_OptionsRef[nb::DHCP_Options{._uuid = dhcpv6_uuid}]. /* SwitchQoS: many-to-one relation between logical switches and nb::QoS */ -relation SwitchQoS(sw: Intern<Switch>, qos: Ref<nb::QoS>) +relation SwitchQoS(sw: Intern<Switch>, qos: Intern<nb::QoS>) SwitchQoS(sw, qos) :- sw in &Switch(), @@ -478,7 +485,7 @@ SwitchQoS(sw, qos) :- * that isn't a fair meter. (The latter case has two subcases: the * case where the meter that the ACL names corresponds to an nb::Meter * with that name, and the case where it doesn't.) */ -relation ACLHasFairMeter(acl: Ref<nb::ACL>, has_fair_meter: bool) +relation ACLHasFairMeter(acl: Intern<nb::ACL>, has_fair_meter: bool) ACLHasFairMeter(acl, true) :- ACLWithFairMeter(acl, _). ACLHasFairMeter(acl, false) :- @@ -486,14 +493,14 @@ ACLHasFairMeter(acl, false) :- not ACLWithFairMeter(acl, _). /* All the ACLs associated with a fair meter, with their fair meters. */ -relation ACLWithFairMeter(acl: Ref<nb::ACL>, meter: Ref<nb::Meter>) +relation ACLWithFairMeter(acl: Intern<nb::ACL>, meter: Intern<nb::Meter>) ACLWithFairMeter(acl, meter) :- acl in &ACLRef[nb::ACL{.meter = Some{meter_name}}], meter in &MeterRef[nb::Meter{.name = meter_name, .fair = Some{true}}]. /* SwitchACL: many-to-many relation between logical switches and ACLs */ relation &SwitchACL(sw: Intern<Switch>, - acl: Ref<nb::ACL>, + acl: Intern<nb::ACL>, has_fair_meter: bool) &SwitchACL(.sw = sw, .acl = acl, .has_fair_meter = has_fair_meter) :- @@ -568,7 +575,7 @@ typedef SwitchPort = SwitchPort { needs_dynamic_ipv6address: bool, needs_dynamic_tag: bool, up: bool, - mcast_cfg: Ref<McastPortCfg>, + mcast_cfg: Intern<McastPortCfg>, hac_group_uuid: Option<uuid> } diff --git a/northd/multicast.dl b/northd/multicast.dl index 5a14a90da1cd..9e3c13a3fde0 100644 --- a/northd/multicast.dl +++ b/northd/multicast.dl @@ -31,7 +31,7 @@ function mCAST_QUERY_INTERVAL_S_RANGE(): (integer, integer) = (1, 3600) function mCAST_DEFAULT_QUERY_MAX_RESPONSE_S(): integer = 1 /* IP Multicast per switch configuration. */ -relation &McastSwitchCfg( +typedef McastSwitchCfg = McastSwitchCfg { datapath : uuid, enabled : bool, querier : bool, @@ -43,24 +43,27 @@ relation &McastSwitchCfg( idle_timeout : integer, query_interval: integer, query_max_resp: integer -) +} + +relation McastSwitchCfg[Intern<McastSwitchCfg>] /* FIXME: Right now table_size is enforced only in ovn-controller but in * the ovn-northd C version we enforce it on the aggregate groups too. */ -&McastSwitchCfg( - .datapath = ls_uuid, - .enabled = other_config.get_bool_def("mcast_snoop", false), - .querier = other_config.get_bool_def("mcast_querier", true), - .flood_unreg = other_config.get_bool_def("mcast_flood_unregistered", false), - .eth_src = other_config.get("mcast_eth_src").unwrap_or(""), - .ip4_src = other_config.get("mcast_ip4_src").unwrap_or(""), - .ip6_src = other_config.get("mcast_ip6_src").unwrap_or(""), - .table_size = other_config.get_int_def("mcast_table_size", mCAST_DEFAULT_MAX_ENTRIES()), - .idle_timeout = idle_timeout, - .query_interval = query_interval, - .query_max_resp = query_max_resp) :- +McastSwitchCfg[McastSwitchCfg { + .datapath = ls_uuid, + .enabled = other_config.get_bool_def("mcast_snoop", false), + .querier = other_config.get_bool_def("mcast_querier", true), + .flood_unreg = other_config.get_bool_def("mcast_flood_unregistered", false), + .eth_src = other_config.get("mcast_eth_src").unwrap_or(""), + .ip4_src = other_config.get("mcast_ip4_src").unwrap_or(""), + .ip6_src = other_config.get("mcast_ip6_src").unwrap_or(""), + .table_size = other_config.get_int_def("mcast_table_size", mCAST_DEFAULT_MAX_ENTRIES()), + .idle_timeout = idle_timeout, + .query_interval = query_interval, + .query_max_resp = query_max_resp + }.intern()] :- nb::Logical_Switch(._uuid = ls_uuid, .other_config = other_config), var idle_timeout = other_config.get_int_def("mcast_idle_timeout", mCAST_DEFAULT_IDLE_TIMEOUT_S()) @@ -71,29 +74,33 @@ relation &McastSwitchCfg( mCAST_DEFAULT_QUERY_MAX_RESPONSE_S()). /* IP Multicast per router configuration. */ -relation &McastRouterCfg( +typedef McastRouterCfg = McastRouterCfg { datapath: uuid, relay : bool -) +} -&McastRouterCfg(lr_uuid, mcast_relay) :- +relation McastRouterCfg[Intern<McastRouterCfg>] + +McastRouterCfg[McastRouterCfg{lr_uuid, mcast_relay}.intern()] :- nb::Logical_Router(._uuid = lr_uuid, .options = options), var mcast_relay = options.get_bool_def("mcast_relay", false). /* IP Multicast port configuration. */ -relation &McastPortCfg( +typedef McastPortCfg = McastPortCfg { port : uuid, router_port : bool, flood : bool, flood_reports : bool -) +} + +relation McastPortCfg[Intern<McastPortCfg>] -&McastPortCfg(lsp_uuid, false, flood, flood_reports) :- +McastPortCfg[McastPortCfg{lsp_uuid, false, flood, flood_reports}.intern()] :- nb::Logical_Switch_Port(._uuid = lsp_uuid, .options = options), var flood = options.get_bool_def("mcast_flood", false), var flood_reports = options.get_bool_def("mcast_flood_reports", false). -&McastPortCfg(lrp_uuid, true, flood, flood) :- +McastPortCfg[McastPortCfg{lrp_uuid, true, flood, flood}.intern()] :- nb::Logical_Router_Port(._uuid = lrp_uuid, .options = options), var flood = options.get_bool_def("mcast_flood", false). diff --git a/northd/ovn_northd.dl b/northd/ovn_northd.dl index 9e53821719c9..f2ada73bf8ed 100644 --- a/northd/ovn_northd.dl +++ b/northd/ovn_northd.dl @@ -295,7 +295,7 @@ function get_router_load_balancer_ips(router: Intern<Router>) : var all_ips_v4 = set_empty(); var all_ips_v6 = set_empty(); for (lb in router.lbs) { - for (kv in deref(lb).vips) { + for (kv in lb.vips) { (var vip, _) = kv; /* node->key contains IP:port or just IP. */ match (ip_address_and_port_from_lb_key(vip)) { @@ -2000,7 +2000,7 @@ HasEventElbMeter(false) :- not nb::Meter(.name = "event-elb"). /* Empty LoadBalancer Controller event */ -function build_empty_lb_event_flow(key: string, lb: Ref<nb::Load_Balancer>, +function build_empty_lb_event_flow(key: string, lb: Intern<nb::Load_Balancer>, meter: bool): Option<(string, string)> { (var ip, var port) = match (ip_address_and_port_from_lb_key(key)) { Some{(ip, port)} -> (ip, port), @@ -2045,7 +2045,7 @@ function build_empty_lb_event_flow(key: string, lb: Ref<nb::Load_Balancer>, * The deprecated way is to set nb::NB_Global options:controller_event=true, * which enables events for every load balancer. */ -relation LoadBalancerEmptyEvents(lb: Ref<nb::Load_Balancer>) +relation LoadBalancerEmptyEvents(lb: Intern<nb::Load_Balancer>) LoadBalancerEmptyEvents(lb) :- nb::NB_Global(.options = global_options), var global_events = global_options.get_bool_def("controller_event", false), @@ -2920,7 +2920,7 @@ function ct_lb(backends: string, "ct_lb(" ++ args.join("; ") ++ ");" } -function build_lb_vip_actions(lbvip: Ref<LBVIPWithStatus>, +function build_lb_vip_actions(lbvip: Intern<LBVIPWithStatus>, stage: Stage, actions0: string): string { var up_backends = set_empty(); -- 2.29.2 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev