Skip to content

Commit

Permalink
dpif: Pass flow parameter to dpif_execute().
Browse files Browse the repository at this point in the history
All the callers of the function already have a copy of the extracted
flow in their stack (or a few frames before).

This is useful for different resons:
* It forces the callers to also call flow_extract() on the packet, which
  is necessary to initialize the l2,l3,l4 pointers.
* It will be used in the userspace datapath to generate the RSS hash by
  a following commit
* It can be used by the userspace connection tracker to avoid extracting
  the l3 type again.

Signed-off-by: Daniele Di Proietto <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
  • Loading branch information
ddiproietto committed May 20, 2016
1 parent 362ad4b commit 1cceb31
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/dpif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,7 @@ dpif_flow_dump_next(struct dpif_flow_dump_thread *thread,

struct dpif_execute_helper_aux {
struct dpif *dpif;
const struct flow *flow;
int error;
};

Expand Down Expand Up @@ -1124,6 +1125,7 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch *packets_,
}

execute.packet = packet;
execute.flow = aux->flow;
execute.needs_help = false;
execute.probe = false;
execute.mtu = 0;
Expand Down Expand Up @@ -1158,7 +1160,7 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch *packets_,
static int
dpif_execute_with_help(struct dpif *dpif, struct dpif_execute *execute)
{
struct dpif_execute_helper_aux aux = {dpif, 0};
struct dpif_execute_helper_aux aux = {dpif, execute->flow, 0};
struct dp_packet_batch pb;

COVERAGE_INC(dpif_execute_with_help);
Expand Down
1 change: 1 addition & 0 deletions lib/dpif.h
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ struct dpif_execute {
bool probe; /* Suppress error messages. */
unsigned int mtu; /* Maximum transmission unit to fragment.
0 if not a fragmented packet */
const struct flow *flow; /* Flow extracted from 'packet'. */

/* Input, but possibly modified as a side effect of execution. */
struct dp_packet *packet; /* Packet to execute. */
Expand Down
1 change: 1 addition & 0 deletions ofproto/ofproto-dpif-upcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,7 @@ handle_upcalls(struct udpif *udpif, struct upcall *upcalls,
op->ukey = NULL;
op->dop.type = DPIF_OP_EXECUTE;
op->dop.u.execute.packet = CONST_CAST(struct dp_packet *, packet);
op->dop.u.execute.flow = upcall->flow;
odp_key_to_pkt_metadata(upcall->key, upcall->key_len,
&op->dop.u.execute.packet->md);
op->dop.u.execute.actions = upcall->odp_actions.data;
Expand Down
10 changes: 10 additions & 0 deletions ofproto/ofproto-dpif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,7 @@ check_variable_length_userdata(struct dpif_backer *backer)
struct ofpbuf actions;
struct dpif_execute execute;
struct dp_packet packet;
struct flow flow;
size_t start;
int error;

Expand All @@ -1083,11 +1084,14 @@ check_variable_length_userdata(struct dpif_backer *backer)
eth = dp_packet_put_zeros(&packet, ETH_HEADER_LEN);
eth->eth_type = htons(0x1234);

flow_extract(&packet, &flow);

/* Execute the actions. On older datapaths this fails with ERANGE, on
* newer datapaths it succeeds. */
execute.actions = actions.data;
execute.actions_len = actions.size;
execute.packet = &packet;
execute.flow = &flow;
execute.needs_help = false;
execute.probe = true;
execute.mtu = 0;
Expand Down Expand Up @@ -1164,6 +1168,7 @@ check_masked_set_action(struct dpif_backer *backer)
struct ofpbuf actions;
struct dpif_execute execute;
struct dp_packet packet;
struct flow flow;
int error;
struct ovs_key_ethernet key, mask;

Expand All @@ -1182,11 +1187,14 @@ check_masked_set_action(struct dpif_backer *backer)
eth = dp_packet_put_zeros(&packet, ETH_HEADER_LEN);
eth->eth_type = htons(0x1234);

flow_extract(&packet, &flow);

/* Execute the actions. On older datapaths this fails with EINVAL, on
* newer datapaths it succeeds. */
execute.actions = actions.data;
execute.actions_len = actions.size;
execute.packet = &packet;
execute.flow = &flow;
execute.needs_help = false;
execute.probe = true;
execute.mtu = 0;
Expand Down Expand Up @@ -3708,6 +3716,7 @@ ofproto_dpif_execute_actions__(struct ofproto_dpif *ofproto,

pkt_metadata_from_flow(&packet->md, flow);
execute.packet = packet;
execute.flow = flow;
execute.needs_help = (xout.slow & SLOW_ACTION) != 0;
execute.probe = false;
execute.mtu = 0;
Expand Down Expand Up @@ -4420,6 +4429,7 @@ nxt_resume(struct ofproto *ofproto_,
.actions_len = odp_actions.size,
.needs_help = (slow & SLOW_ACTION) != 0,
.packet = &packet,
.flow = &headers,
};
dpif_execute(ofproto->backer->dpif, &execute);

Expand Down

0 comments on commit 1cceb31

Please sign in to comment.