[ovs-dev] [PATCH 01/17] rstp: Show some useful rstp port fields.

Jarno Rajahalme jrajahalme at nicira.com
Thu Nov 13 22:54:54 UTC 2014


Acked-by: Jarno Rajahalme <jrajahalme at nicira.com>

From CodingStyle:

  "Use the int<N>_t and uint<N>_t types from <stdint.h> for exact-width
integer types.  Use the PRId<N>, PRIu<N>, and PRIx<N> macros from
<inttypes.h> for formatting them with printf() and related functions."

I’ll merge this to master with these portability/style changes:

diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 20cfcba..f346522 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -2456,7 +2456,7 @@ br_refresh_rstp_status(struct bridge *br)
     }
     smap_add_format(&smap, "rstp_bridge_id", RSTP_ID_FMT,
                     RSTP_ID_ARGS(status.bridge_id));
-    smap_add_format(&smap, "rstp_root_path_cost", "%d",
+    smap_add_format(&smap, "rstp_root_path_cost", "%"PRIu32,
                     status.root_path_cost);
     smap_add_format(&smap, "rstp_root_id", RSTP_ID_FMT,
                     RSTP_ID_ARGS(status.root_id));
@@ -2513,7 +2513,7 @@ port_refresh_rstp_status(struct port *port)
                     RSTP_ID_ARGS(status.designated_bridge_id));
     smap_add_format(&smap, "rstp_designated_port_id", RSTP_PORT_ID_FMT,
                     status.designated_port_id);
-    smap_add_format(&smap, "rstp_designated_path_cost", "%d",
+    smap_add_format(&smap, "rstp_designated_path_cost", "%"PRIu32,
                     status.designated_path_cost);
 
     ovsrec_port_set_rstp_status(port->cfg, &smap);

  Jarno

On Nov 6, 2014, at 7:30 AM, Daniele Venturino <daniele.venturino at m3s.it> wrote:

>      designated_bridge_id, designated_port_id and designated_path_cost are
>      now displayed in rstp_status when using 'ovs-vsctl list port'.
> 
> Signed-off-by: Daniele Venturino <daniele.venturino at m3s.it>
> ---
> lib/rstp.c             | 10 ++++++++--
> lib/rstp.h             |  6 ++++--
> ofproto/ofproto-dpif.c |  4 +++-
> ofproto/ofproto.h      |  3 +++
> vswitchd/bridge.c      |  6 ++++++
> 5 files changed, 24 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/rstp.c b/lib/rstp.c
> index b37ad68..0f96749 100644
> --- a/lib/rstp.c
> +++ b/lib/rstp.c
> @@ -1264,8 +1264,10 @@ rstp_port_get_state(const struct rstp_port *p)
> void
> rstp_port_get_status(const struct rstp_port *p, uint16_t *id,
>                      enum rstp_state *state, enum rstp_port_role *role,
> -                     int *tx_count, int *rx_count, int *error_count,
> -                     int *uptime)
> +                     rstp_identifier *designated_bridge_id,
> +                     uint16_t *designated_port_id,
> +                     uint32_t *designated_path_cost, int *tx_count,
> +                     int *rx_count, int *error_count, int *uptime)
>     OVS_EXCLUDED(rstp_mutex)
> {
>     ovs_mutex_lock(&rstp_mutex);
> @@ -1273,6 +1275,10 @@ rstp_port_get_status(const struct rstp_port *p, uint16_t *id,
>     *state = p->rstp_state;
>     *role = p->role;
> 
> +    *designated_bridge_id = p->port_priority.designated_bridge_id;
> +    *designated_port_id = p->port_priority.designated_port_id;
> +    *designated_path_cost = p->port_priority.root_path_cost;
> +
>     *tx_count = p->tx_count;
>     *rx_count = p->rx_rstp_bpdu_cnt;
>     *error_count = p->error_count;
> diff --git a/lib/rstp.h b/lib/rstp.h
> index 364a181..ccf8292 100644
> --- a/lib/rstp.h
> +++ b/lib/rstp.h
> @@ -219,8 +219,10 @@ enum rstp_state rstp_port_get_state(const struct rstp_port *)
> 
> void rstp_port_get_status(const struct rstp_port *, uint16_t *id,
>                           enum rstp_state *state, enum rstp_port_role *role,
> -                          int *tx_count, int *rx_count, int *error_count,
> -                          int *uptime)
> +                          rstp_identifier *designated_bridge_id,
> +                          uint16_t *designated_port_id,
> +                          uint32_t *designated_path_cost, int *tx_count,
> +                          int *rx_count, int *error_count, int *uptime)
>     OVS_EXCLUDED(rstp_mutex);
> 
> void * rstp_get_port_aux(struct rstp *rstp, uint16_t port_number)
> diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
> index 0d0649c..2302073 100644
> --- a/ofproto/ofproto-dpif.c
> +++ b/ofproto/ofproto-dpif.c
> @@ -2422,7 +2422,9 @@ get_rstp_port_status(struct ofport *ofport_,
>     }
> 
>     s->enabled = true;
> -    rstp_port_get_status(rp, &s->port_id, &s->state, &s->role, &s->tx_count,
> +    rstp_port_get_status(rp, &s->port_id, &s->state, &s->role,
> +                         &s->designated_bridge_id, &s->designated_port_id,
> +                         &s->designated_path_cost, &s->tx_count,
>                          &s->rx_count, &s->error_count, &s->uptime);
> }
> 
> diff --git a/ofproto/ofproto.h b/ofproto/ofproto.h
> index 40bb3b7..989747d 100644
> --- a/ofproto/ofproto.h
> +++ b/ofproto/ofproto.h
> @@ -109,6 +109,9 @@ struct ofproto_port_rstp_status {
>     uint16_t port_id;
>     enum rstp_port_role role;
>     enum rstp_state state;
> +    rstp_identifier designated_bridge_id;
> +    uint16_t designated_port_id;
> +    uint32_t designated_path_cost;
>     int tx_count;               /* Number of BPDUs transmitted. */
>     int rx_count;               /* Number of valid BPDUs received. */
>     int error_count;            /* Number of bad BPDUs received. */
> diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
> index 33d8d6a..20cfcba 100644
> --- a/vswitchd/bridge.c
> +++ b/vswitchd/bridge.c
> @@ -2509,6 +2509,12 @@ port_refresh_rstp_status(struct port *port)
>                     rstp_port_role_name(status.role));
>     smap_add_format(&smap, "rstp_port_state", "%s",
>                     rstp_state_name(status.state));
> +    smap_add_format(&smap, "rstp_designated_bridge_id", RSTP_ID_FMT,
> +                    RSTP_ID_ARGS(status.designated_bridge_id));
> +    smap_add_format(&smap, "rstp_designated_port_id", RSTP_PORT_ID_FMT,
> +                    status.designated_port_id);
> +    smap_add_format(&smap, "rstp_designated_path_cost", "%d",
> +                    status.designated_path_cost);
> 
>     ovsrec_port_set_rstp_status(port->cfg, &smap);
>     smap_destroy(&smap);
> -- 
> 1.8.1.2
> 




More information about the dev mailing list