diff mbox series

[ovs-dev,1/2] bridge: Move sec_in_state to port statistics from port status.

Message ID CAEQwrRRWCv2iFNiGb56MZCGBNrL8MHNddE-A7OO0LTv+LJuXjQ@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:54 a.m. UTC
This commit moves the field sec_in_state field from port statistics to
port status structure.This helps in reducing the number of updates
sent to the controller, with the current mechanism everytime there is
a change in this field a notification is sent to the controller. For
this field its every second, since it's just counting the number of
secs its been in that particular state. By moving this under port
statistics, this can be controlled with the key
"stats-update-interval".

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(-)

Comments

Ben Pfaff Nov. 22, 2019, 1:14 a.m. UTC | #1
On Wed, Nov 20, 2019 at 05:54:28PM -0800, Krishna Kolakaluri wrote:
> This commit moves the field sec_in_state field from port statistics to
> port status structure.This helps in reducing the number of updates
> sent to the controller, with the current mechanism everytime there is
> a change in this field a notification is sent to the controller. For
> this field its every second, since it's just counting the number of
> secs its been in that particular state. By moving this under port
> statistics, this can be controlled with the key
> "stats-update-interval".
> 
> Signed-off-by: Krishna Kolakaluri <kkolakaluri@plume.com>

Please update the documentation in vswitch.xml to reflect the new
location.  The documentation should also mention that it was in the
previous location in 2.12 and earlier.

Please add an item to NEWS, also, since this is an incompatible change.
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));