Skip to contentSkip to conversation

[2.6.7] Bridge - Fix BPDU message_age

PATCH Kishore A K 1 participant 1 message Jun 24, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi Stephen,

Quoted 1 line
Quoted 1 line

First, we shouldn't send out the config info if our info about the root is too old.

Thats why I had introduced the check "if (bpdu.message_age < br->max_age)". The purpose of maintaining the message_age parameter is to enable a bridge to discard information whose age exceeds Max Age. So I think this would be the right way of doing it. You may refer the section "8.6.1.3.3 step 3" in the IEEE 802.1D spec. Above that I really did not get the logic behind doing "if (age < stp_t_to_jiffies(2))". Pls clarify.

Quoted 2 lines
Quoted 2 lines

Second, since the time values in the BPDU are scaled from jiffies to 1/256 sec later in the send process, need to increment age by the appropriate value.

I had completely forgotten about this. However, the purpose of doing the increment is to avoid underestimating the age, which is very unlikely to happen. Anyway this can be easily done by incrementing the age by a factor ( (1 * HZ)>>8) instead of 1.

Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+		long age = (long) root->message_age_timer.expires
+			- (long)jiffies;

"message_age_timer.expires - jiffies" does not give the message age. Instead it gives the time left before the message age timer expires. Whereas Message age is the time elapsed since the generation of the configuration BPDU by the root. So the right way of getting the message age according to me would be

message_age = max_age - (message_age_timer.expires - jiffies) + (HZ>>8)

Pls correct me if I am wrong here.

Hence the updated patch,

Index: linux-2.6.7/net/bridge/br_stp.c
=============================================================

net/bridge/br_stp.c renamed from net/bridge/br_stp.c.orig +8 -9
@@ -161,20 +161,19 @@ void br_transmit_config(struct net_bridg
 	if (!br_is_root_bridge(br)) {
 		struct net_bridge_port *root
 			= br_get_port(br, br->root_port);
-		bpdu.max_age = root->message_age_timer.expires - jiffies;
-
-		if (bpdu.max_age <= 0) bpdu.max_age = 1;
+		bpdu.message_age = br->max_age - 
+			(root->message_age_timer.expires - jiffies) + (HZ >> 8);
 	}
 	bpdu.max_age = br->max_age;
 	bpdu.hello_time = br->hello_time;
 	bpdu.forward_delay = br->forward_delay;
 
-	br_send_config_bpdu(p, &bpdu);
-
-	p->topology_change_ack = 0;
-	p->config_pending = 0;
-	
-	mod_timer(&p->hold_timer, jiffies + BR_HOLD_TIME);
+	if (bpdu.message_age < br->max_age) {
+		br_send_config_bpdu(p, &bpdu);
+		p->topology_change_ack = 0;
+		p->config_pending = 0;
+		mod_timer(&p->hold_timer, jiffies + BR_HOLD_TIME);
+	}
 }
 
 /* called under bridge lock */