@@ -1837,23 +1837,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;
}
@@ -1876,6 +1875,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,
@@ -2115,10 +2121,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) {
@@ -2133,26 +2139,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);
}
}
}
@@ -5083,24 +5083,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)
@@ -208,7 +208,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 *,
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> --- ofproto/ofproto-dpif-upcall.c | 48 ++++++++++++++++++++----------------------- ofproto/ofproto-dpif-xlate.c | 18 ---------------- ofproto/ofproto-dpif-xlate.h | 1 - 3 files changed, 22 insertions(+), 45 deletions(-)