]> git.ipfire.org Git - people/ms/mstpd.git/commitdiff
Configuration for bridge hello time
authordv1tas <dv1tas@fbe50366-0c72-4402-a84b-5d246361dba7>
Wed, 29 May 2013 09:49:55 +0000 (09:49 +0000)
committerdv1tas <dv1tas@fbe50366-0c72-4402-a84b-5d246361dba7>
Wed, 29 May 2013 09:49:55 +0000 (09:49 +0000)
Signed-off-by: Satish Ashok <sashok@cumulusnetworks.com>
Signed-off-by: Vitalii Demianets <dvitasgs@gmail.com>
git-svn-id: svn://svn.code.sf.net/p/mstpd/code/trunk@38 fbe50366-0c72-4402-a84b-5d246361dba7

ctl_main.c
mstp.c
mstp.h

index aaf0432ebad879dac7f9e97ce58c4bf30767f36c..8dfc7d5c0940ec258571c81928e9cc9f8d475c4f 100644 (file)
@@ -103,6 +103,7 @@ typedef enum {
     PARAM_BRFWDDELAY,
     PARAM_TXHOLDCNT,
     PARAM_MAXHOPS,
+    PARAM_BRHELLO,
     PARAM_FORCEPROTVERS,
     PARAM_TOPCHNGTIME,
     PARAM_TOPCHNGCNT,
@@ -151,6 +152,7 @@ static const cmd_param_t cist_bridge_params[] = {
     { PARAM_BRFWDDELAY,   "bridge-forward-delay" },
     { PARAM_TXHOLDCNT,    "tx-hold-count" },
     { PARAM_MAXHOPS,      "max-hops" },
+    { PARAM_BRHELLO,      "hello-time" },
     { PARAM_FORCEPROTVERS,"force-protocol-version" },
     { PARAM_TOPCHNGTIME,  "time-since-topology-change" },
     { PARAM_TOPCHNGCNT,   "topology-change-count" },
@@ -185,14 +187,15 @@ static int do_showbridge(const char *br_name, param_id_t param_id)
             else
                 printf("none\n");
             printf("  path cost     %-10u ", s.root_path_cost);
-            printf("internal path cost   %u\n", s.internal_path_cost);
+            printf("internal path cost     %u\n", s.internal_path_cost);
             printf("  max age       %-10hhu ", s.root_max_age);
-            printf("bridge max age       %hhu\n", s.bridge_max_age);
+            printf("bridge max age         %hhu\n", s.bridge_max_age);
             printf("  forward delay %-10hhu ", s.root_forward_delay);
-            printf("bridge forward delay %hhu\n", s.bridge_forward_delay);
+            printf("bridge forward delay   %hhu\n", s.bridge_forward_delay);
             printf("  tx hold count %-10u ", s.tx_hold_count);
-            printf("max hops             %hhu\n", s.max_hops);
-            printf("  force protocol version     %s\n",
+            printf("max hops               %hhu\n", s.max_hops);
+            printf("  hello time    %-10u ", s.bridge_hello_time);
+            printf("force protocol version %s\n",
                    PROTO_VERS_STR(s.protocol_version));
             printf("  time since topology change %u\n",
                    s.time_since_topology_change);
@@ -243,6 +246,9 @@ static int do_showbridge(const char *br_name, param_id_t param_id)
         case PARAM_MAXHOPS:
             printf("%hhu\n", s.max_hops);
             break;
+        case PARAM_BRHELLO:
+            printf("%hhu\n", s.bridge_hello_time);
+            break;
         case PARAM_FORCEPROTVERS:
             printf("%s\n", PROTO_VERS_STR(s.protocol_version));
             break;
@@ -925,6 +931,17 @@ static int cmd_setbridgemaxage(int argc, char *const *argv)
     return set_bridge_cfg(bridge_max_age, max_age);
 }
 
+static int cmd_setbridgehello(int argc, char *const *argv)
+{
+    int br_index = get_index(argv[1], "bridge");
+    if(0 > br_index)
+        return br_index;
+    unsigned int hello_time = getuint(argv[2]);
+    if(hello_time > 255)
+        hello_time = 255;
+    return set_bridge_cfg(bridge_hello_time, hello_time);
+}
+
 static int cmd_setbridgefdelay(int argc, char *const *argv)
 {
     int br_index = get_index(argv[1], "bridge");
@@ -1432,6 +1449,8 @@ static const struct command commands[] =
      "<bridge> <fwd_delay>", "Set bridge forward delay (4-30)"},
     {2, 0, "setmaxhops", cmd_setbridgemaxhops,
      "<bridge> <max_hops>", "Set bridge max hops (6-40)"},
+    {2, 0, "sethello", cmd_setbridgehello,
+     "<bridge> <hello_time>", "Set bridge hello time (1-10)"},
     {2, 0, "setforcevers", cmd_setbridgeforcevers,
      "<bridge> {mstp|rstp|stp}", "Force Spanning Tree protocol version"},
     {2, 0, "settxholdcount", cmd_setbridgetxholdcount,
diff --git a/mstp.c b/mstp.c
index ccec4bcbd64f95d82bf186f351648bb0fd735087..fb2c5ec5baa87430dd386a4a0251c72385a520bb 100644 (file)
--- a/mstp.c
+++ b/mstp.c
@@ -18,7 +18,7 @@
  * ---- Bad IEEE! ----
  * For now I decide: All structures will hold Hello_Time,
  * because in 802.1D they do.
- * Maybe 802.1Q-2011 clarifies this, but I don't have the text.
+ * Besides, it is necessary for compatibility with old STP implementations.
  */
 
 /* 802.1Q-2005 does not define but widely use variable name newInfoXst.
@@ -116,8 +116,7 @@ static tree_t * create_tree(bridge_t *br, __u8 *macaddr, __be16 MSTID)
     assign(tree->BridgeTimes.Forward_Delay, br->Forward_Delay);
     assign(tree->BridgeTimes.Max_Age, br->Max_Age);
     assign(tree->BridgeTimes.Message_Age, (__u8)0);
-    /* 17.14 of 802.1D */
-    assign(tree->BridgeTimes.Hello_Time, (__u8)2);
+    assign(tree->BridgeTimes.Hello_Time, br->Hello_Time);
 
     /* 12.8.1.1.3.(b,c,d) */
     tree->time_since_topology_change = 0;
@@ -205,6 +204,7 @@ bool MSTP_IN_bridge_create(bridge_t *br, __u8 *macaddr)
     assign(br->Transmit_Hold_Count, 6u); /* 17.14 of 802.1D */
     assign(br->Migrate_Time, 3u); /* 17.14 of 802.1D */
     assign(br->Ageing_Time, 300u);/* 8.8.3 Table 8-3 */
+    assign(br->Hello_Time, (__u8)2);     /* 17.14 of 802.1D */
 
     br->uptime = 0;
 
@@ -585,6 +585,7 @@ void MSTP_IN_get_cist_bridge_status(bridge_t *br, CIST_BridgeStatus *status)
     assign(status->tx_hold_count, br->Transmit_Hold_Count);
     status->protocol_version = br->ForceProtocolVersion;
     status->enabled = br->bridgeEnabled;
+    assign(status->bridge_hello_time, br->Hello_Time);
 }
 
 /* 12.8.1.2 Read MSTI Bridge Protocol Parameters */
@@ -682,6 +683,15 @@ int MSTP_IN_set_cist_bridge_config(bridge_t *br, CIST_BridgeConfig *cfg)
         }
     }
 
