diff mbox series

[ovs-dev,2/2] bridge: Split the rstp statistics and status updates.

Message ID CAEQwrRQ=4varox=pbWvXpLv8vsRZiZH8CUwxepPWOE=ftAWzAA@mail.gmail.com
State Changes Requested
Headers show
Series [ovs-dev,1/2] bridge: Move sec_in_state to port statistics from port status. | expand

Commit Message

Krishna Kolakaluri Nov. 21, 2019, 1:59 a.m. UTC
This commit splits the rstp port statistics and rstp port status
updates into its own functions. This helps in controlling the number
of times rstp statistics are updated with the key
"stats-update-intervals". Currently this is updated every second
approximately which causes too many notifications or updates to the
controller.

Signed-off-by: Krishna Kolakaluri <kkolakaluri@plume.com>
---
 vswitchd/bridge.c | 34 +++++++++++++++++++++++++++++++---
 1 file changed, 31 insertions(+), 3 deletions(-)

     keys[0] = "rstp_tx_count";
@@ -3051,6 +3078,7 @@ run_stats_update(void)
                         iface_refresh_stats(iface);
                     }
                     port_refresh_stp_stats(port);
+                    port_refresh_rstp_stats(port);
                 }
                 HMAP_FOR_EACH (m, hmap_node, &br->mirrors) {
                     mirror_refresh_stats(m);
diff mbox series

Patch

diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 26aa596e9..abd581298 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -2841,8 +2841,6 @@  port_refresh_rstp_status(struct port *port)
     struct ofproto *ofproto = port->bridge->ofproto;
     struct iface *iface;
     struct ofproto_port_rstp_status status;
-    const char *keys[4];
-    int64_t int_values[4];
     struct smap smap;

     if (port_is_synthetic(port)) {
@@ -2862,7 +2860,6 @@  port_refresh_rstp_status(struct port *port)

     if (!status.enabled) {
         ovsrec_port_set_rstp_status(port->cfg, NULL);
-        ovsrec_port_set_rstp_statistics(port->cfg, NULL, NULL, 0);
         return;
     }
     /* Set Status column. */
@@ -2883,6 +2880,36 @@  port_refresh_rstp_status(struct port *port)

     ovsrec_port_set_rstp_status(port->cfg, &smap);
     smap_destroy(&smap);
+}
+
+static void
+port_refresh_rstp_stats(struct port *port)
+{
+    struct ofproto *ofproto = port->bridge->ofproto;
+    struct iface *iface;
+    struct ofproto_port_rstp_status status;
+    const char *keys[4];
+    int64_t int_values[4];
+
+    if (port_is_synthetic(port)) {
+        return;
+    }
+
+    /* RSTP doesn't currently support bonds. */
+    if (!ovs_list_is_singleton(&port->ifaces)) {
+        ovsrec_port_set_rstp_statistics(port->cfg, NULL, NULL, 0);
+        return;
+    }
+
+    iface = CONTAINER_OF(ovs_list_front(&port->ifaces), struct iface,
port_elem);
+    if (ofproto_port_get_rstp_status(ofproto, iface->ofp_port, &status)) {
+        return;
+    }
+
+    if (!status.enabled) {
+        ovsrec_port_set_rstp_statistics(port->cfg, NULL, NULL, 0);
+        return;
+    }

     /* Set Statistics column. */