[ovs-dev] [PATCH] ofproto: Limit log rate when controller disconnected.

nickcooper-zhangtonghao nic at opencloud.tech
Fri Mar 24 12:16:32 UTC 2017


There are a lot of logs when OvS bridges can’t connect
to controllers. The controller may stop or something
causes a disruption in network traffic.

Signed-off-by: nickcooper-zhangtonghao <nic at opencloud.tech>
---
 lib/rconn.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/rconn.c b/lib/rconn.c
index 8a29864..8ba5106 100644
--- a/lib/rconn.c
+++ b/lib/rconn.c
@@ -455,9 +455,10 @@ reconnect(struct rconn *rc)
     OVS_REQUIRES(rc->mutex)
 {
     int retval;
+    static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
 
     if (rconn_logging_connection_attempts__(rc)) {
-        VLOG_INFO("%s: connecting...", rc->name);
+        VLOG_INFO_RL(&rl, "%s: connecting...", rc->name);
     }
     rc->n_attempted_connections++;
     retval = vconn_open(rc->target, rc->allowed_versions, rc->dscp,
@@ -466,8 +467,8 @@ reconnect(struct rconn *rc)
         rc->backoff_deadline = time_now() + rc->backoff;
         state_transition(rc, S_CONNECTING);
     } else {
-        VLOG_WARN("%s: connection failed (%s)",
-                  rc->name, ovs_strerror(retval));
+        VLOG_WARN_RL(&rl, "%s: connection failed (%s)",
+                     rc->name, ovs_strerror(retval));
         rc->backoff_deadline = TIME_MAX; /* Prevent resetting backoff. */
         disconnect(rc, retval);
     }
-- 
1.8.3.1





More information about the dev mailing list