lib/stp: Some debugging support.
authorJarno Rajahalme <jrajahalme@nicira.com>
Fri, 22 Aug 2014 16:01:34 +0000 (09:01 -0700)
committerJarno Rajahalme <jrajahalme@nicira.com>
Tue, 9 Sep 2014 18:45:43 +0000 (11:45 -0700)
Set the stp port name before enabling it, so that debugging messages
have the name to print out.

Do not treat the first state initialization as a state change.  Zero
is not a valid state, so changing from zero to STP_DISABLED is not a
state change.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Daniele Venturino <daniele.venturino@m3s.it>
lib/stp.c
ofproto/ofproto-dpif.c

index 1bf1f89..8f904c0 100644 (file)
--- a/lib/stp.c
+++ b/lib/stp.c
@@ -1469,7 +1469,12 @@ stp_initialize_port(struct stp_port *p, enum stp_state state)
 {
     ovs_assert(state & (STP_DISABLED | STP_BLOCKING));
     stp_become_designated_port(p);
-    stp_set_port_state(p, state);
+
+    if (!p->state && state == STP_DISABLED) {
+        p->state = state; /* Do not trigger state change when initializing. */
+    } else {
+        stp_set_port_state(p, state);
+    }
     p->topology_change_ack = false;
     p->config_pending = false;
     p->change_detection_enabled = true;
index 291873a..aeff00d 100644 (file)
@@ -2219,9 +2219,12 @@ set_stp_port(struct ofport *ofport_,
     }
 
     sp = ofport->stp_port = stp_get_port(ofproto->stp, s->port_num);
-    stp_port_enable(sp);
 
+    /* Set name before enabling the port so that debugging messages can print
+     * the name. */
     stp_port_set_name(sp, netdev_get_name(ofport->up.netdev));
+    stp_port_enable(sp);
+
     stp_port_set_aux(sp, ofport);
     stp_port_set_priority(sp, s->priority);
     stp_port_set_path_cost(sp, s->path_cost);