[ovs-dev] [optimize 11/13] ofproto-dpif: Factor controller optimization out of execute_odp_actions().
Ethan Jackson
ethan at nicira.com
Thu Oct 13 22:33:32 UTC 2011
Looks good.
Ethan
On Tue, Sep 27, 2011 at 16:27, Ben Pfaff <blp at nicira.com> wrote:
> An upcoming commit will use this code separately from
> execute_odp_actions(), so this prepares for that.
> ---
> ofproto/ofproto-dpif.c | 53 +++++++++++++++++++++++++++++++----------------
> 1 files changed, 35 insertions(+), 18 deletions(-)
>
> diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
> index fb870be..7d7d6af 100644
> --- a/ofproto/ofproto-dpif.c
> +++ b/ofproto/ofproto-dpif.c
> @@ -263,6 +263,11 @@ static struct facet *facet_lookup_valid(struct ofproto_dpif *,
> const struct flow *);
> static bool facet_revalidate(struct ofproto_dpif *, struct facet *);
>
> +static bool execute_controller_action(struct ofproto_dpif *,
> + const struct flow *,
> + const struct nlattr *odp_actions,
> + size_t actions_len,
> + struct ofpbuf *packet);
> static void facet_execute(struct ofproto_dpif *, struct facet *,
> struct ofpbuf *packet);
>
> @@ -2184,14 +2189,11 @@ facet_free(struct facet *facet)
> free(facet);
> }
>
> -/* Executes, within 'ofproto', the 'n_actions' actions in 'actions' on
> - * 'packet', which arrived on 'in_port'.
> - *
> - * Takes ownership of 'packet'. */
> static bool
> -execute_odp_actions(struct ofproto_dpif *ofproto, const struct flow *flow,
> - const struct nlattr *odp_actions, size_t actions_len,
> - struct ofpbuf *packet)
> +execute_controller_action(struct ofproto_dpif *ofproto,
> + const struct flow *flow,
> + const struct nlattr *odp_actions, size_t actions_len,
> + struct ofpbuf *packet)
> {
> if (actions_len == NLA_ALIGN(NLA_HDRLEN + sizeof(uint64_t))
> && odp_actions->nla_type == OVS_ACTION_ATTR_USERSPACE) {
> @@ -2200,22 +2202,37 @@ execute_odp_actions(struct ofproto_dpif *ofproto, const struct flow *flow,
> * buffers along the way. */
> send_packet_in_action(ofproto, packet, nl_attr_get_u64(odp_actions),
> flow, false);
> -
> return true;
> } else {
> - struct odputil_keybuf keybuf;
> - struct ofpbuf key;
> - int error;
> -
> - ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
> - odp_flow_key_from_flow(&key, flow);
> + return false;
> + }
> +}
>
> - error = dpif_execute(ofproto->dpif, key.data, key.size,
> - odp_actions, actions_len, packet);
> +/* Executes, within 'ofproto', the 'n_actions' actions in 'actions' on
> + * 'packet', which arrived on 'in_port'.
> + *
> + * Takes ownership of 'packet'. */
> +static bool
> +execute_odp_actions(struct ofproto_dpif *ofproto, const struct flow *flow,
> + const struct nlattr *odp_actions, size_t actions_len,
> + struct ofpbuf *packet)
> +{
> + struct odputil_keybuf keybuf;
> + struct ofpbuf key;
> + int error;
>
> - ofpbuf_delete(packet);
> - return !error;
> + if (execute_controller_action(ofproto, flow, odp_actions, actions_len,
> + packet)) {
> + return true;
> }
> +
> + ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
> + odp_flow_key_from_flow(&key, flow);
> + error = dpif_execute(ofproto->dpif, key.data, key.size,
> + odp_actions, actions_len, packet);
> + ofpbuf_delete(packet);
> +
> + return !error;
> }
>
> /* Executes the actions indicated by 'facet' on 'packet' and credits 'facet''s
> --
> 1.7.4.4
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
More information about the dev
mailing list