[ovs-dev] [PATCH] stp: Log topology change events.

Ethan Jackson ethan at nicira.com
Fri Feb 3 00:55:08 UTC 2012


Here's a version without the command line vlog support.

---
diff --git a/lib/stp.c b/lib/stp.c
index ba27306..06ac001 100644
--- a/lib/stp.c
+++ b/lib/stp.c
@@ -1068,6 +1068,8 @@ stp_set_port_state(struct stp_port *p, enum stp_state state)
 static void
 stp_topology_change_detection(struct stp *stp)
 {
+    static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
+
     if (stp_is_root_bridge(stp)) {
         stp->topology_change = true;
         stp_start_timer(&stp->topology_change_timer, 0);
@@ -1077,6 +1079,7 @@ stp_topology_change_detection(struct stp *stp)
     }
     stp->fdb_needs_flush = true;
     stp->topology_change_detected = true;
+    VLOG_INFO_RL(&rl, "%s: detected topology change.", stp->name);
 }
 
 static void
diff --git a/tests/stp.at b/tests/stp.at
index ba19837..741957d 100644
--- a/tests/stp.at
+++ b/tests/stp.at
@@ -15,7 +15,13 @@ check 2 = F:10 B
 check 3 = F:5 F
 check 4 = F:5 B
 ])
-AT_CHECK([test-stp test-stp-ieee802.1d-1998])
+AT_CHECK([test-stp test-stp-ieee802.1d-1998], [0], [], [dnl
+stp|INFO|stp42: detected topology change.
+stp|INFO|stp42: detected topology change.
+stp|INFO|stp97: detected topology change.
+stp|INFO|stp97: detected topology change.
+stp|INFO|stp97: detected topology change.
+])
 AT_CLEANUP
 
 AT_SETUP([STP example from IEEE 802.1D-2004 figures 17.4 and 17.5])
@@ -52,7 +58,13 @@ check 5 = F:20 B F F
 check 6 = F:20 B F F
 check 7 = F:20 B F B
 ])
-AT_CHECK([test-stp test-stp-ieee802.1d-2004-fig17.4])
+AT_CHECK([test-stp test-stp-ieee802.1d-2004-fig17.4], [0], [], [dnl
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp222: detected topology change.
+])
 AT_CLEANUP
 
 AT_SETUP([STP example from IEEE 802.1D-2004 figure 17.6])
@@ -72,7 +84,13 @@ check 3 = F:30 F B
 check 4 = F:20 F F
 check 5 = F:10 F F
 ])
-AT_CHECK([test-stp test-stp-ieee802.1d-2004-fig17.6])
+AT_CHECK([test-stp test-stp-ieee802.1d-2004-fig17.6], [0], [], [dnl
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp222: detected topology change.
+stp|INFO|stp222: detected topology change.
+])
 AT_CLEANUP
 
 AT_SETUP([STP example from IEEE 802.1D-2004 figure 17.7])
@@ -95,7 +113,13 @@ check 0 = root
 check 1 = F F:10 F F F F F F
 check 2 = F:20 D F F F F F F
 ])
-AT_CHECK([test-stp test-stp-ieee802.1d-2004-fig17.7])
+AT_CHECK([test-stp test-stp-ieee802.1d-2004-fig17.7], [0], [], [dnl
+stp|INFO|stpaa: detected topology change.
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp111: detected topology change.
+])
 AT_CLEANUP
 
 AT_SETUP([STP.io.1.1: Link Failure])
@@ -128,7 +152,13 @@ run 1000
 check 0 = root
 check 1 = D D F:10
 ])
-AT_CHECK([test-stp test-stp-iol-io-1.1])
+AT_CHECK([test-stp test-stp-iol-io-1.1], [0], [], [dnl
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp222: detected topology change.
+stp|INFO|stp111: detected topology change.
+])
 AT_CLEANUP
 
 AT_SETUP([STP.io.1.2: Repeated Network])
@@ -148,7 +178,11 @@ run 1000
 check 0 = rootid:0x111 F B
 check 1 = rootid:0x111 B F:10
 ])
-AT_CHECK([test-stp test-stp-iol-io-1.2])
+AT_CHECK([test-stp test-stp-iol-io-1.2], [0], [], [dnl
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp222: detected topology change.
+stp|INFO|stp111: detected topology change.
+])
 AT_CLEANUP
 
 AT_SETUP([STP.io.1.4: Network Initialization])
