X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Frconn.c;h=cb3cdd5d4aa7d1c13c4eab05832b3746aec6df90;hb=28c5588e8e1a8d091c5d2275232c35f2968a97fa;hp=d339365b286fc85fa41c5fb210e069c9b062288a;hpb=a8d819675f3525a5416ea355382b2e9c47cb2e74;p=sliver-openvswitch.git diff --git a/lib/rconn.c b/lib/rconn.c index d339365b2..cb3cdd5d4 100644 --- a/lib/rconn.c +++ b/lib/rconn.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc. + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -592,7 +592,15 @@ rconn_run(struct rconn *rc) ovs_mutex_lock(&rc->mutex); if (rc->vconn) { + int error; + vconn_run(rc->vconn); + + error = vconn_get_status(rc->vconn); + if (error) { + report_error(rc, error); + disconnect(rc, error); + } } for (i = 0; i < rc->n_monitors; ) { struct ofpbuf *msg; @@ -708,10 +716,14 @@ 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); + rconn_packet_counter_inc(counter, ofpbuf_size(b)); } + + /* Reuse 'frame' as a private pointer while 'b' is in txq. */ + ofpbuf_set_frame(b, counter); + list_push_back(&rc->txq, &b->list_node); /* If the queue was empty before we added 'b', try to send some @@ -1094,17 +1106,19 @@ try_send(struct rconn *rc) OVS_REQUIRES(rc->mutex) { struct ofpbuf *msg = ofpbuf_from_list(rc->txq.next); - unsigned int n_bytes = msg->size; - struct rconn_packet_counter *counter = msg->private_p; + unsigned int n_bytes = ofpbuf_size(msg); + struct rconn_packet_counter *counter = msg->frame; 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); + ofpbuf_set_frame(msg, NULL); retval = vconn_send(rc->vconn, msg); if (retval) { + ofpbuf_set_frame(msg, counter); list_push_front(&rc->txq, &msg->list_node); if (retval != EAGAIN) { report_error(rc, retval); @@ -1197,9 +1211,9 @@ 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->frame; if (counter) { - rconn_packet_counter_dec(counter, b->size); + rconn_packet_counter_dec(counter, ofpbuf_size(b)); } COVERAGE_INC(rconn_discarded); ofpbuf_delete(b); @@ -1309,7 +1323,7 @@ is_admitted_msg(const struct ofpbuf *b) enum ofptype type; enum ofperr error; - error = ofptype_decode(&type, b->data); + error = ofptype_decode(&type, ofpbuf_data(b)); if (error) { return false; }