Skip to content

Commit

Permalink
Merge pull request #8 from ryzhyk/ddlog
Browse files Browse the repository at this point in the history
DDlog OVSDB integration improvements
  • Loading branch information
justinpettit committed Feb 11, 2019
2 parents 63a87a5 + e92a98c commit 2b7b7c8
Show file tree
Hide file tree
Showing 5 changed files with 306 additions and 335 deletions.
2 changes: 1 addition & 1 deletion ovn/northd/lrouter.dl
Expand Up @@ -112,7 +112,7 @@ relation &Router(
)

&Router(.lr = lr,
.dpname = uuid2str(lr._uuid),
.dpname = uuid2name(lr._uuid),
.l3dgw_port = l3dgw_port,
.redirect_port_name =
match (l3dgw_port) {
Expand Down
2 changes: 1 addition & 1 deletion ovn/northd/lswitch.dl
Expand Up @@ -126,7 +126,7 @@ relation &Switch(
)

&Switch(.ls = ls,
.dpname = uuid2str(ls._uuid),
.dpname = uuid2name(ls._uuid),
.has_stateful_acl = has_stateful_acl,
.has_dns_records = has_dns_records,
.has_localnet_port = has_localnet_port,
Expand Down
35 changes: 3 additions & 32 deletions ovn/northd/ovn-northd-ddlog.c
Expand Up @@ -70,43 +70,14 @@ ddlog_table_update(ddlog_prog ddlog, const char *table)
{
int error;
char *json;
char *ddlog_table;

ddlog_table = xasprintf("OVN_Southbound.DeltaPlus_%s", table);
error = ddlog_dump_ovsdb_deltaplus_table(ddlog,
ddlog_get_table_id(ddlog_table),
&json);
error = ddlog_dump_ovsdb_delta(ddlog, "OVN_Southbound", table, &json);
if (error) {
VLOG_WARN("xxx delta-plus (%s) error: %d", ddlog_table, error);
VLOG_WARN("xxx delta (%s) error: %d", table, error);
return;
}
VLOG_WARN("xxx delta-plus (%s): %s", ddlog_table, json);
VLOG_WARN("xxx delta (%s): %s", table, json);
ddlog_free_json(json);
free(ddlog_table);

ddlog_table = xasprintf("OVN_Southbound.DeltaMinus_%s", table);
error = ddlog_dump_ovsdb_deltaminus_table(ddlog,
ddlog_get_table_id(ddlog_table),
&json);
if (error) {
VLOG_WARN("xxx delta-minus (%s) error: %d", ddlog_table, error);
return;
}
VLOG_WARN("xxx delta-minus (%s): %s", ddlog_table, json);
ddlog_free_json(json);
free(ddlog_table);

#if 0
ddlog_table = xasprintf("OVN_Southbound.DeltaUpdate_%s", table);
error = ddlog_dump_ovsdb_deltaupdate_table(ddlog, ddlog_table, &json);
if (error) {
VLOG_WARN("xxx delta-update (%s) error: %d", ddlog_table, error);
return;
}
VLOG_WARN("xxx delta-update (%s): %s", ddlog_table, json);
ddlog_free_json(json);
free(ddlog_table);
#endif
}

static void
Expand Down
62 changes: 31 additions & 31 deletions ovn/northd/ovn_northd.dl
Expand Up @@ -10,7 +10,7 @@ import ipam

/* Meter_Band table */
for (mb in nb.Meter_Band) {
sb.Out_Meter_Band(.uuid_name = uuid2str(mb._uuid),
sb.Out_Meter_Band(.uuid_name = uuid2name(mb._uuid),
.action = mb.action,
.rate = mb.rate,
.burst_size = mb.burst_size)
Expand All @@ -20,11 +20,11 @@ for (mb in nb.Meter_Band) {
for (meter in nb.Meter) {
sb.Out_Meter(.name = meter.name,
.unit = meter.unit,
.bands = set_map_uuid2str(meter.bands))
.bands = set_map_uuid2name(meter.bands))
}

/* Datapath_Binding table */
sb.Out_Datapath_Binding(uuid_str, 0, external_ids) :-
sb.Out_Datapath_Binding(uuid2name(uuid), 0, external_ids) :-
nb.Logical_Switch(._uuid = uuid, .name = name, .external_ids = ids),
var uuid_str = uuid2str(uuid),
var external_ids = {
Expand All @@ -38,7 +38,7 @@ sb.Out_Datapath_Binding(uuid_str, 0, external_ids) :-
eids
}.

sb.Out_Datapath_Binding(uuid_str, 0, external_ids) :-
sb.Out_Datapath_Binding(uuid2name(uuid), 0, external_ids) :-
nb.Logical_Router(._uuid = uuid, .name = name, .external_ids = ids),
var uuid_str = uuid2str(uuid),
var external_ids = {
Expand All @@ -52,9 +52,9 @@ sb.Out_Datapath_Binding(uuid_str, 0, external_ids) :-
eids
}.

sb.OutProxy_Datapath_Binding(uuid_str, tunkey, external_ids) :-
sb.Out_Datapath_Binding(uuid_str, _, external_ids),
TunKeyAllocation(uuid_str, tunkey).
sb.OutProxy_Datapath_Binding(uuid_name, tunkey, external_ids) :-
sb.Out_Datapath_Binding(uuid_name, _, external_ids),
TunKeyAllocation(uuid_name, tunkey).



Expand All @@ -78,12 +78,12 @@ relation Out_Port_Binding (
*/

/* Case 1: Create a Port_Binding per logical switch port that is not of type "router" */
sb.Out_Port_Binding(.uuid_name = uuid2str(lsp._uuid),
sb.Out_Port_Binding(.uuid_name = uuid2name(lsp._uuid),
.logical_port = lsp.name,
.__type = lsp.__type,
.gateway_chassis = set_empty(),
.options = lsp.options,
.datapath = uuid2str(sw.ls._uuid),
.datapath = uuid2name(sw.ls._uuid),
.tunnel_key = 0,
.parent_port = lsp.parent_name,
.tag = tag,
Expand Down Expand Up @@ -113,7 +113,7 @@ sb.Out_Port_Binding(.uuid_name = uuid_name,
.__type = __type,
.gateway_chassis = set_empty(),
.options = options,
.datapath = uuid2str(sw.ls._uuid),
.datapath = uuid2name(sw.ls._uuid),
.tunnel_key = 0,
.parent_port = lsp.parent_name,
.tag = set_empty(),
Expand All @@ -123,7 +123,7 @@ sb.Out_Port_Binding(.uuid_name = uuid_name,
&SwitchPort(.lsp = lsp,
.sw = &sw,
.peer = Some{&RouterPort{.router = &Router{.lr=lr}}}),
var uuid_name = uuid2str(lsp._uuid),
var uuid_name = uuid2name(lsp._uuid),
var eids = {
var eids = lsp.external_ids;
match (map_get(lsp.external_ids, "neutron:port_name")) {
Expand Down Expand Up @@ -153,7 +153,7 @@ sb.Out_Port_Binding(.uuid_name = uuid_name,
.__type = __type,
.gateway_chassis = set_empty(),
.options = map_union(map_union(options1, options2), extra_options),
.datapath = uuid2str(router.lr._uuid),
.datapath = uuid2name(router.lr._uuid),
.tunnel_key = 0,
.parent_port = set_empty(),
.tag = set_empty(), // always empty for router ports
Expand All @@ -162,7 +162,7 @@ sb.Out_Port_Binding(.uuid_name = uuid_name,
.external_ids = lrp.external_ids) :-
&RouterPort(.lrp = lrp, .router = &router),
RouterPortRAOptionsComplete(lrp._uuid, extra_options),
var uuid_name = uuid2str(lrp._uuid),
var uuid_name = uuid2name(lrp._uuid),
(var __type, var options1) = match (map_get(router.lr.options, "chassis")) {
/* TODO: derived ports */
None -> ("patch", map_empty(): Map<string, string>),
Expand Down Expand Up @@ -198,12 +198,12 @@ RouterPortRAOptionsComplete(lrp, map_empty()) :-
*/

/* Create derived ports */
sb.Out_Port_Binding(.uuid_name = "cr" ++ uuid2str(lrp._uuid),
sb.Out_Port_Binding(.uuid_name = "cr" ++ uuid2name(lrp._uuid),
.logical_port = lrp.name,
.__type = "chassisredirect",
.gateway_chassis = gateway_chassis,
.options = map_singleton("distributed-port", chassis_redirect_name(lrp.name)),
.datapath = uuid2str(lr_uuid),
.datapath = uuid2name(lr_uuid),
.tunnel_key = 0,
.parent_port = set_empty(),
.tag = set_empty(), //always empty for router ports
Expand All @@ -212,17 +212,17 @@ sb.Out_Port_Binding(.uuid_name = "cr" ++ uuid2str(lrp._uuid),
.external_ids = lrp.external_ids) :-
ChassisRedirectPort(lrp, lr_uuid),
var gateway_chassis = if (not set_is_empty(lrp.gateway_chassis)) {
set_map_uuid2str(lrp.gateway_chassis)
set_map_uuid2name(lrp.gateway_chassis)
} else {
set_singleton(uuid2str(lr_uuid))
set_singleton(uuid2name(lr_uuid))
}.

/* Create sb.Gateway_Chassis for derived ports.
* - For derived ports with non-empty gateway_chassis, clone nb.Gateway_Chassis to
* sb.Gateway_Chassis, replacing chassis_name's with matching sb.Chassis uuid's.
* - For derived ports with options:redirect-chassis, synthesize a fresh Gateway_Chassis
*/
sb.Out_Gateway_Chassis(.uuid_name = uuid2str(gateway_chassis_uuid),
sb.Out_Gateway_Chassis(.uuid_name = uuid2name(gateway_chassis_uuid),
.name = gw_chassis.name,
.chassis = set_singleton(chassis_uuid),
.priority = gw_chassis.priority,
Expand All @@ -233,7 +233,7 @@ sb.Out_Gateway_Chassis(.uuid_name = uuid2str(gateway_chassis_uuid),
gw_chassis in nb.Gateway_Chassis(._uuid = gateway_chassis_uuid),
sb.Chassis(._uuid = chassis_uuid, .name = gw_chassis.chassis_name).

sb.Out_Gateway_Chassis(.uuid_name = uuid2str(lr_uuid),
sb.Out_Gateway_Chassis(.uuid_name = uuid2name(lr_uuid),
.name = "${lrp.name}_${redirect_chassis}",
.chassis = set_singleton(chassis_uuid),
.priority = 0,
Expand Down Expand Up @@ -369,17 +369,17 @@ function mC_UNKNOWN(): string = "_MC_unknown"
sb.Out_Multicast_Group (.datapath = datapath,
.name = mC_FLOOD(),
.tunnel_key = 65535,
.ports = set_map_uuid2str(port_ids)) :-
.ports = set_map_uuid2name(port_ids)) :-
&SwitchPort(.lsp = lsp, .sw = &Switch{.ls = ls}),
is_enabled(lsp.enabled),
var datapath = uuid2str(ls._uuid),
var datapath = uuid2name(ls._uuid),
var port_ids = Aggregate((datapath), group2set(lsp._uuid)).

/* Only create unknown group if the switch has ports with "unknown" address */
sb.Out_Multicast_Group (.datapath = uuid2str(ls),
sb.Out_Multicast_Group (.datapath = uuid2name(ls),
.name = mC_UNKNOWN(),
.tunnel_key = 65534,
.ports = set_map_uuid2str(port_ids)) :-
.ports = set_map_uuid2name(port_ids)) :-
LogicalSwitchUnknownPorts(ls, port_ids).

/*
Expand Down Expand Up @@ -584,7 +584,7 @@ sb.Out_DNS(.records = nbdns.records,
.external_ids = nbdns.external_ids) :-
nb.DNS[nbdns],
LogicalSwitchDNS(ls_uuid, nbdns._uuid),
var datapaths = Aggregate((nbdns), group2set(uuid2str(ls_uuid))).
var datapaths = Aggregate((nbdns), group2set(uuid2name(ls_uuid))).

sb.Out_DNS(.records = nbdns.records,
.datapaths = set_empty(),
Expand Down Expand Up @@ -664,7 +664,7 @@ sb.Out_RBAC_Role (
).

/* Output modified Logical_Switch_Port table with dynamic address updated */
nb.Out_Logical_Switch_Port(.uuid_name = uuid2str(lsp._uuid),
nb.Out_Logical_Switch_Port(.uuid_name = uuid2name(lsp._uuid),
.name = lsp.name,
.__type = lsp.__type,
.options = lsp.options,
Expand Down Expand Up @@ -2219,7 +2219,7 @@ for (SwitchPortIPv6Address(.port = &SwitchPort{.lsp = lsp, .json_name = json_nam
/* Ingress table 11: ARP/ND responder, by default goto next.
* (priority 0)*/
for (ls in nb.Logical_Switch) {
var lsname = uuid2str(ls._uuid) in {
var lsname = uuid2name(ls._uuid) in {
sb.Out_Logical_Flow(.logical_datapath = lsname,
.pipeline = "ingress",
.table_id = switch_stage(IN, ARP_ND_RSP),
Expand Down Expand Up @@ -2393,7 +2393,7 @@ for (lsp in nb.Logical_Switch_Port
if is_enabled(lsp.enabled) and lsp.__type != "router")
{
for (lps in LogicalPortSwitch(.lport = lsp._uuid)) {
var lsname = uuid2str(lps.lswitch) in
var lsname = uuid2name(lps.lswitch) in
var json_key = json_string_escape(lsp.name) in
{
/* DHCPv4 options enabled for this port */
Expand Down Expand Up @@ -2501,7 +2501,7 @@ for (lsp in nb.Logical_Switch_Port
*/
for (LogicalSwitchHasDNSRecords(ls, true))
{
var lsname = uuid2str(ls) in
var lsname = uuid2name(ls) in
{
sb.Out_Logical_Flow(.logical_datapath = lsname,
.pipeline = "ingress",
Expand Down Expand Up @@ -2540,7 +2540,7 @@ for (LogicalSwitchHasDNSRecords(ls, true))
* Ingress table 14 and 15: DNS lookup and response, by default goto next.
* (priority 0).*/
for (ls in nb.Logical_Switch) {
var lsname = uuid2str(ls._uuid) in {
var lsname = uuid2name(ls._uuid) in {
sb.Out_Logical_Flow(.logical_datapath = lsname,
.pipeline = "ingress",
.table_id = switch_stage(IN, DHCP_OPTIONS),
Expand Down Expand Up @@ -2579,7 +2579,7 @@ for (ls in nb.Logical_Switch) {
/* Ingress table 16: Destination lookup, broadcast and multicast handling
* (priority 100). */
for (ls in nb.Logical_Switch) {
var lsname = uuid2str(ls._uuid) in
var lsname = uuid2name(ls._uuid) in
sb.Out_Logical_Flow(.logical_datapath = lsname,
.pipeline = "ingress",
.table_id = switch_stage(IN, L2_LKUP),
Expand Down Expand Up @@ -2657,7 +2657,7 @@ for (&SwitchPort(.lsp = lsp,

/* Ingress table 16: Destination lookup for unknown MACs (priority 0). */
for (LogicalSwitchUnknownPorts(.ls = ls_uuid)) {
var lsname = uuid2str(ls_uuid) in
var lsname = uuid2name(ls_uuid) in
sb.Out_Logical_Flow(.logical_datapath = lsname,
.pipeline = "ingress",
.table_id = switch_stage(IN, L2_LKUP),
Expand Down

0 comments on commit 2b7b7c8

Please sign in to comment.