@@ -168,7 +202,13 @@ check 1 = F:10 F F
 check 2 = F:10 B F
 check 3 = F:10 B B
 ])
-AT_CHECK([test-stp test-stp-iol-io-1.4])
+AT_CHECK([test-stp test-stp-iol-io-1.4], [0], [], [dnl
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp222: detected topology change.
+stp|INFO|stp222: detected topology change.
+])
 AT_CLEANUP
 
 AT_SETUP([STP.io.1.5: Topology Change])
@@ -215,7 +255,13 @@ check 1 = F:10 B F F
 check 2 = B F:10 F F
 check 3 = B F:20 B B
 ])
-AT_CHECK([test-stp test-stp-iol-io-1.5])
+AT_CHECK([test-stp test-stp-iol-io-1.5], [0], [], [dnl
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp222: detected topology change.
+])
 AT_CLEANUP
 
 AT_SETUP([STP.op.1.1 and STP.op.1.2])
@@ -244,7 +290,13 @@ check 0 = Li Li Li Li Li Li
 run 1000
 check 0 = F F F F F F
 ])
-AT_CHECK([test-stp test-stp-iol-op-1.4])
+AT_CHECK([test-stp test-stp-iol-op-1.4], [0], [], [dnl
+stp|INFO|stp123: detected topology change.
+stp|INFO|stp123: detected topology change.
+stp|INFO|stp123: detected topology change.
+stp|INFO|stp123: detected topology change.
+stp|INFO|stp123: detected topology change.
+])
 AT_CLEANUP
 
 AT_SETUP([STP.op.3.1: Root Bridge Selection: Root ID Values])
@@ -262,7 +314,9 @@ run 1000
 check 0 = rootid:0x111 root
 check 1 = rootid:0x111 F:10
 ])
-AT_CHECK([test-stp test-stp-iol-op-3.1])
+AT_CHECK([test-stp test-stp-iol-op-3.1], [0], [], [dnl
+stp|INFO|stp111: detected topology change.
+])
 AT_CLEANUP
 
 AT_SETUP([STP.op.3.3: Root Bridge Selection: Bridge ID Values])
@@ -280,7 +334,12 @@ check 0 = rootid:0x333^0x6000 root
 check 1 = rootid:0x333^0x6000 F:20
 check 2 = rootid:0x333^0x6000 F:10 F
 ])
-AT_CHECK([test-stp test-stp-iol-op-3.3])
+AT_CHECK([test-stp test-stp-iol-op-3.3], [0], [], [dnl
+stp|INFO|stp333: detected topology change.
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp333: detected topology change.
+])
 AT_CLEANUP
 
 AT_SETUP([STP.op.3.3: Root Bridge Selection: Bridge ID Values])
@@ -298,5 +357,10 @@ check 0 = rootid:0x333^0x6000 root
 check 1 = rootid:0x333^0x6000 F:20
 check 2 = rootid:0x333^0x6000 F:10 F
 ])
-AT_CHECK([test-stp test-stp-iol-op-3.4])
+AT_CHECK([test-stp test-stp-iol-op-3.4], [0], [], [dnl
+stp|INFO|stp333: detected topology change.
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp111: detected topology change.
+stp|INFO|stp333: detected topology change.
+])
 AT_CLEANUP
diff --git a/tests/test-stp.c b/tests/test-stp.c
index fecada7..259dc74 100644
--- a/tests/test-stp.c
+++ b/tests/test-stp.c
@@ -25,6 +25,7 @@
 #include <stdlib.h>
 #include "ofpbuf.h"
 #include "packets.h"
+#include "vlog.h"
 
 struct bpdu {
     int port_no;
@@ -440,6 +441,9 @@ main(int argc, char *argv[])
     FILE *input_file;
     int i;
 
+    vlog_set_pattern(VLF_CONSOLE, "%c|%p|%m");
+    vlog_set_levels(NULL, VLF_SYSLOG, VLL_OFF);
+
     if (argc != 2) {
         ovs_fatal(0, "usage: test-stp INPUT.STP\n");
     }
-- 
1.7.8.3




More information about the dev mailing list