]> git.ipfire.org Git - people/ms/mstpd.git/commitdiff
Add support for setting ageing time
authordv1tas <dv1tas@fbe50366-0c72-4402-a84b-5d246361dba7>
Wed, 29 May 2013 10:35:41 +0000 (10:35 +0000)
committerdv1tas <dv1tas@fbe50366-0c72-4402-a84b-5d246361dba7>
Wed, 29 May 2013 10:35:41 +0000 (10:35 +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@39 fbe50366-0c72-4402-a84b-5d246361dba7

ctl_main.c
mstp.c
mstp.h

index 8dfc7d5c0940ec258571c81928e9cc9f8d475c4f..de07853798a802540a9c886382eec1ae4c7a86fe 100644 (file)
@@ -104,6 +104,7 @@ typedef enum {
     PARAM_TXHOLDCNT,
     PARAM_MAXHOPS,
     PARAM_BRHELLO,
+    PARAM_BRAGEING,
     PARAM_FORCEPROTVERS,
     PARAM_TOPCHNGTIME,
     PARAM_TOPCHNGCNT,
@@ -153,6 +154,7 @@ static const cmd_param_t cist_bridge_params[] = {
     { PARAM_TXHOLDCNT,    "tx-hold-count" },
     { PARAM_MAXHOPS,      "max-hops" },
     { PARAM_BRHELLO,      "hello-time" },
+    { PARAM_BRAGEING,     "ageing-time" },
     { PARAM_FORCEPROTVERS,"force-protocol-version" },
     { PARAM_TOPCHNGTIME,  "time-since-topology-change" },
     { PARAM_TOPCHNGCNT,   "topology-change-count" },
@@ -187,15 +189,16 @@ 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("max hops             %hhu\n", s.max_hops);
             printf("  hello time    %-10u ", s.bridge_hello_time);
-            printf("force protocol version %s\n",
+            printf("ageing time          %u\n", s.Ageing_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);
@@ -249,6 +252,9 @@ static int do_showbridge(const char *br_name, param_id_t param_id)
         case PARAM_BRHELLO:
             printf("%hhu\n", s.bridge_hello_time);
             break;
+        case PARAM_BRAGEING:
+            printf("%u\n", s.Ageing_Time);
+            break;
         case PARAM_FORCEPROTVERS:
             printf("%s\n", PROTO_VERS_STR(s.protocol_version));
             break;
@@ -982,6 +988,14 @@ static int cmd_setbridgetxholdcount(int argc, char *const *argv)
     return set_bridge_cfg(tx_hold_count, getuint(argv[2]));
 }
 
+static int cmd_setbridgeageing(int argc, char *const *argv)
+{
+    int br_index = get_index(argv[1], "bridge");
+    if(0 > br_index)
+        return br_index;
+    return set_bridge_cfg(bridge_ageing_time, getuint(argv[2]));
+}
+
 static int cmd_settreeprio(int argc, char *const *argv)
 {
     int br_index = get_index(argv[1], "bridge");
@@ -1451,6 +1465,8 @@ static const struct command commands[] =
      "<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, "setageing", cmd_setbridgeageing,
+     "<bridge> <ageing_time>", "Set bridge ageing time (10-1000000)"},
     {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 fb2c5ec5baa87430dd386a4a0251c72385a520bb..d2bfc7ba4736bafea53730905c046eca53b4396f 100644 (file)
--- a/mstp.c
+++ b/mstp.c
@@ -586,6 +586,7 @@ void MSTP_IN_get_cist_bridge_status(bridge_t *br, CIST_BridgeStatus *status)
     status->protocol_version = br->ForceProtocolVersion;
     status->enabled = br->bridgeEnabled;
     assign(status->bridge_hello_time, br->Hello_Time);
+    assign(status->Ageing_Time, br->Ageing_Time);
 }
 
 /* 12.8.1.2 Read MSTI Bridge Protocol Parameters */
@@ -692,6 +693,16 @@ int MSTP_IN_set_cist_bridge_config(bridge_t *br, CIST_BridgeConfig *cfg)
         }
     }
 
+    if(cfg->set_bridge_ageing_time)
+    {
+        if((10 > cfg->bridge_ageing_time)||(1000000 < cfg->bridge_ageing_time))
+        {
+            ERROR_BRNAME(br,
+                "Bridge Ageing Time must be between 10 and 1000000 seconds");
+            r = -1;
+        }
+    }
+
     if(r)
         return r;
 
@@ -749,6 +760,16 @@ int MSTP_IN_set_cist_bridge_config(bridge_t *br, CIST_BridgeConfig *cfg)
         }
     }
 
+    if(cfg->set_bridge_ageing_time)
+    {
+        if(cfg->bridge_ageing_time != br->Ageing_Time)
+        {
+            INFO_BRNAME(br, "bridge ageing_time new=%u, old=%u",
+                        cfg->bridge_ageing_time, br->Ageing_Time);
+            assign(br->Ageing_Time, cfg->bridge_ageing_time);
+        }
+    }
+
     /* Thirdly, finalize changes */
     if(changedBridgeTimes)
     {
diff --git a/mstp.h b/mstp.h
index 5bec14cf35e93515b6ecf6c62c01e53fef2c69fb..a0692671bd8be3b64b40841dea11b03f6c01e7dc 100644 (file)
--- a/mstp.h
+++ b/mstp.h
@@ -592,6 +592,7 @@ typedef struct
     bridge_identifier_t regional_root;
     unsigned int internal_path_cost;
     bool enabled; /* not in standard */
+    unsigned int Ageing_Time;
     __u8 max_hops;
     __u8 bridge_hello_time;
 } CIST_BridgeStatus;
@@ -636,6 +637,9 @@ typedef struct
 
     __u8 bridge_hello_time;
     bool set_bridge_hello_time;
+
+    unsigned int bridge_ageing_time;
+    bool set_bridge_ageing_time;
 } CIST_BridgeConfig;
 
 int MSTP_IN_set_cist_bridge_config(bridge_t *br, CIST_BridgeConfig *cfg);