+    if(cfg->set_bridge_hello_time)
+    {
+        if((1 > cfg->bridge_hello_time) || (10 < cfg->bridge_hello_time))
+        {
+            ERROR_BRNAME(br, "Bridge Hello Time must be between 1 and 10");
+            r = -1;
+        }
+    }
+
     if(r)
         return r;
 
@@ -728,6 +738,17 @@ int MSTP_IN_set_cist_bridge_config(bridge_t *br, CIST_BridgeConfig *cfg)
         }
     }
 
+    if(cfg->set_bridge_hello_time)
+    {
+        if(cfg->bridge_hello_time != br->Hello_Time)
+        {
+            INFO_BRNAME(br, "bridge hello_time new=%hhu, old=%hhu",
+                        cfg->bridge_hello_time, br->Hello_Time);
+            assign(br->Hello_Time, cfg->bridge_hello_time);
+            changed = changedBridgeTimes = true;
+        }
+    }
+
     /* Thirdly, finalize changes */
     if(changedBridgeTimes)
     {
@@ -736,6 +757,7 @@ int MSTP_IN_set_cist_bridge_config(bridge_t *br, CIST_BridgeConfig *cfg)
             assign(tree->BridgeTimes.remainingHops, br->MaxHops);
             assign(tree->BridgeTimes.Forward_Delay, br->Forward_Delay);
             assign(tree->BridgeTimes.Max_Age, br->Max_Age);
+            assign(tree->BridgeTimes.Hello_Time, br->Hello_Time);
         /* Comment found in rstpd by Srinivas Aji:
          * Do this for any change in BridgeTimes.
          * Otherwise we fail UNH rstp.op_D test 3.2 since when administratively
diff --git a/mstp.h b/mstp.h
index a0859ba7e8d01537945258e8f648e2fe5d0f1550..5bec14cf35e93515b6ecf6c62c01e53fef2c69fb 100644 (file)
--- a/mstp.h
+++ b/mstp.h
@@ -390,6 +390,11 @@ typedef struct
     __u8 MaxHops;             /* 13.22.o */
     __u8 Forward_Delay;       /* 13.22.f */
     __u8 Max_Age;             /* 13.22.i */
+    /* The 802.1Q-2005 (13.22.j) says that this parameter is substituted by
+     * the per-port Hello Time, but we still need it for compatibility
+     * with old STP implementations.
+     */
+    __u8 Hello_Time;
     unsigned int Transmit_Hold_Count; /* 13.22.g */
     unsigned int Migrate_Time;        /* 13.22.h */
     unsigned int Ageing_Time;  /* 8.8.3 */
@@ -588,6 +593,7 @@ typedef struct
     unsigned int internal_path_cost;
     bool enabled; /* not in standard */
     __u8 max_hops;
+    __u8 bridge_hello_time;
 } CIST_BridgeStatus;
 
 void MSTP_IN_get_cist_bridge_status(bridge_t *br, CIST_BridgeStatus *status);
@@ -627,6 +633,9 @@ typedef struct
 
     __u8 max_hops;
     bool set_max_hops;
+
+    __u8 bridge_hello_time;
+    bool set_bridge_hello_time;
 } CIST_BridgeConfig;
 
 int MSTP_IN_set_cist_bridge_config(bridge_t *br, CIST_BridgeConfig *cfg);