diff mbox series

[ovs-dev] bridge: Move sec_in_state field from port status to port statistics.

Message ID CAEQwrRT5qjTQD=-jY_ZcGQNxxTQhv6rAJcTiNezg2f143bZdTQ@mail.gmail.com
State Superseded
Headers show
Series [ovs-dev] bridge: Move sec_in_state field from port status to port statistics. | expand

Commit Message

Krishna Kolakaluri Nov. 21, 2019, 1:30 a.m. UTC
Signed-off-by: Krishna Kolakaluri <kkolakaluri@plume.com>
---
 ofproto/ofproto-dpif.c | 2 +-
 ofproto/ofproto.h      | 2 +-
 vswitchd/bridge.c      | 7 ++++---
 3 files changed, 6 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index c35ec3e61..f68ab661f 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -2829,7 +2829,6 @@  get_stp_port_status(struct ofport *ofport_,

     s->enabled = true;
     stp_port_get_status(sp, &s->port_id, &s->state, &s->role);
-    s->sec_in_state = (time_msec() - ofport->stp_state_entered) / 1000;

     return 0;
 }
@@ -2849,6 +2848,7 @@  get_stp_port_stats(struct ofport *ofport_,

     s->enabled = true;
     stp_port_get_counts(sp, &s->tx_count, &s->rx_count, &s->error_count);
+    s->sec_in_state = (time_msec() - ofport->stp_state_entered) / 1000;

     return 0;
 }
diff --git a/ofproto/ofproto.h b/ofproto/ofproto.h
index 033c4cf93..7e75b2e6c 100644
--- a/ofproto/ofproto.h
+++ b/ofproto/ofproto.h
@@ -166,7 +166,6 @@  struct ofproto_port_stp_status {
     bool enabled;               /* If false, ignore other members. */
     int port_id;
     enum stp_state state;
-    unsigned int sec_in_state;
     enum stp_role role;
 };

@@ -175,6 +174,7 @@  struct ofproto_port_stp_stats {
     int tx_count;               /* Number of BPDUs transmitted. */
     int rx_count;               /* Number of valid BPDUs received. */
     int error_count;            /* Number of bad BPDUs received. */
+    unsigned int sec_in_state;  /* Number of secs in stp state. */
 };

 struct ofproto_port_queue {
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 9095ebf5d..26aa596e9 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -2758,7 +2758,6 @@  port_refresh_stp_status(struct port *port)
     smap_init(&smap);
     smap_add_format(&smap, "stp_port_id", "%d", status.port_id);
     smap_add(&smap, "stp_state", stp_state_name(status.state));
-    smap_add_format(&smap, "stp_sec_in_state", "%u", status.sec_in_state);
     smap_add(&smap, "stp_role", stp_role_name(status.role));
     ovsrec_port_set_status(port->cfg, &smap);
     smap_destroy(&smap);
@@ -2770,8 +2769,8 @@  port_refresh_stp_stats(struct port *port)
     struct ofproto *ofproto = port->bridge->ofproto;
     struct iface *iface;
     struct ofproto_port_stp_stats stats;
-    const char *keys[3];
-    int64_t int_values[3];
+    const char *keys[4];
+    int64_t int_values[4];

     if (port_is_synthetic(port)) {
         return;
@@ -2799,6 +2798,8 @@  port_refresh_stp_stats(struct port *port)
     int_values[1] = stats.rx_count;
     keys[2] = "stp_error_count";
     int_values[2] = stats.error_count;
+    keys[3] = "stp_sec_in_state";
+    int_values[3] = stats.sec_in_state;

     ovsrec_port_set_statistics(port->cfg, keys, int_values,
                                ARRAY_SIZE(int_values));