[ovs-dev] [packet-in 3/8] connmgr: Move send_len from ofputil_packet_in to ofproto_packet_in.

Ben Pfaff blp at nicira.com
Wed Oct 23 05:05:15 UTC 2013


send_len is not directly part of the OpenFlow packet_in message, at least
given that it is partially redundant with packet_len.  send_len is, rather,
a request to the connmgr that expresses how many bytes the action requested
be sent to the controller, but the connmgr cannot always honor it.

Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 lib/ofp-util.c                |   13 ++++++-------
 lib/ofp-util.h                |    1 -
 ofproto/connmgr.c             |    9 ++++-----
 ofproto/connmgr.h             |    1 +
 ofproto/fail-open.c           |    2 +-
 ofproto/ofproto-dpif-upcall.c |    3 +--
 ofproto/ofproto-dpif-xlate.c  |    2 +-
 7 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 991a943..e295c20 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -2940,7 +2940,6 @@ ofputil_encode_packet_in(const struct ofputil_packet_in *pin,
                          enum ofputil_protocol protocol,
                          enum nx_packet_in_format packet_in_format)
 {
-    size_t send_len = MIN(pin->send_len, pin->packet_len);
     struct ofpbuf *packet;
 
     /* Add OFPT_PACKET_IN. */
@@ -2966,11 +2965,11 @@ ofputil_encode_packet_in(const struct ofputil_packet_in *pin,
         /* The final argument is just an estimate of the space required. */
         packet = ofpraw_alloc_xid(packet_in_raw, packet_in_version,
                                   htonl(0), (sizeof(struct flow_metadata) * 2
-                                             + 2 + send_len));
+                                             + 2 + pin->packet_len));
         ofpbuf_put_zeros(packet, packet_in_size);
         oxm_put_match(packet, &match);
         ofpbuf_put_zeros(packet, 2);
-        ofpbuf_put(packet, pin->packet, send_len);
+        ofpbuf_put(packet, pin->packet, pin->packet_len);
 
         opi = packet->l3;
         opi->pi.buffer_id = htonl(pin->buffer_id);
@@ -2984,14 +2983,14 @@ ofputil_encode_packet_in(const struct ofputil_packet_in *pin,
         struct ofp10_packet_in *opi;
 
         packet = ofpraw_alloc_xid(OFPRAW_OFPT10_PACKET_IN, OFP10_VERSION,
-                                  htonl(0), send_len);
+                                  htonl(0), pin->packet_len);
         opi = ofpbuf_put_zeros(packet, offsetof(struct ofp10_packet_in, data));
         opi->total_len = htons(pin->total_len);
         opi->in_port = htons(ofp_to_u16(pin->fmd.in_port));
         opi->reason = pin->reason;
         opi->buffer_id = htonl(pin->buffer_id);
 
-        ofpbuf_put(packet, pin->packet, send_len);
+        ofpbuf_put(packet, pin->packet, pin->packet_len);
     } else if (packet_in_format == NXPIF_NXM) {
         struct nx_packet_in *npi;
         struct match match;
@@ -3002,11 +3001,11 @@ ofputil_encode_packet_in(const struct ofputil_packet_in *pin,
         /* The final argument is just an estimate of the space required. */
         packet = ofpraw_alloc_xid(OFPRAW_NXT_PACKET_IN, OFP10_VERSION,
                                   htonl(0), (sizeof(struct flow_metadata) * 2
-                                             + 2 + send_len));
+                                             + 2 + pin->packet_len));
         ofpbuf_put_zeros(packet, sizeof *npi);
         match_len = nx_put_match(packet, &match, 0, 0);
         ofpbuf_put_zeros(packet, 2);
-        ofpbuf_put(packet, pin->packet, send_len);
+        ofpbuf_put(packet, pin->packet, pin->packet_len);
 
         npi = packet->l3;
         npi->buffer_id = htonl(pin->buffer_id);
