Skip to content

Commit

Permalink
rstp: Add rstp port name for human reading.
Browse files Browse the repository at this point in the history
This patch is useful to debug rstp subsystem and log the
port name instead of port number. This patch will also
be used to display rstp info for next patches.

Signed-off-by: nickcooper-zhangtonghao <[email protected]>
Acked-by: Jarno Rajahalme <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
xpu22 authored and blp committed Jun 8, 2017
1 parent fff4813 commit 8d2f837
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/rstp-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ struct rstp_port {
struct rstp *rstp OVS_GUARDED_BY(rstp_mutex);
struct hmap_node node OVS_GUARDED_BY(rstp_mutex); /* In rstp->ports. */
void *aux OVS_GUARDED_BY(rstp_mutex);
char *port_name;
struct rstp_bpdu received_bpdu_buffer OVS_GUARDED_BY(rstp_mutex);
/*************************************************************************
* MAC status parameters
Expand Down
14 changes: 13 additions & 1 deletion lib/rstp.c
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,14 @@ rstp_port_set_port_number__(struct rstp_port *port, uint16_t port_number)
}
}

static void
rstp_port_set_port_name__(struct rstp_port *port, const char *name)
OVS_REQUIRES(rstp_mutex)
{
free(port->port_name);
port->port_name = xstrdup(name);
}

/* Converts the link speed to a port path cost [Table 17-3]. */
uint32_t
rstp_convert_speed_to_cost(unsigned int speed)
Expand Down Expand Up @@ -1164,6 +1172,7 @@ rstp_add_port(struct rstp *rstp)
rstp_port_set_priority__(p, RSTP_DEFAULT_PORT_PRIORITY);
rstp_port_set_port_number__(p, 0);
p->aux = NULL;
p->port_name = NULL;
rstp_initialize_port_defaults__(p);
VLOG_DBG("%s: RSTP port "RSTP_PORT_ID_FMT" initialized.", rstp->name,
p->port_id);
Expand Down Expand Up @@ -1201,6 +1210,7 @@ rstp_port_unref(struct rstp_port *rp)
ovs_mutex_lock(&rstp_mutex);
rstp = rp->rstp;
rstp_port_set_state__(rp, RSTP_DISABLED);
free(rp->port_name);
hmap_remove(&rstp->ports, &rp->node);
VLOG_DBG("%s: removed port "RSTP_PORT_ID_FMT"", rstp->name,
rp->port_id);
Expand Down Expand Up @@ -1439,13 +1449,15 @@ void
rstp_port_set(struct rstp_port *port, uint16_t port_num, int priority,
uint32_t path_cost, bool is_admin_edge, bool is_auto_edge,
enum rstp_admin_point_to_point_mac_state admin_p2p_mac_state,
bool admin_port_state, bool do_mcheck, void *aux)
bool admin_port_state, bool do_mcheck, void *aux,
const char *name)
OVS_EXCLUDED(rstp_mutex)
{
ovs_mutex_lock(&rstp_mutex);
port->aux = aux;
rstp_port_set_priority__(port, priority);
rstp_port_set_port_number__(port, port_num);
rstp_port_set_port_name__(port, name);
rstp_port_set_path_cost__(port, path_cost);
rstp_port_set_admin_edge__(port, is_admin_edge);
rstp_port_set_auto_edge__(port, is_auto_edge);
Expand Down
3 changes: 2 additions & 1 deletion lib/rstp.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ uint32_t rstp_convert_speed_to_cost(unsigned int speed);
void rstp_port_set(struct rstp_port *, uint16_t port_num, int priority,
uint32_t path_cost, bool is_admin_edge, bool is_auto_edge,
enum rstp_admin_point_to_point_mac_state admin_p2p_mac_state,
bool admin_port_state, bool do_mcheck, void *aux)
bool admin_port_state, bool do_mcheck, void *aux,
const char *name)
OVS_EXCLUDED(rstp_mutex);

enum rstp_state rstp_port_get_state(const struct rstp_port *)
Expand Down
2 changes: 1 addition & 1 deletion ofproto/ofproto-dpif.c
Original file line number Diff line number Diff line change
Expand Up @@ -2759,7 +2759,7 @@ set_rstp_port(struct ofport *ofport_,
rstp_port_set(rp, s->port_num, s->priority, s->path_cost,
s->admin_edge_port, s->auto_edge,
s->admin_p2p_mac_state, s->admin_port_state, s->mcheck,
ofport);
ofport, netdev_get_name(ofport->up.netdev));
update_rstp_port_state(ofport);
/* Synchronize operational status. */
rstp_port_set_mac_operational(rp, ofport->may_enable);
Expand Down

0 comments on commit 8d2f837

Please sign in to comment.