[ovs-dev] [PATCH v4 05/10] Native Set-Field action.

Jarno Rajahalme jrajahalme at nicira.com
Fri Nov 1 22:22:34 UTC 2013


Fair enough ;-)

  Jarno

On Nov 1, 2013, at 3:02 PM, Ben Pfaff <blp at nicira.com> wrote:

> On Thu, Oct 24, 2013 at 01:19:29PM -0700, Jarno Rajahalme wrote:
>> Signed-off-by: Jarno Rajahalme <jrajahalme at nicira.com>
> 
> I'm going to fold this in:
> 
> diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c
> index a9d4340..9f31449 100644
> --- a/lib/ofp-actions.c
> +++ b/lib/ofp-actions.c
> @@ -793,7 +793,7 @@ set_field_from_openflow(const struct ofp12_action_set_field *oasf,
>         return OFPERR_OFPBAC_BAD_SET_ARGUMENT;
>     }
>     sf = ofpact_put_SET_FIELD(ofpacts);
> -    sf->field = mf->id;
> +    sf->field = mf;
>     memcpy(&sf->value, oasf + 1, mf->n_bytes);
> 
>     /* The value must be valid for match and must have the OFPVID_PRESENT bit
> @@ -816,17 +816,16 @@ static void
> set_field_to_ofast(const struct ofpact_set_field *sf,
>                    struct ofpbuf *openflow)
> {
> -    const struct mf_field *mf = mf_from_id(sf->field);
> -    uint16_t padded_value_len = ROUND_UP(mf->n_bytes, 8);
> +    uint16_t padded_value_len = ROUND_UP(sf->field->n_bytes, 8);
>     struct ofp12_action_set_field *oasf;
>     char *value;
> 
>     oasf = ofputil_put_OFPAT12_SET_FIELD(openflow);
> -    oasf->dst = htonl(mf->oxm_header);
> +    oasf->dst = htonl(sf->field->oxm_header);
>     oasf->len = htons(ntohs(oasf->len) + padded_value_len);
> 
>     value = ofpbuf_put_zeros(openflow, padded_value_len);
> -    memcpy(value, &sf->value, mf->n_bytes);
> +    memcpy(value, &sf->value, sf->field->n_bytes);
> }
> 
> static void
> @@ -834,16 +833,14 @@ set_field_to_openflow(const struct ofpact_set_field *sf,
>                       struct ofpbuf *openflow)
> {
>     struct ofp_header *oh = (struct ofp_header *)openflow->l2;
> +    const struct mf_field *mf = sf->field;
>     struct nx_action_reg_load *narl;
> -    const struct mf_field *mf;
> 
>     if (oh->version >= OFP12_VERSION) {
>         set_field_to_ofast(sf, openflow);
>         return;
>     }
> 
> -    mf = mf_from_id(sf->field);
> -
>     /* Convert to one or two REG_LOADs */
> 
>     if (mf->n_bits > 64) {
> @@ -1780,7 +1777,7 @@ ofpact_check__(struct ofpact *a, struct flow *flow, ofp_port_t max_ports,
>         return nxm_reg_load_check(ofpact_get_REG_LOAD(a), flow);
> 
>     case OFPACT_SET_FIELD:
> -        mf = mf_from_id(ofpact_get_SET_FIELD(a)->field);
> +        mf = ofpact_get_SET_FIELD(a)->field;
>         /* Require OXM_OF_VLAN_VID to have an existing VLAN header. */
>         if (!mf_are_prereqs_ok(mf, flow) ||
>             (mf->id == MFF_VLAN_VID && !(flow->vlan_tci & htons(VLAN_CFI)))) {
> @@ -2967,7 +2964,7 @@ ofpact_format(const struct ofpact *a, struct ds *s)
> 
>     case OFPACT_SET_FIELD:
>         set_field = ofpact_get_SET_FIELD(a);
> -        mf = mf_from_id(set_field->field);
> +        mf = set_field->field;
>         ds_put_format(s, "set_field:");
>         /* RFC: Print VLAN VID without the OFPVID_PRESENT bit. */
>         if (mf->id == MFF_VLAN_VID) {
> diff --git a/lib/ofp-actions.h b/lib/ofp-actions.h
> index 1809db0..233a31b 100644
> --- a/lib/ofp-actions.h
> +++ b/lib/ofp-actions.h
> @@ -378,7 +378,7 @@ enum ofpact_mpls_position {
>  * Used for OFPAT12_SET_FIELD. */
> struct ofpact_set_field {
>     struct ofpact ofpact;
> -    enum mf_field_id field;
> +    const struct mf_field *field;
>     union mf_value value; /* Most-significant bits are used. */
> };
> 
> diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c
> index 7b19dc0..0fb32d5 100644
> --- a/lib/ofp-parse.c
> +++ b/lib/ofp-parse.c
> @@ -489,7 +489,7 @@ set_field_parse__(char *arg, struct ofpbuf *ofpacts,
>     if (!mf->writable) {
>         return xasprintf("%s is read-only", key);
>     }
> -    sf->field = mf->id;
> +    sf->field = mf;
>     delim[0] = '\0';
>     error = mf_parse_value(mf, value, &sf->value);
>     if (error) {
> diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
> index f8c4f5f..1b849d2 100644
> --- a/ofproto/ofproto-dpif-xlate.c
> +++ b/ofproto/ofproto-dpif-xlate.c
> @@ -2440,7 +2440,7 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len,
> 
>         case OFPACT_SET_FIELD:
>             set_field = ofpact_get_SET_FIELD(a);
> -            mf = mf_from_id(set_field->field);
> +            mf = set_field->field;
>             mf_mask_field_and_prereqs(mf, &wc->masks);
> 
>             /* Set field action only ever overwrites packet's outermost




More information about the dev mailing list