[ovs-dev] [PATCH v4 04/14] ofp-util: Rename struct ofputil_packet_in member 'len' to 'packet_len'.

Jarno Rajahalme jarno at ovn.org
Fri Feb 19 22:19:28 UTC 2016


Acked-by: Jarno Rajahalme <jarno at ovn.org>

> On Feb 19, 2016, at 12:34 AM, Ben Pfaff <blp at ovn.org> wrote:
> 
> An upcoming commit will introduce another member that has a length, and
> it seems weird that bare 'len' would be one or the other.
> 
> Signed-off-by: Ben Pfaff <blp at ovn.org>
> ---
> lib/learning-switch.c        |  2 +-
> lib/ofp-print.c              | 10 +++++-----
> lib/ofp-util.c               | 42 +++++++++++++++++++++---------------------
> lib/ofp-util.h               |  2 +-
> ofproto/fail-open.c          |  2 +-
> ofproto/ofproto-dpif-xlate.c |  2 +-
> 6 files changed, 30 insertions(+), 30 deletions(-)
> 
> diff --git a/lib/learning-switch.c b/lib/learning-switch.c
> index 0027100..8f194b3 100644
> --- a/lib/learning-switch.c
> +++ b/lib/learning-switch.c
> @@ -540,7 +540,7 @@ process_packet_in(struct lswitch *sw, const struct ofp_header *oh)
>     }
> 
>     /* Extract flow data from 'pi' into 'flow'. */
> -    dp_packet_use_const(&pkt, pi.packet, pi.len);
> +    dp_packet_use_const(&pkt, pi.packet, pi.packet_len);
>     flow_extract(&pkt, &flow);
>     flow.in_port.ofp_port = pi.flow_metadata.flow.in_port.ofp_port;
>     flow.tunnel.tun_id = pi.flow_metadata.flow.tunnel.tun_id;
> diff --git a/lib/ofp-print.c b/lib/ofp-print.c
> index 3195376..74f0de6 100644
> --- a/lib/ofp-print.c
> +++ b/lib/ofp-print.c
> @@ -127,27 +127,27 @@ ofp_print_packet_in(struct ds *string, const struct ofp_header *oh,
>                                                      reasonbuf,
>                                                      sizeof reasonbuf));
> 
> -    ds_put_format(string, " data_len=%"PRIuSIZE, pin.len);
> +    ds_put_format(string, " data_len=%"PRIuSIZE, pin.packet_len);
>     if (buffer_id == UINT32_MAX) {
>         ds_put_format(string, " (unbuffered)");
> -        if (total_len != pin.len) {
> +        if (total_len != pin.packet_len) {
>             ds_put_format(string, " (***total_len != data_len***)");
>         }
>     } else {
>         ds_put_format(string, " buffer=0x%08"PRIx32, buffer_id);
> -        if (total_len < pin.len) {
> +        if (total_len < pin.packet_len) {
>             ds_put_format(string, " (***total_len < data_len***)");
>         }
>     }
>     ds_put_char(string, '\n');
> 
>     if (verbosity > 0) {
> -        char *packet = ofp_packet_to_string(pin.packet, pin.len);
> +        char *packet = ofp_packet_to_string(pin.packet, pin.packet_len);
>         ds_put_cstr(string, packet);
>         free(packet);
>     }
>     if (verbosity > 2) {
> -        ds_put_hex_dump(string, pin.packet, pin.len, 0, false);
> +        ds_put_hex_dump(string, pin.packet, pin.packet_len, 0, false);
>     }
> }
> 
> diff --git a/lib/ofp-util.c b/lib/ofp-util.c
> index d9dc0ad..38ee117 100644
> --- a/lib/ofp-util.c
> +++ b/lib/ofp-util.c
> @@ -3325,7 +3325,7 @@ decode_nx_packet_in2(const struct ofp_header *oh,
>         switch (type) {
>         case NXPINT_PACKET:
>             pin->packet = payload.msg;
> -            pin->len = ofpbuf_msgsize(&payload);
> +            pin->packet_len = ofpbuf_msgsize(&payload);
>             break;
> 
>         case NXPINT_FULL_LEN: {
> @@ -3368,12 +3368,12 @@ decode_nx_packet_in2(const struct ofp_header *oh,
>         }
>     }
> 
> -    if (!pin->len) {
> +    if (!pin->packet_len) {
>         VLOG_WARN_RL(&bad_ofmsg_rl, "NXT_PACKET_IN2 lacks packet");
>         return OFPERR_OFPBRC_BAD_LEN;
>     } else if (!*total_len) {
> -        *total_len = pin->len;
> -    } else if (*total_len < pin->len) {
> +        *total_len = pin->packet_len;
> +    } else if (*total_len < pin->packet_len) {
>         VLOG_WARN_RL(&bad_ofmsg_rl, "NXT_PACKET_IN2 claimed full_len < len");
>         return OFPERR_OFPBRC_BAD_LEN;
>     }
> @@ -3422,14 +3422,14 @@ ofputil_decode_packet_in(const struct ofp_header *oh,
>         }
> 
>         pin->packet = b.data;
> -        pin->len = b.size;
> +        pin->packet_len = b.size;
>     } else if (raw == OFPRAW_OFPT10_PACKET_IN) {
>         const struct ofp10_packet_in *opi;
> 
>         opi = ofpbuf_pull(&b, offsetof(struct ofp10_packet_in, data));
> 
>         pin->packet = CONST_CAST(uint8_t *, opi->data);
> -        pin->len = b.size;
> +        pin->packet_len = b.size;
> 
>         match_init_catchall(&pin->flow_metadata);
>         match_set_in_port(&pin->flow_metadata,
> @@ -3445,7 +3445,7 @@ ofputil_decode_packet_in(const struct ofp_header *oh,
>         opi = ofpbuf_pull(&b, sizeof *opi);
> 
>         pin->packet = b.data;
> -        pin->len = b.size;
> +        pin->packet_len = b.size;
> 
>         *buffer_id = ntohl(opi->buffer_id);
>         error = ofputil_port_from_ofp11(opi->in_port, &in_port);
> @@ -3480,7 +3480,7 @@ ofputil_decode_packet_in(const struct ofp_header *oh,
>         *total_len = ntohs(npi->total_len);
> 
>         pin->packet = b.data;
> -        pin->len = b.size;
> +        pin->packet_len = b.size;
>     } else if (raw == OFPRAW_NXT_PACKET_IN2) {
>         return decode_nx_packet_in2(oh, pin, total_len, buffer_id);
>     } else {
> @@ -3525,9 +3525,9 @@ ofputil_encode_ofp10_packet_in(const struct ofputil_packet_in *pin,
>     struct ofpbuf *msg;
> 
>     msg = ofpraw_alloc_xid(OFPRAW_OFPT10_PACKET_IN, OFP10_VERSION,
> -                           htonl(0), pin->len);
> +                           htonl(0), pin->packet_len);
>     opi = ofpbuf_put_zeros(msg, offsetof(struct ofp10_packet_in, data));
> -    opi->total_len = htons(pin->len);
> +    opi->total_len = htons(pin->packet_len);
>     opi->in_port = htons(ofp_to_u16(pin->flow_metadata.flow.in_port.ofp_port));
>     opi->reason = encode_packet_in_reason(pin->reason, OFP10_VERSION);
>     opi->buffer_id = htonl(buffer_id);
> @@ -3545,14 +3545,14 @@ ofputil_encode_nx_packet_in(const struct ofputil_packet_in *pin,
> 
>     /* The final argument is just an estimate of the space required. */
>     msg = ofpraw_alloc_xid(OFPRAW_NXT_PACKET_IN, version,
> -                           htonl(0), NXM_TYPICAL_LEN + 2 + pin->len);
> +                           htonl(0), NXM_TYPICAL_LEN + 2 + pin->packet_len);
>     ofpbuf_put_zeros(msg, sizeof *npi);
>     match_len = nx_put_match(msg, &pin->flow_metadata, 0, 0);
>     ofpbuf_put_zeros(msg, 2);
> 
>     npi = msg->msg;
>     npi->buffer_id = htonl(buffer_id);
> -    npi->total_len = htons(pin->len);
> +    npi->total_len = htons(pin->packet_len);
>     npi->reason = encode_packet_in_reason(pin->reason, version);
>     npi->table_id = pin->table_id;
>     npi->cookie = pin->cookie;
> @@ -3573,8 +3573,8 @@ ofputil_encode_nx_packet_in2(const struct ofputil_packet_in *pin,
> 
>     /* Add packet properties. */
>     ofpprop_put(msg, NXPINT_PACKET, pin->packet, include_bytes);
> -    if (include_bytes != pin->len) {
> -        ofpprop_put_u32(msg, NXPINT_FULL_LEN, pin->len);
> +    if (include_bytes != pin->packet_len) {
> +        ofpprop_put_u32(msg, NXPINT_FULL_LEN, pin->packet_len);
>     }
>     if (buffer_id != UINT32_MAX) {
>         ofpprop_put_u32(msg, NXPINT_BUFFER_ID, buffer_id);
> @@ -3606,13 +3606,13 @@ ofputil_encode_ofp11_packet_in(const struct ofputil_packet_in *pin,
>     struct ofpbuf *msg;
> 
>     msg = ofpraw_alloc_xid(OFPRAW_OFPT11_PACKET_IN, OFP11_VERSION,
> -                           htonl(0), pin->len);
> +                           htonl(0), pin->packet_len);
>     opi = ofpbuf_put_zeros(msg, sizeof *opi);
>     opi->buffer_id = htonl(buffer_id);
>     opi->in_port = ofputil_port_to_ofp11(
>         pin->flow_metadata.flow.in_port.ofp_port);
>     opi->in_phy_port = opi->in_port;
> -    opi->total_len = htons(pin->len);
> +    opi->total_len = htons(pin->packet_len);
>     opi->reason = encode_packet_in_reason(pin->reason, OFP11_VERSION);
>     opi->table_id = pin->table_id;
> 
> @@ -3631,11 +3631,11 @@ ofputil_encode_ofp12_packet_in(const struct ofputil_packet_in *pin,
> 
>     /* The final argument is just an estimate of the space required. */
>     msg = ofpraw_alloc_xid(raw, version,
> -                           htonl(0), NXM_TYPICAL_LEN + 2 + pin->len);
> +                           htonl(0), NXM_TYPICAL_LEN + 2 + pin->packet_len);
> 
>     struct ofp12_packet_in *opi = ofpbuf_put_zeros(msg, sizeof *opi);
>     opi->buffer_id = htonl(buffer_id);
> -    opi->total_len = htons(pin->len);
> +    opi->total_len = htons(pin->packet_len);
>     opi->reason = encode_packet_in_reason(pin->reason, version);
>     opi->table_id = pin->table_id;
> 
> @@ -3669,7 +3669,7 @@ ofputil_encode_packet_in(const struct ofputil_packet_in *pin,
>     ofp_port_t in_port = pin->flow_metadata.flow.in_port.ofp_port;
>     uint32_t buffer_id = (max_len != OFPCML12_NO_BUFFER && pktbuf
>                           ? pktbuf_save(pktbuf, pin->packet,
> -                                        pin->len, in_port)
> +                                        pin->packet_len, in_port)
>                           : UINT32_MAX);
> 
>     /* Calculate the number of bytes of the packet to include in the
> @@ -3679,8 +3679,8 @@ ofputil_encode_packet_in(const struct ofputil_packet_in *pin,
>      *
>      *    - Otherwise, no more than 'max_len' bytes. */
>     size_t include_bytes = (buffer_id == UINT32_MAX
> -                            ? pin->len
> -                            : MIN(max_len, pin->len));
> +                            ? pin->packet_len
> +                            : MIN(max_len, pin->packet_len));
> 
>     struct ofpbuf *msg;
>     switch (packet_in_format) {
> diff --git a/lib/ofp-util.h b/lib/ofp-util.h
> index 19bfc4b..9d9bb72 100644
> --- a/lib/ofp-util.h
> +++ b/lib/ofp-util.h
> @@ -427,7 +427,7 @@ struct ofputil_packet_in {
>      * the original packet.  ofputil_decode_packet_in() reports the full
>      * original length of the packet using its 'total_len' output parameter. */
>     void *packet;               /* The packet. */
> -    size_t len;                 /* Length of 'packet' in bytes. */
> +    size_t packet_len;          /* Length of 'packet' in bytes. */
> 
>     /* Input port and other metadata for packet. */
>     struct match flow_metadata;
> diff --git a/ofproto/fail-open.c b/ofproto/fail-open.c
> index a28acef..77b99ad 100644
> --- a/ofproto/fail-open.c
> +++ b/ofproto/fail-open.c
> @@ -130,7 +130,7 @@ send_bogus_packet_ins(struct fail_open *fo)
>         .pin = {
>             .up = {
>                 .packet = dp_packet_data(&b),
> -                .len = dp_packet_size(&b),
> +                .packet_len = dp_packet_size(&b),
>                 .flow_metadata = MATCH_CATCHALL_INITIALIZER,
>                 .flow_metadata.flow.in_port.ofp_port = OFPP_LOCAL,
>                 .flow_metadata.wc.masks.in_port.ofp_port
> diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
> index 8e68e7c..b4ea4f0 100644
> --- a/ofproto/ofproto-dpif-xlate.c
> +++ b/ofproto/ofproto-dpif-xlate.c
> @@ -3619,7 +3619,7 @@ execute_controller_action(struct xlate_ctx *ctx, int len,
>         .pin = {
>             .up = {
>                 .packet = dp_packet_steal_data(packet),
> -                .len = packet_len,
> +                .packet_len = packet_len,
>                 .reason = reason,
>                 .table_id = ctx->table_id,
>                 .cookie = ctx->rule_cookie,
> -- 
> 2.1.3
> 
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev




More information about the dev mailing list