From 36030685e00189de8f7a4522956d8c5bc5017c9e Mon Sep 17 00:00:00 2001 From: dv1tas Date: Wed, 29 May 2013 10:35:41 +0000 Subject: [PATCH] Add support for setting ageing time Signed-off-by: Satish Ashok Signed-off-by: Vitalii Demianets git-svn-id: svn://svn.code.sf.net/p/mstpd/code/trunk@39 fbe50366-0c72-4402-a84b-5d246361dba7 --- ctl_main.c | 26 +++++++++++++++++++++----- mstp.c | 21 +++++++++++++++++++++ mstp.h | 4 ++++ 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/ctl_main.c b/ctl_main.c index 8dfc7d5..de07853 100644 --- a/ctl_main.c +++ b/ctl_main.c @@ -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[] = " ", "Set bridge max hops (6-40)"}, {2, 0, "sethello", cmd_setbridgehello, " ", "Set bridge hello time (1-10)"}, + {2, 0, "setageing", cmd_setbridgeageing, + " ", "Set bridge ageing time (10-1000000)"}, {2, 0, "setforcevers", cmd_setbridgeforcevers, " {mstp|rstp|stp}", "Force Spanning Tree protocol version"}, {2, 0, "settxholdcount", cmd_setbridgetxholdcount, diff --git a/mstp.c b/mstp.c index fb2c5ec..d2bfc7b 100644 --- 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 5bec14c..a069267 100644 --- 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); -- 2.47.2