[Olsr-dev] [PATCH v1 12/23] gateway: add SmartGatewayUseCount configuration parameter
Ferry Huberts
(spam-protected)
Tue Dec 4 16:17:19 CET 2012
From: Ferry Huberts <(spam-protected)>
We can now configure multiple 'active' gateways (although we only
allow 1 for now until the functionality is complete).
Multiple active gateways are used to reduce breaking connections
in a dynamic network.
Signed-off-by: Ferry Huberts <(spam-protected)>
---
README-Olsr-Extensions | 15 ++++++++++-----
files/olsrd.conf.default.full | 7 +++++++
files/olsrd.conf.default.lq | 7 +++++++
files/olsrd.conf.default.lq-fisheye | 7 +++++++
lib/jsoninfo/src/olsrd_jsoninfo.c | 1 +
src/cfgparser/cfgfile_gen.c | 10 ++++++++++
src/cfgparser/olsrd_conf.c | 8 ++++++++
src/cfgparser/oparse.y | 10 ++++++++++
src/cfgparser/oscan.lex | 5 +++++
src/olsr_cfg.h | 5 +++++
10 files changed, 70 insertions(+), 5 deletions(-)
diff --git a/README-Olsr-Extensions b/README-Olsr-Extensions
index ac244cf..c7663fe 100644
--- a/README-Olsr-Extensions
+++ b/README-Olsr-Extensions
@@ -251,20 +251,25 @@ All other parameters will be ignored if SmartGateway is set to "no"
5.2) Client Side
-1- SmartGatewayAllowNAT controls whether you want to allow the selection
+1- SmartGatewayUseCount controls the maximum number of gateways that can be
+ in use at any given time. This setting is used to mitigate the effects of
+ breaking connections (due to the selection of a new gateway) on a dynamic
+ network.
+ The default setting is 1.
+2- SmartGatewayAllowNAT controls whether you want to allow the selection
of an outgoing ipv4 gateway with NAT (Network Address Translation).
The default setting is "yes".
-2- SmartGatewayPeriod determines the period (in milliseconds) on which
+3- SmartGatewayPeriod determines the period (in milliseconds) on which
a new smart gateway selection is performed.
The default setting is 10000 milliseconds.
-3- SmartGatewayStableCount determines the number of times the link state
+4- SmartGatewayStableCount determines the number of times the link state
database must be stable before a new smart gateway is selected.
The default setting is 6.
-4- SmartGatewayThreshold controls whether you want to allow re-selection
+5- SmartGatewayThreshold controls whether you want to allow re-selection
of a new outgoing gateway if its routing cost is lower or equal to the
configured percentage of the routing cost of the current gateway.
The default setting is 0, which disables it.
-5- SmartGatewayWeightExitLinkUp, SmartGatewayWeightExitLinkDown,
+6- SmartGatewayWeightExitLinkUp, SmartGatewayWeightExitLinkDown,
SmartGatewayWeightEtx and SmartGatewayDividerEtx control the weighing
of gateway bandwidth and ETX costs.
diff --git a/files/olsrd.conf.default.full b/files/olsrd.conf.default.full
index 6b11c7d..72de099 100644
--- a/files/olsrd.conf.default.full
+++ b/files/olsrd.conf.default.full
@@ -144,6 +144,13 @@
# SmartGateway no
+# Determines the maximum number of gateways that can be in use at any given
+# time. This setting is used to mitigate the effects of breaking connections
+# (due to the selection of a new gateway) on a dynamic network.
+# (default is 1)
+
+# SmartGatewayUseCount 1
+
# Allows the selection of a smartgateway with NAT (only for IPv4)
# (default is "yes")
diff --git a/files/olsrd.conf.default.lq b/files/olsrd.conf.default.lq
index 4ed0650..b3c2976 100644
--- a/files/olsrd.conf.default.lq
+++ b/files/olsrd.conf.default.lq
@@ -81,6 +81,13 @@
# SmartGateway no
+# Determines the maximum number of gateways that can be in use at any given
+# time. This setting is used to mitigate the effects of breaking connections
+# (due to the selection of a new gateway) on a dynamic network.
+# (default is 1)
+
+# SmartGatewayUseCount 1
+
# Allows the selection of a smartgateway with NAT (only for IPv4)
# (default is "yes")
diff --git a/files/olsrd.conf.default.lq-fisheye b/files/olsrd.conf.default.lq-fisheye
index 0437239..878505f 100644
--- a/files/olsrd.conf.default.lq-fisheye
+++ b/files/olsrd.conf.default.lq-fisheye
@@ -81,6 +81,13 @@
# SmartGateway no
+# Determines the maximum number of gateways that can be in use at any given
+# time. This setting is used to mitigate the effects of breaking connections
+# (due to the selection of a new gateway) on a dynamic network.
+# (default is 1)
+
+# SmartGatewayUseCount 1
+
# Allows the selection of a smartgateway with NAT (only for IPv4)
# (default is "yes")
diff --git a/lib/jsoninfo/src/olsrd_jsoninfo.c b/lib/jsoninfo/src/olsrd_jsoninfo.c
index c7d8a38..142d0d8 100644
--- a/lib/jsoninfo/src/olsrd_jsoninfo.c
+++ b/lib/jsoninfo/src/olsrd_jsoninfo.c
@@ -986,6 +986,7 @@ ipc_print_config(struct autobuf *abuf)
#ifdef __linux__
abuf_json_boolean(abuf, "smartGateway", olsr_cnf->smart_gw_active);
if (olsr_cnf->smart_gw_active) {
+ abuf_json_int(abuf, "smartGatewayUseCount", olsr_cnf->smart_gw_use_count);
abuf_json_boolean(abuf, "smartGatewayAllowNat", olsr_cnf->smart_gw_allow_nat);
abuf_json_boolean(abuf, "smartGatewayUplinkNat", olsr_cnf->smart_gw_uplink_nat);
abuf_json_int(abuf, "smartGatewayPeriod", olsr_cnf->smart_gw_period);
diff --git a/src/cfgparser/cfgfile_gen.c b/src/cfgparser/cfgfile_gen.c
index 768bf8f..629fa9c 100644
--- a/src/cfgparser/cfgfile_gen.c
+++ b/src/cfgparser/cfgfile_gen.c
@@ -438,6 +438,16 @@ void olsrd_write_cnf_autobuf(struct autobuf *out, struct olsrd_config *cnf) {
cnf->smart_gw_active ? "yes" : "no");
abuf_puts(out,
"\n"
+ "# Determines the maximum number of gateways that can be in use at any given\n"
+ "# time. This setting is used to mitigate the effects of breaking connections\n"
+ "# (due to the selection of a new gateway) on a dynamic network.\n"
+ "# (default is 1)\n"
+ "\n");
+ abuf_appendf(out, "%sSmartGatewayUseCount %d\n",
+ cnf->smart_gw_use_count == DEF_GW_USE_COUNT ? "# " : "",
+ cnf->smart_gw_use_count);
+ abuf_puts(out,
+ "\n"
"# Allows the selection of a smartgateway with NAT (only for IPv4)\n"
"# (default is \"yes\")\n"
"\n");
diff --git a/src/cfgparser/olsrd_conf.c b/src/cfgparser/olsrd_conf.c
index 0838037..c747655 100644
--- a/src/cfgparser/olsrd_conf.c
+++ b/src/cfgparser/olsrd_conf.c
@@ -554,6 +554,11 @@ olsrd_sanity_check_cnf(struct olsrd_config *cnf)
}
#ifdef __linux__
+ if ((cnf->smart_gw_use_count < MIN_SMARTGW_USE_COUNT_MIN) || (cnf->smart_gw_use_count > MAX_SMARTGW_USE_COUNT_MAX)) {
+ fprintf(stderr, "Error, bad gateway use count %d, outside of range [%d, %d]\n",
+ cnf->smart_gw_use_count, MIN_SMARTGW_USE_COUNT_MIN, MAX_SMARTGW_USE_COUNT_MAX);
+ return -1;
+ }
if (cnf->smart_gw_period < MIN_SMARTGW_PERIOD || cnf->smart_gw_period > MAX_SMARTGW_PERIOD) {
fprintf(stderr, "Error, bad gateway period: %d msec (should be %d-%d)\n",
cnf->smart_gw_period, MIN_SMARTGW_PERIOD, MAX_SMARTGW_PERIOD);
@@ -787,6 +792,7 @@ set_default_cnf(struct olsrd_config *cnf)
cnf->niit6to4_if_index = 0;
cnf->smart_gw_active = DEF_SMART_GW;
+ cnf->smart_gw_use_count = DEF_GW_USE_COUNT;
cnf->smart_gw_allow_nat = DEF_GW_ALLOW_NAT;
cnf->smart_gw_period = DEF_GW_PERIOD;
cnf->smart_gw_stablecount = DEF_GW_STABLE_COUNT;
@@ -915,6 +921,8 @@ olsrd_print_cnf(struct olsrd_config *cnf)
printf("Smart Gateway : %s\n", cnf->smart_gw_active ? "yes" : "no");
+ printf("SmGw. Use Count : %u\n", cnf->smart_gw_use_count);
+
printf("SmGw. Allow NAT : %s\n", cnf->smart_gw_allow_nat ? "yes" : "no");
printf("SmGw. period : %d\n", cnf->smart_gw_period);
diff --git a/src/cfgparser/oparse.y b/src/cfgparser/oparse.y
index c123ae4..9c253ac 100644
--- a/src/cfgparser/oparse.y
+++ b/src/cfgparser/oparse.y
@@ -215,6 +215,7 @@ static int add_ipv6_addr(YYSTYPE ipaddr_arg, YYSTYPE prefixlen_arg)
%token TOK_LOCK_FILE
%token TOK_USE_NIIT
%token TOK_SMART_GW
+%token TOK_SMART_GW_USE_COUNT
%token TOK_SMART_GW_ALLOW_NAT
%token TOK_SMART_GW_PERIOD
%token TOK_SMART_GW_STABLECOUNT
@@ -302,6 +303,7 @@ stmt: idebug
| alock_file
| suse_niit
| bsmart_gw
+ | ismart_gw_use_count
| bsmart_gw_allow_nat
| ismart_gw_period
| asmart_gw_stablecount
@@ -1304,6 +1306,14 @@ bsmart_gw: TOK_SMART_GW TOK_BOOLEAN
}
;
+ismart_gw_use_count: TOK_SMART_GW_USE_COUNT TOK_INTEGER
+{
+ PARSER_DEBUG_PRINTF("Smart gateway use count: %d\n", $2->integer);
+ olsr_cnf->smart_gw_use_count = $2->integer;
+ free($2);
+}
+;
+
bsmart_gw_allow_nat: TOK_SMART_GW_ALLOW_NAT TOK_BOOLEAN
{
PARSER_DEBUG_PRINTF("Smart gateway allow client nat: %s\n", $2->boolean ? "yes" : "no");
diff --git a/src/cfgparser/oscan.lex b/src/cfgparser/oscan.lex
index 194c53a..25e109f 100644
--- a/src/cfgparser/oscan.lex
+++ b/src/cfgparser/oscan.lex
@@ -466,6 +466,11 @@ IPV6ADDR {IPV6PAT1}|{IPV6PAT2}|{IPV6PAT3}|{IPV6PAT4}|{IPV6PAT5}|{IPV6PAT6}|{IPV6
return TOK_SMART_GW;
}
+"SmartGatewayUseCount" {
+ yylval = NULL;
+ return TOK_SMART_GW_USE_COUNT;
+}
+
"SmartGatewayAllowNAT" {
yylval = NULL;
return TOK_SMART_GW_ALLOW_NAT;
diff --git a/src/olsr_cfg.h b/src/olsr_cfg.h
index 7e4cb11..6bccbb2 100644
--- a/src/olsr_cfg.h
+++ b/src/olsr_cfg.h
@@ -81,6 +81,7 @@
#define DEF_MIN_TC_VTIME 0.0
#define DEF_USE_NIIT true
#define DEF_SMART_GW false
+#define DEF_GW_USE_COUNT 1
#define DEF_GW_PERIOD 10*1000
#define DEF_GW_STABLE_COUNT 6
#define DEF_GW_ALLOW_NAT true
@@ -122,6 +123,9 @@
#define MAX_LQ_AGING 1.0
#define MIN_LQ_AGING 0.01
+#define MIN_SMARTGW_USE_COUNT_MIN 1
+#define MAX_SMARTGW_USE_COUNT_MAX 1
+
#define MIN_SMARTGW_PERIOD 1*1000
#define MAX_SMARTGW_PERIOD 320000*1000
@@ -276,6 +280,7 @@ struct olsrd_config {
bool use_niit;
bool smart_gw_active, smart_gw_allow_nat, smart_gw_uplink_nat;
+ uint8_t smart_gw_use_count;
uint32_t smart_gw_period;
uint8_t smart_gw_stablecount;
uint8_t smart_gw_thresh;
--
1.7.11.7
More information about the Olsr-dev
mailing list