Skip to content

Commit

Permalink
revalidator: Reuse xlate_ukey from deletion.
Browse files Browse the repository at this point in the history
This code was already very similar to the actual revalidation code, but
previously it wasn't structured quite closely enough to share it. Do so.

xlate_actions_for_side_effects() is now unused, so remove it.

Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
  • Loading branch information
joestringer committed Sep 29, 2016
1 parent 95beec1 commit dd0dc9e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 45 deletions.
48 changes: 22 additions & 26 deletions ofproto/ofproto-dpif-upcall.c
Expand Up @@ -1850,23 +1850,22 @@ struct reval_context {
struct flow flow;
};

/* Translates 'ukey->key' into a flow, populating 'ctx' as it goes along.
/* Translates 'key' into a flow, populating 'ctx' as it goes along.
*
* Returns 0 on success, otherwise a positive errno value.
*
* The caller is responsible for uninitializing ctx->xout on success.
*/
static int
xlate_ukey(struct udpif *udpif, const struct udpif_key *ukey,
const struct dpif_flow_stats *push, struct reval_context *ctx)
xlate_key(struct udpif *udpif, const struct nlattr *key, unsigned int len,
const struct dpif_flow_stats *push, struct reval_context *ctx)
{
struct ofproto_dpif *ofproto;
ofp_port_t ofp_in_port;
struct xlate_in xin;
int error;

if (odp_flow_key_to_flow(ukey->key, ukey->key_len, &ctx->flow)
== ODP_FIT_ERROR) {
if (odp_flow_key_to_flow(key, len, &ctx->flow) == ODP_FIT_ERROR) {
return EINVAL;
}

Expand All @@ -1889,6 +1888,13 @@ xlate_ukey(struct udpif *udpif, const struct udpif_key *ukey,
return 0;
}

static int
xlate_ukey(struct udpif *udpif, const struct udpif_key *ukey,
const struct dpif_flow_stats *push, struct reval_context *ctx)
{
return xlate_key(udpif, ukey->key, ukey->key_len, push, ctx);
}

static enum reval_result
revalidate_ukey__(struct udpif *udpif, struct udpif_key *ukey,
const struct dpif_flow_stats *push,
Expand Down Expand Up @@ -2127,10 +2133,10 @@ push_dp_ops(struct udpif *udpif, struct ukey_op *ops, size_t n_ops)
if (push->n_packets || netflow_exists()) {
const struct nlattr *key = op->dop.u.flow_del.key;
size_t key_len = op->dop.u.flow_del.key_len;
struct ofproto_dpif *ofproto;
struct netflow *netflow;
ofp_port_t ofp_in_port;
struct flow flow;
struct reval_context ctx = {
.netflow = &netflow,
};
int error;

if (op->ukey) {
Expand All @@ -2145,26 +2151,16 @@ push_dp_ops(struct udpif *udpif, struct ukey_op *ops, size_t n_ops)
key_len = op->ukey->key_len;
}

if (odp_flow_key_to_flow(key, key_len, &flow)
== ODP_FIT_ERROR) {
continue;
}

error = xlate_lookup(udpif->backer, &flow, &ofproto, NULL, NULL,
&netflow, &ofp_in_port);
if (!error) {
struct xlate_in xin;

xlate_in_init(&xin, ofproto,
ofproto_dpif_get_tables_version(ofproto),
&flow, ofp_in_port, NULL,
push->tcp_flags, NULL, NULL, NULL);
xin.resubmit_stats = push->n_packets ? push : NULL;
xin.allow_side_effects = push->n_packets > 0;
xlate_actions_for_side_effects(&xin);
error = xlate_key(udpif, key, key_len, push, &ctx);
if (error) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);

VLOG_WARN_RL(&rl, "xlate_actions failed (%s)!",
xlate_strerror(error));
} else {
xlate_out_uninit(&ctx.xout);
if (netflow) {
netflow_flow_clear(netflow, &flow);
netflow_flow_clear(netflow, &ctx.flow);
}
}
}
Expand Down
18 changes: 0 additions & 18 deletions ofproto/ofproto-dpif-xlate.c
Expand Up @@ -5100,24 +5100,6 @@ xlate_out_uninit(struct xlate_out *xout)
recirc_refs_unref(&xout->recircs);
}
}

/* Translates the 'ofpacts_len' bytes of "struct ofpact"s starting at 'ofpacts'
* into datapath actions, using 'ctx', and discards the datapath actions. */
void
xlate_actions_for_side_effects(struct xlate_in *xin)
{
struct xlate_out xout;
enum xlate_error error;

error = xlate_actions(xin, &xout);
if (error) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);

VLOG_WARN_RL(&rl, "xlate_actions failed (%s)!", xlate_strerror(error));
}

xlate_out_uninit(&xout);
}

static struct skb_priority_to_dscp *
get_skb_priority(const struct xport *xport, uint32_t skb_priority)
Expand Down
1 change: 0 additions & 1 deletion ofproto/ofproto-dpif-xlate.h
Expand Up @@ -213,7 +213,6 @@ void xlate_in_init(struct xlate_in *, struct ofproto_dpif *, ovs_version_t,
uint16_t tcp_flags, const struct dp_packet *packet,
struct flow_wildcards *, struct ofpbuf *odp_actions);
void xlate_out_uninit(struct xlate_out *);
void xlate_actions_for_side_effects(struct xlate_in *);

enum ofperr xlate_resume(struct ofproto_dpif *,
const struct ofputil_packet_in_private *,
Expand Down

0 comments on commit dd0dc9e

Please sign in to comment.