lib/ofpbuf: Compact
[sliver-openvswitch.git] / lib / rconn.c
index 72688ba..a5368d5 100644 (file)
@@ -716,10 +716,15 @@ rconn_send__(struct rconn *rc, struct ofpbuf *b,
     if (rconn_is_connected(rc)) {
         COVERAGE_INC(rconn_queued);
         copy_to_monitor(rc, b);
-        b->private_p = counter;
+
         if (counter) {
             rconn_packet_counter_inc(counter, b->size);
         }
+
+        /* Use 'l2' as a private pointer while 'b' is in txq. */
+        ovs_assert(b->l2 == b->data);
+        b->l2 = counter;
+
         list_push_back(&rc->txq, &b->list_node);
 
         /* If the queue was empty before we added 'b', try to send some
@@ -1103,16 +1108,18 @@ try_send(struct rconn *rc)
 {
     struct ofpbuf *msg = ofpbuf_from_list(rc->txq.next);
     unsigned int n_bytes = msg->size;
-    struct rconn_packet_counter *counter = msg->private_p;
+    struct rconn_packet_counter *counter = msg->l2;
     int retval;
 
     /* Eagerly remove 'msg' from the txq.  We can't remove it from the list
      * after sending, if sending is successful, because it is then owned by the
      * vconn, which might have freed it already. */
     list_remove(&msg->list_node);
+    msg->l2 = msg->data; /* Restore 'l2'. */
 
     retval = vconn_send(rc->vconn, msg);
     if (retval) {
+        msg->l2 = counter; /* 'l2' is a private pointer while msg is in txq. */
         list_push_front(&rc->txq, &msg->list_node);
         if (retval != EAGAIN) {
             report_error(rc, retval);
@@ -1205,7 +1212,7 @@ flush_queue(struct rconn *rc)
     }
     while (!list_is_empty(&rc->txq)) {
         struct ofpbuf *b = ofpbuf_from_list(list_pop_front(&rc->txq));
-        struct rconn_packet_counter *counter = b->private_p;
+        struct rconn_packet_counter *counter = b->l2;
         if (counter) {
             rconn_packet_counter_dec(counter, b->size);
         }