rstp-state-machines: fix proposal reception behaviour.
authorJarno Rajahalme <jrajahalme@nicira.com>
Fri, 14 Nov 2014 21:58:25 +0000 (13:58 -0800)
committerJarno Rajahalme <jrajahalme@nicira.com>
Wed, 19 Nov 2014 17:41:52 +0000 (09:41 -0800)
Other ports should stop forwarding and learning when a port receives a
superior BPDU carrying a Proposal flag.
Without this patch this does not happen and other ports keep executing
the learning and forwarding processes.
This patch contains some fixes reported in the 802.1q-2008 standard.

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

index ab3443e..df357a7 100644 (file)
@@ -755,8 +755,11 @@ record_dispute(struct rstp_port *p)
     OVS_REQUIRES(rstp_mutex)
 {
     if ((p->received_bpdu_buffer.flags & BPDU_FLAG_LEARNING) != 0) {
-        p->agreed = true;
-        p->proposing = false;
+        /* 802.1D-2004 says to set the agreed flag and to clear the proposing
+         * flag. 802.1q-2008 instead says to set the disputed variable and to
+         * clear the agreed variable. */
+        p->disputed = true;
+        p->agreed = false;
     }
 }
 
@@ -1134,6 +1137,7 @@ port_information_sm(struct rstp_port *p)
 {
     enum port_information_state_machine old_state;
     struct rstp *r;
+    struct rstp_port *p1;
 
     old_state = p->port_information_sm_state;
     r = p->rstp;
@@ -1233,6 +1237,19 @@ port_information_sm(struct rstp_port *p)
         } else {
             switch (p->rcvd_info) {
             case SUPERIOR_DESIGNATED_INFO:
+                /* 802.1q-2008 has a checkBPDUConsistency() function, called on
+                 * a BPDU reception.  checkBPDUConsistency() clears the agreed
+                 * variable if the received message priority vector is superior
+                 * to the port priority vector, the BPDU is an ST BPDU or an
+                 * RST BPDU, its port role is Designated and its Learning flag
+                 * is set. */
+                if (p->received_bpdu_buffer.flags & BPDU_FLAG_LEARNING) {
+                    HMAP_FOR_EACH (p1, node, &r->ports) {
+                        if (p1->port_number != p->port_number) {
+                            p1->agreed = false;
+                        }
+                    }
+                }
                 p->port_information_sm_state =
                     PORT_INFORMATION_SM_SUPERIOR_DESIGNATED_EXEC;
                 break;
@@ -1299,6 +1316,9 @@ port_information_sm(struct rstp_port *p)
     case PORT_INFORMATION_SM_REPEATED_DESIGNATED_EXEC:
         record_proposal(p);
         set_tc_flags(p);
+        /* This record_agreement() is missing in 802.1D-2004, but it's present
+         * in 802.1q-2008. */
+        record_agreement(p);
         updt_rcvd_info_while(p);
         p->rcvd_msg = false;
         p->port_information_sm_state = PORT_INFORMATION_SM_REPEATED_DESIGNATED;
@@ -1317,6 +1337,10 @@ port_information_sm(struct rstp_port *p)
         set_tc_flags(p);
         /* RECEIVED is not specified in Standard 802.1D-2004. */
         p->agree = p->agree && better_or_same_info(p, RECEIVED);
+        /* This record_agreement() and the synced assignment are  missing in
+         * 802.1D-2004, but they're present in 802.1q-2008. */
+        record_agreement(p);
+        p->synced = p->synced && p->agreed;
         record_priority(p);
         record_times(p);
         updt_rcvd_info_while(p);