Skip to contentSkip to conversation

mount.nfs: dont pass options from configuration sections that are not relevant

PATCH In review Scott Mayhew 3 participants 3 messages Aug 14, 2013 – Aug 19, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mount.nfs: dont pass options from configuration sections that are not relevant

The nfsmount.conf file has the following format:

[ section "arg" ]
tag = value

conf_get_tag_list() currently doesn't check the arg field so we wind up getting all the options that fall under a particular section value, instead of just the ones that match the specific "arg" field. As a result, we wind up passing options to the mount syscall from sections that aren't even relevant to the mount operation that is being performed.

For example, if we have three different server sections, and each section has an Nfsvers tag, then the string we pass to the mount syscall will have two extra occurrences of the nfsvers option. Each option should appear at most 4 times -- once for the system section, once for the server-specific section, once for the mount-specific section, and once for the command line mount options.

---
 support/include/conffile.h | 2 +-
 support/nfs/conffile.c     | 4 +++-
 utils/mount/configfile.c   | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)
support/include/conffile.h +1 -1
index ce7aa21..05ea5d2 100644
@@ -54,7 +54,7 @@ extern int      conf_end(int, int);
 extern void     conf_free_list(struct conf_list *);
 extern struct sockaddr *conf_get_address(char *, char *);
 extern struct conf_list *conf_get_list(char *, char *);
-extern struct conf_list *conf_get_tag_list(char *);
+extern struct conf_list *conf_get_tag_list(char *, char *);
 extern int      conf_get_num(char *, char *, int);
 extern char    *conf_get_str(char *, char *);
 extern char    *conf_get_section(char *, char *, char *);
support/nfs/conffile.c +3 -1
index 5015e94..c3434d5 100644
@@ -565,7 +565,7 @@ cleanup:
 }
 
 struct conf_list *
