summaryrefslogtreecommitdiffstats
path: root/xlators/protocol
diff options
context:
space:
mode:
authorKaushik BV <kaushikbv@gluster.com>2010-10-05 07:02:07 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-10-05 05:47:38 -0700
commit6b74f3ec7b6e0fed2e253df456b067fc27049117 (patch)
treea4f51f043b8d169bf1be46e7b482fca9f3d29d77 /xlators/protocol
parent7aec50bdad06665243a16f1ce83a03037bcd5d56 (diff)
Reply back to CLI on error, by validating each xlator's opts
Signed-off-by: Kaushik BV <kaushikbv@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1159 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1159
Diffstat (limited to 'xlators/protocol')
-rw-r--r--xlators/protocol/client/src/client.c71
-rw-r--r--xlators/protocol/server/src/server.c79
2 files changed, 150 insertions, 0 deletions
diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c
index 5cf3b1ea19f..50cb917aacc 100644
--- a/xlators/protocol/client/src/client.c
+++ b/xlators/protocol/client/src/client.c
@@ -1782,6 +1782,77 @@ out:
}
int
+validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+{
+ int ret = 0;
+ int timeout_ret=0;
+ int ping_timeout;
+ int frame_timeout;
+
+
+ timeout_ret = dict_get_int32 (options, "frame-timeout",
+ &frame_timeout);
+ if (timeout_ret == 0) {
+ if (frame_timeout < 5 ) {
+ gf_log (this->name, GF_LOG_WARNING, "Validation"
+ "'option frame-timeout %d failed , Min value"
+ " can be 5", frame_timeout);
+ *op_errstr = gf_strdup ("Error, Min Value 5");
+ ret = -1;
+ goto out;
+ }
+
+ if (frame_timeout > 86400 ) {
+ gf_log (this->name, GF_LOG_WARNING, "Reconfiguration"
+ "'option frame-timeout %d failed , Max value"
+ "can be 86400", frame_timeout );
+ *op_errstr = gf_strdup ("Error, Max Value 86400");
+ ret = -1;
+ goto out;
+ }
+
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ "validation otion frame-timeout to %d",
+ frame_timeout);
+
+ }
+
+ timeout_ret = dict_get_int32 (options, "ping-timeout",
+ &ping_timeout);
+ if (timeout_ret == 0) {
+
+ if (ping_timeout < 5 ) {
+ gf_log (this->name, GF_LOG_WARNING, "Reconfiguration"
+ "'option ping-timeout %d failed , Min value"
+ " can be 5", ping_timeout);
+ *op_errstr = gf_strdup ("Error, Min Value 5");
+ ret = -1;
+ goto out;
+ }
+
+ if (ping_timeout > 1013 ) {
+ gf_log (this->name, GF_LOG_WARNING, "Reconfiguration"
+ "'option frame-timeout %d failed , Max value"
+ "can be 1013,", frame_timeout);
+ *op_errstr = gf_strdup ("Error, Max Value 1013");
+ ret = -1;
+ goto out;
+ }
+
+ gf_log (this->name, GF_LOG_DEBUG, "Validated "
+ "'option ping-timeout' to %d", ping_timeout);
+
+ }
+
+ ret = 0;
+
+out:
+ return ret;
+
+}
+
+int
reconfigure (xlator_t *this, dict_t *options)
{
int ret = 0;
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
index 1594b8d0a01..2851f8cea86 100644
--- a/xlators/protocol/server/src/server.c
+++ b/xlators/protocol/server/src/server.c
@@ -456,6 +456,84 @@ mem_acct_init (xlator_t *this)
return ret;
}
+int
+validate_options (xlator_t *this, dict_t *options, char **op_errstr)
+{
+ int inode_lru_limit = 0;
+ char errstr[1024] = {0, };
+ dict_t *auth_modules = NULL;
+ int ret = 0;
+ data_t *data;
+ gf_boolean_t trace;
+
+
+
+ if (dict_get_int32 ( options, "inode-lru-limit", &inode_lru_limit) == 0){
+ if (!(inode_lru_limit < (1 * GF_UNIT_MB) &&
+ inode_lru_limit >1 )) {
+ gf_log (this->name, GF_LOG_DEBUG, "Validate inode-lru"
+ "-limit %d, was WRONG", inode_lru_limit);
+ snprintf (errstr,1024, "Error, Greater than max value %d "
+ ,inode_lru_limit);
+
+ *op_errstr = gf_strdup (errstr);
+ ret = -1;
+ goto out;
+ }
+ }
+
+ data = dict_get (options, "trace");
+ if (data) {
+ ret = gf_string2boolean (data->data, &trace);
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "'trace' takes on only boolean values. "
+ "Neglecting option");
+ snprintf (errstr,1024, "Error, trace takes only boolean"
+ "values");
+ *op_errstr = gf_strdup (errstr);
+ ret = -1;
+ goto out;
+ }
+ }
+
+ if (!auth_modules)
+ auth_modules = dict_new ();
+
+ dict_foreach (options, get_auth_types, auth_modules);
+ ret = validate_auth_options (this, options);
+ if (ret == -1) {
+ /* logging already done in validate_auth_options function. */
+ snprintf (errstr,1024, "authentication values are incorrect");
+ *op_errstr = gf_strdup (errstr);
+ goto out;
+ }
+
+ ret = gf_auth_init (this, auth_modules);
+ if (ret) {
+ dict_unref (auth_modules);
+ goto out;
+ }
+out:
+
+ return ret;
+}
+
+static void
+_copy_auth_opt (dict_t *unused,
+ char *key,
+ data_t *value,
+ void *xl_dict)
+{
+ char *auth_option_pattern[] = { "auth.addr.*.allow",
+ "auth.addr.*.reject"};
+ if (fnmatch ( auth_option_pattern[0], key, 0) != 0)
+ dict_set ((dict_t *)xl_dict, key, (value));
+
+ if (fnmatch ( auth_option_pattern[1], key, 0) != 0)
+ dict_set ((dict_t *)xl_dict, key, (value));
+}
+
int
reconfigure (xlator_t *this, dict_t *options)
@@ -499,6 +577,7 @@ reconfigure (xlator_t *this, dict_t *options)
/* logging already done in validate_auth_options function. */
goto out;
}
+ dict_foreach (options, _copy_auth_opt, this->options);
ret = gf_auth_init (this, conf->auth_modules);
if (ret) {