Currently ct_lb() logical action is only added for a logical switch and we use the conntrack zone allocated for the logical port. A future commit will use ct_lb() for a logical router too. In that case, use the allocated DNAT zone.
Signed-off-by: Gurucharan Shetty <g...@ovn.org> --- include/ovn/actions.h | 3 +++ ovn/controller/lflow.c | 1 + ovn/lib/actions.c | 7 +++++-- ovn/ovn-sb.xml | 6 ++++-- tests/test-ovn.c | 1 + 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/ovn/actions.h b/include/ovn/actions.h index e2a716a..fd03c00 100644 --- a/include/ovn/actions.h +++ b/include/ovn/actions.h @@ -406,6 +406,9 @@ struct ovnact_encode_params { unsigned int *portp); const void *aux; + /* 'true' if the flow is for a switch. */ + bool is_switch; + /* A map from a port name to its connection tracking zone. */ const struct simap *ct_zones; diff --git a/ovn/controller/lflow.c b/ovn/controller/lflow.c index 341ca08..71167ef 100644 --- a/ovn/controller/lflow.c +++ b/ovn/controller/lflow.c @@ -419,6 +419,7 @@ consider_logical_flow(const struct lport_index *lports, struct ovnact_encode_params ep = { .lookup_port = lookup_port_cb, .aux = &aux, + .is_switch = is_switch(ldp), .ct_zones = ct_zones, .group_table = group_table, .lflow_uuid = lflow->header_.uuid, diff --git a/ovn/lib/actions.c b/ovn/lib/actions.c index 3908e1d..f2002cf 100644 --- a/ovn/lib/actions.c +++ b/ovn/lib/actions.c @@ -927,7 +927,8 @@ encode_CT_LB(const struct ovnact_ct_lb *cl, struct ofpact_conntrack *ct = ofpact_put_CT(ofpacts); struct ofpact_nat *nat; size_t nat_offset; - ct->zone_src.field = mf_from_id(MFF_LOG_CT_ZONE); + ct->zone_src.field = ep->is_switch ? mf_from_id(MFF_LOG_CT_ZONE) + : mf_from_id(MFF_LOG_DNAT_ZONE); ct->zone_src.ofs = 0; ct->zone_src.n_bits = 16; ct->flags = 0; @@ -951,6 +952,8 @@ encode_CT_LB(const struct ovnact_ct_lb *cl, uint32_t group_id = 0, hash; struct group_info *group_info; struct ofpact_group *og; + uint32_t zone_reg = ep->is_switch ? MFF_LOG_CT_ZONE - MFF_REG0 + : MFF_LOG_DNAT_ZONE - MFF_REG0; struct ds ds = DS_EMPTY_INITIALIZER; ds_put_format(&ds, "type=select"); @@ -965,7 +968,7 @@ encode_CT_LB(const struct ovnact_ct_lb *cl, ds_put_format(&ds, ":%"PRIu16, dst->port); } ds_put_format(&ds, "),commit,table=%d,zone=NXM_NX_REG%d[0..15])", - recirc_table, MFF_LOG_CT_ZONE - MFF_REG0); + recirc_table, zone_reg); } hash = hash_string(ds_cstr(&ds), 0); diff --git a/ovn/ovn-sb.xml b/ovn/ovn-sb.xml index e119249..235c21c 100644 --- a/ovn/ovn-sb.xml +++ b/ovn/ovn-sb.xml @@ -1345,8 +1345,10 @@ DNAT address. Processing automatically moves on to the next table, as if <code>next;</code> were specified, and later tables act on the packet as modified by the connection tracker. Connection - tracking state is scoped by the logical port, so overlapping - addresses may be used. + tracking state is scoped by the logical port when the action is + used in a flow for a logical switch, so overlapping + addresses may be used. Connection tracking state is scoped by the + logical topology when the action is used in a flow for a router. </p> <p> Without arguments, <code>ct_lb</code> sends the packet to the diff --git a/tests/test-ovn.c b/tests/test-ovn.c index 0ef09ab..837399e 100644 --- a/tests/test-ovn.c +++ b/tests/test-ovn.c @@ -1181,6 +1181,7 @@ test_parse_actions(struct ovs_cmdl_context *ctx OVS_UNUSED) const struct ovnact_encode_params ep = { .lookup_port = lookup_port_cb, .aux = &ports, + .is_switch = true, .ct_zones = &ct_zones, .group_table = &group_table, -- 1.9.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev