ofp-util: Rename struct ofputil_packet_in member 'len' to 'packet_len'.
authorBen Pfaff <blp@ovn.org>
Wed, 17 Feb 2016 08:31:11 +0000 (00:31 -0800)
committerBen Pfaff <blp@ovn.org>
Sat, 20 Feb 2016 00:15:44 +0000 (16:15 -0800)
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@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
lib/learning-switch.c
lib/ofp-print.c
lib/ofp-util.c
lib/ofp-util.h
ofproto/fail-open.c
ofproto/ofproto-dpif-xlate.c

index 0027100..8f194b3 100644 (file)
@@ -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;
index 3195376..74f0de6 100644 (file)
@@ -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);
     }
 }
 
index eba72a3..37e6e8a 100644 (file)
@@ -3327,7 +3327,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: {
@@ -3370,12 +3370,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;
     }
@@ -3424,14 +3424,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,
@@ -3447,7 +3447,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);
@@ -3482,7 +3482,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 {
@@ -3527,9 +3527,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);
@@ -3547,14 +3547,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;
@@ -3575,8 +3575,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);
@@ -3608,13 +3608,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;
 
@@ -3633,11 +3633,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;
 
@@ -3671,7 +3671,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
@@ -3681,8 +3681,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) {
index 19bfc4b..9d9bb72 100644 (file)
@@ -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;
index a28acef..77b99ad 100644 (file)
@@ -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
index e7b37a9..64c45de 100644 (file)
@@ -3634,7 +3634,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,