diff --git a/lib/ofp-util.h b/lib/ofp-util.h
index 9dff763..b1275d7 100644
--- a/lib/ofp-util.h
+++ b/lib/ofp-util.h
@@ -384,7 +384,6 @@ struct ofputil_packet_in {
     ovs_be64 cookie;
 
     uint32_t buffer_id;
-    int send_len;
     uint16_t total_len;         /* Full length of frame. */
 
     struct flow_metadata fmd;   /* Metadata at creation time. */
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index bd6e934..f5bef59 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -1521,7 +1521,7 @@ schedule_packet_in(struct ofconn *ofconn, struct ofproto_packet_in pin)
     pin.up.total_len = pin.up.packet_len;
 
     if (pin.up.reason == OFPR_ACTION) {
-        controller_max_len = pin.up.send_len;  /* max_len */
+        controller_max_len = pin.send_len;  /* max_len */
     } else {
         controller_max_len = ofconn->miss_send_len;
     }
@@ -1544,10 +1544,9 @@ schedule_packet_in(struct ofconn *ofconn, struct ofproto_packet_in pin)
     /* Figure out how much of the packet to send.
      * If not buffered, send the entire packet.  Otherwise, depending on
      * the reason of packet-in, send what requested by the controller. */
-    if (pin.up.buffer_id == UINT32_MAX) {
-        pin.up.send_len = pin.up.packet_len;
-    } else {
-        pin.up.send_len = MIN(pin.up.packet_len, controller_max_len);
+    if (pin.up.buffer_id != UINT32_MAX
+        && controller_max_len < pin.up.packet_len) {
+        pin.up.packet_len = controller_max_len;
     }
 
     /* Make OFPT_PACKET_IN and hand over to packet scheduler.  It might
diff --git a/ofproto/connmgr.h b/ofproto/connmgr.h
index 6cbbf17..e9ffbbc 100644
--- a/ofproto/connmgr.h
+++ b/ofproto/connmgr.h
@@ -67,6 +67,7 @@ struct ofproto_packet_in {
     struct ofputil_packet_in up;
     struct list list_node;      /* For queuing. */
     uint16_t controller_id;     /* Controller ID to send to. */
+    int send_len;               /* Length that the action requested sending. */
 };
 
 /* Basics. */
diff --git a/ofproto/fail-open.c b/ofproto/fail-open.c
index 40859a4..b0caf8d 100644
--- a/ofproto/fail-open.c
+++ b/ofproto/fail-open.c
@@ -128,8 +128,8 @@ send_bogus_packet_ins(struct fail_open *fo)
     pin.up.packet = b.data;
     pin.up.packet_len = b.size;
     pin.up.reason = OFPR_NO_MATCH;
-    pin.up.send_len = b.size;
     pin.up.fmd.in_port = OFPP_LOCAL;
+    pin.send_len = b.size;
     connmgr_send_packet_in(fo->connmgr, &pin);
 
     ofpbuf_uninit(&b);
diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c
index ec4fc5c..cc10ed6 100644
--- a/ofproto/ofproto-dpif-upcall.c
+++ b/ofproto/ofproto-dpif-upcall.c
@@ -847,9 +847,8 @@ handle_upcalls(struct udpif *udpif, struct list *upcalls)
             pin->up.reason = OFPR_NO_MATCH;
             pin->up.table_id = 0;
             pin->up.cookie = 0;
-            pin->up.send_len = 0; /* Not used for flow table misses. */
             flow_get_metadata(&miss->flow, &pin->up.fmd);
-            pin->controller_id = 0;
+            pin->send_len = 0; /* Not used for flow table misses. */
             ofproto_dpif_send_packet_in(miss->ofproto, pin);
         }
     }
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 004a105..8308dd3 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -1850,10 +1850,10 @@ execute_controller_action(struct xlate_ctx *ctx, int len,
     pin->up.table_id = ctx->table_id;
     pin->up.cookie = ctx->rule ? rule_dpif_get_flow_cookie(ctx->rule) : 0;
 
-    pin->up.send_len = len;
     flow_get_metadata(&ctx->xin->flow, &pin->up.fmd);
 
     pin->controller_id = controller_id;
+    pin->send_len = len;
     ofproto_dpif_send_packet_in(ctx->xbridge->ofproto, pin);
     ofpbuf_delete(packet);
 }
-- 
1.7.10.4




More information about the dev mailing list