-conf_get_tag_list(char *section)
+conf_get_tag_list(char *section, char *arg)
 {
 	struct conf_list *list = 0;
 	struct conf_list_node *node;
@@ -579,6 +579,8 @@ conf_get_tag_list(char *section)
 	cb = LIST_FIRST(&conf_bindings[conf_hash (section)]);
 	for (; cb; cb = LIST_NEXT(cb, link)) {
 		if (strcasecmp (section, cb->section) == 0) {
+			if (arg != NULL && strcasecmp(arg, cb->arg) != 0)
+				continue;
 			list->cnt++;
 			node = calloc(1, sizeof *node);
 			if (!node)
utils/mount/configfile.c +1 -1
index 6f2ee75..1f1b6e7 100644
@@ -286,7 +286,7 @@ conf_parse_mntopts(char *section, char *arg, char *opts)
 	char *nvalue, *ptr;
 	int argtype;
 
-	list = conf_get_tag_list(section);
+	list = conf_get_tag_list(section, arg);
 	TAILQ_FOREACH(node, &list->fields, link) {
 		/*
 		 * Do not overwrite options if already exists 
Signature · 1 line
1.7.11.7
Acked-by on v1 1/1
#1 lore raw
Quoted 12 lines · Scott Mayhew

The nfsmount.conf file has the following format:

[ section "arg" ]
tag = value

conf_get_tag_list() currently doesn't check the arg field so we wind up getting all the options that fall under a particular section value, instead of just the ones that match the specific "arg" field. As a result, we wind up passing options to the mount syscall from sections that aren't even relevant to the mount operation that is being performed.

Quoted 8 lines

For example, if we have three different server sections, and each section has an Nfsvers tag, then the string we pass to the mount syscall will have two extra occurrences of the nfsvers option. Each option should appear at most 4 times -- once for the system section, once for the server-specific section, once for the mount-specific section, and once for the command line mount options.

Btw, is there still a problem with "sloppy" ?

Quoted 61 lines

---

support/include/conffile.h | 2 +-
support/nfs/conffile.c     | 4 +++-
utils/mount/configfile.c   | 2 +-
3 files changed, 5 insertions(+), 3 deletions(-)
support/include/conffile.h +1 -1
index ce7aa21..05ea5d2 100644
@@ -54,7 +54,7 @@ extern int      conf_end(int, int);
 extern void     conf_free_list(struct conf_list *);
 extern struct sockaddr *conf_get_address(char *, char *);
 extern struct conf_list *conf_get_list(char *, char *);
-extern struct conf_list *conf_get_tag_list(char *);
+extern struct conf_list *conf_get_tag_list(char *, char *);
 extern int      conf_get_num(char *, char *, int);
 extern char    *conf_get_str(char *, char *);
 extern char    *conf_get_section(char *, char *, char *);
support/nfs/conffile.c +0 -0
index 5015e94..c3434d5 100644
@@ -565,7 +565,7 @@ cleanup:
 }
 

struct conf_list *

support/nfs/conffile.c +1 -1
-conf_get_tag_list(char *section)
+conf_get_tag_list(char *section, char *arg)
{
	struct conf_list *list = 0;
	struct conf_list_node *node;
support/nfs/conffile.c +2 -0
@@ -579,6 +579,8 @@ conf_get_tag_list(char *section)
 	cb = LIST_FIRST(&conf_bindings[conf_hash (section)]);
 	for (; cb; cb = LIST_NEXT(cb, link)) {
 		if (strcasecmp (section, cb->section) == 0) {
+			if (arg != NULL && strcasecmp(arg, cb->arg) != 0)
+				continue;
 			list->cnt++;
 			node = calloc(1, sizeof *node);
 			if (!node)
utils/mount/configfile.c +1 -1
index 6f2ee75..1f1b6e7 100644
@@ -286,7 +286,7 @@ conf_parse_mntopts(char *section, char *arg, char *opts)
 	char *nvalue, *ptr;
 	int argtype;
 
-	list = conf_get_tag_list(section);
+	list = conf_get_tag_list(section, arg);
 	TAILQ_FOREACH(node, &list->fields, link) {
 		/*
 		 * Do not overwrite options if already exists 
Signature · 6 lines
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com

#2 lore raw
In reply to Scott Mayhew
Quoted 12 lines · Scott Mayhew

The nfsmount.conf file has the following format:

[ section "arg" ]
tag = value

conf_get_tag_list() currently doesn't check the arg field so we wind up getting all the options that fall under a particular section value, instead of just the ones that match the specific "arg" field. As a result, we wind up passing options to the mount syscall from sections that aren't even relevant to the mount operation that is being performed.

Quoted 8 lines

For example, if we have three different server sections, and each section has an Nfsvers tag, then the string we pass to the mount syscall will have two extra occurrences of the nfsvers option. Each option should appear at most 4 times -- once for the system section, once for the server-specific section, once for the mount-specific section, and once for the command line mount options.

Committed...

steved.

Quoted 55 lines
---
 support/include/conffile.h | 2 +-
 support/nfs/conffile.c     | 4 +++-
 utils/mount/configfile.c   | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)
support/include/conffile.h +1 -1
index ce7aa21..05ea5d2 100644
@@ -54,7 +54,7 @@ extern int      conf_end(int, int);
 extern void     conf_free_list(struct conf_list *);
 extern struct sockaddr *conf_get_address(char *, char *);
 extern struct conf_list *conf_get_list(char *, char *);
-extern struct conf_list *conf_get_tag_list(char *);
+extern struct conf_list *conf_get_tag_list(char *, char *);
 extern int      conf_get_num(char *, char *, int);
 extern char    *conf_get_str(char *, char *);
 extern char    *conf_get_section(char *, char *, char *);
support/nfs/conffile.c +3 -1
index 5015e94..c3434d5 100644
@@ -565,7 +565,7 @@ cleanup:
 }
 
 struct conf_list *
-conf_get_tag_list(char *section)
+conf_get_tag_list(char *section, char *arg)
 {
 	struct conf_list *list = 0;
 	struct conf_list_node *node;
@@ -579,6 +579,8 @@ conf_get_tag_list(char *section)
 	cb = LIST_FIRST(&conf_bindings[conf_hash (section)]);
 	for (; cb; cb = LIST_NEXT(cb, link)) {
 		if (strcasecmp (section, cb->section) == 0) {
+			if (arg != NULL && strcasecmp(arg, cb->arg) != 0)
+				continue;
 			list->cnt++;
 			node = calloc(1, sizeof *node);
 			if (!node)
utils/mount/configfile.c +1 -1
index 6f2ee75..1f1b6e7 100644
@@ -286,7 +286,7 @@ conf_parse_mntopts(char *section, char *arg, char *opts)
 	char *nvalue, *ptr;
 	int argtype;
 
-	list = conf_get_tag_list(section);
+	list = conf_get_tag_list(section, arg);
 	TAILQ_FOREACH(node, &list->fields, link) {
 		/*
 		 * Do not overwrite options if already exists