From 121f205298ec92265fb769f7e27103c279dd54f1 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 26 Mar 2010 14:37:16 -0700 Subject: [PATCH] ofproto: Factor out check on rule->send_flow_removed in send_flow_removed(). There's no point in even iterating over the list of OpenFlow connections if rule->send_flow_removed is false, since we'll never actually do anything in that case anyway. --- ofproto/ofproto.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 6ef8b3b2d..6976a0e1f 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -3367,34 +3367,34 @@ uninstall_idle_flow(struct ofproto *ofproto, struct rule *rule) static void send_flow_removed(struct ofproto *p, struct rule *rule, uint8_t reason) { - long long int now = time_msec(); - struct ofconn *ofconn; - struct ofconn *prev; - struct ofpbuf *buf = NULL; - /* We limit the maximum number of queued flow expirations it by accounting * them under the counter for replies. That works because preventing * OpenFlow requests from being processed also prevents new flows from * being added (and expiring). (It also prevents processing OpenFlow * requests that would not add new flows, so it is imperfect.) */ - prev = NULL; - LIST_FOR_EACH (ofconn, struct ofconn, node, &p->all_conns) { - if (rule->send_flow_removed && rconn_is_connected(ofconn->rconn)) { - if (prev) { - queue_tx(ofpbuf_clone(buf), prev, prev->reply_counter); - } else { - buf = compose_flow_removed(rule, now, reason); + if (rule->send_flow_removed) { + long long int now = time_msec(); + struct ofconn *prev = NULL; + struct ofpbuf *buf = NULL; + struct ofconn *ofconn; + + LIST_FOR_EACH (ofconn, struct ofconn, node, &p->all_conns) { + if (rconn_is_connected(ofconn->rconn)) { + if (prev) { + queue_tx(ofpbuf_clone(buf), prev, prev->reply_counter); + } else { + buf = compose_flow_removed(rule, now, reason); + } + prev = ofconn; } - prev = ofconn; } - } - if (prev) { - queue_tx(buf, prev, prev->reply_counter); + if (prev) { + queue_tx(buf, prev, prev->reply_counter); + } } } - static void expire_rule(struct cls_rule *cls_rule, void *p_) { -- 2.47.0