Skip to contentSkip to conversation

IPv6-related nfs-utils bugs and regressions

PATCH In review Chuck Lever 2 participants 11 messages Dec 6, 2010 – Dec 13, 2010 3 messages not in the archive

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

cover IPv6-related nfs-utils bugs and regressions

Two of these are build regressions: the new code uses macros not defined in glibc 2.2.5 headers. The third fixes a longstanding bug with how statd and sm-notify sweep the sm/ and sm.bak/ directories looking for monitored host records.

---

Chuck Lever (3):
sm-notify: Make use of AI_NUMERICSERV conditional libnsm.a: Replace __attribute_noinline__ libnsm.a: sm-notify sometimes ignores monitored hosts

 support/nsm/file.c      |   48 ++++++++++++++++++++++++++++++++++-------------
 utils/statd/sm-notify.c |    6 ++++++
 2 files changed, 41 insertions(+), 13 deletions(-)
Signature · 1 line
Chuck Lever
#1 lore raw

PATCH 1/3 libnsm.a: sm-notify sometimes ignores monitored hosts

Monitored host information is stored in files under /var/lib/nfs. When visiting entries in the monitored hosts directory, libnsm.a examines the value of dirent.d_type to determine if an entry is a regular file.

According to readdir(3), the d_type field is not supported by all file system types. My root file system happens to be one where d_type isn't supported. Typical installations that use an ext-derived root file system are not exposed to this issue, but those who use xfs, for instance, are.

On such file systems, not only are remote peers not notified of reboots, but the NSM state number is never incremented. A statd warm restart would not re-monitor any hosts that were monitored before the restart.

When writing support/nsm/file.c, I copied the use of d_type from the original statd code, so this has likely been an issue for some time.

Replace the use of d_type in support/nsm/file.c with a call to lstat(2). It's extra code, but is guaranteed to work on all file system types.

Note there is a usage of d_type in gssd. I'll let gssd and rpcpipefs experts decide whether that's worth changing.

Fix for:

https://bugzilla.linux-nfs.org/show_bug.cgi?id=193

---

 support/nsm/file.c |   38 ++++++++++++++++++++++++++++++--------
 1 files changed, 30 insertions(+), 8 deletions(-)
support/nsm/file.c +30 -8
index f4baeb9..ba2a9ce 100644
@@ -568,11 +568,13 @@ nsm_retire_monitored_hosts(void)
 
 	while ((de = readdir(dir)) != NULL) {
 		char *src, *dst;
+		struct stat stb;
 
-		if (de->d_type != (unsigned char)DT_REG)
-			continue;
-		if (de->d_name[0] == '.')
+		if (de->d_name[0] == '.') {
+			xlog(D_GENERAL, "Skipping dot file %s",
+					de->d_name);
 			continue;
+		}
 
 		src = nsm_make_record_pathname(NSM_MONITOR_DIR, de->d_name);
 		if (src == NULL) {
@@ -580,6 +582,20 @@ nsm_retire_monitored_hosts(void)
 			continue;
 		}
 
+		/* NB: not all file systems fill in d_type correctly */
+		if (lstat(src, &stb) == -1) {
+			xlog_warn("Bad monitor file %s, skipping: %m",
+					de->d_name);
+			free(src);
+			continue;
+		}
+		if (!S_ISREG(stb.st_mode)) {
+			xlog(D_GENERAL, "Skipping non-regular file %s",
+					de->d_name);
+			free(src);
+			continue;
+		}
+
 		dst = nsm_make_record_pathname(NSM_NOTIFY_DIR, de->d_name);
 		if (dst == NULL) {
 			free(src);
@@ -846,7 +862,7 @@ nsm_read_line(const char *hostname, const time_t timestamp, char *line,
 }
 
 /*
- * Given a filename, reads data from a file under NSM_MONITOR_DIR
+ * Given a filename, reads data from a file under "directory"
  * and invokes @func so caller can populate their in-core
  * database with this data.
  */
@@ -863,10 +879,15 @@ nsm_load_host(const char *directory, const char *filename, nsm_populate_t func)
 	if (path == NULL)
 		goto out_err;
 
-	if (stat(path, &stb) == -1) {
+	if (lstat(path, &stb) == -1) {
 		xlog(L_ERROR, "Failed to stat %s: %m", path);
 		goto out_freepath;
 	}
+	if (!S_ISREG(stb.st_mode)) {
+		xlog(D_GENERAL, "Skipping non-regular file %s",
+				path);
+		goto out_freepath;
+	}
 
 	f = fopen(path, "r");
 	if (f == NULL) {
@@ -913,10 +934,11 @@ nsm_load_dir(const char *directory, nsm_populate_t func)
 	}
 
 	while ((de = readdir(dir)) != NULL) {
-		if (de->d_type != (unsigned char)DT_REG)
-			continue;
-		if (de->d_name[0] == '.')
+		if (de->d_name[0] == '.') {
+			xlog(D_GENERAL, "Skipping dot file %s",
+					de->d_name);
 			continue;
+		}
 
 		count += nsm_load_host(directory, de->d_name, func);
 	}
#2 lore raw

Re: [PATCH 1/3] libnsm.a: sm-notify sometimes ignores monitored hosts

Hey Chuck,

Quoted 89 lines · Chuck Lever

Monitored host information is stored in files under /var/lib/nfs. When visiting entries in the monitored hosts directory, libnsm.a examines the value of dirent.d_type to determine if an entry is a regular file.

According to readdir(3), the d_type field is not supported by all file system types. My root file system happens to be one where d_type isn't supported. Typical installations that use an ext-derived root file system are not exposed to this issue, but those who use xfs, for instance, are.

On such file systems, not only are remote peers not notified of reboots, but the NSM state number is never incremented. A statd warm restart would not re-monitor any hosts that were monitored before the restart.

When writing support/nsm/file.c, I copied the use of d_type from the original statd code, so this has likely been an issue for some time.

Replace the use of d_type in support/nsm/file.c with a call to lstat(2). It's extra code, but is guaranteed to work on all file system types.

Note there is a usage of d_type in gssd. I'll let gssd and rpcpipefs experts decide whether that's worth changing.

Fix for:

https://bugzilla.linux-nfs.org/show_bug.cgi?id=193

---

 support/nsm/file.c |   38 ++++++++++++++++++++++++++++++--------
 1 files changed, 30 insertions(+), 8 deletions(-)
support/nsm/file.c +20 -4
index f4baeb9..ba2a9ce 100644
@@ -568,11 +568,13 @@ nsm_retire_monitored_hosts(void)
 
 	while ((de = readdir(dir)) != NULL) {
 		char *src, *dst;
+		struct stat stb;
 
-		if (de->d_type != (unsigned char)DT_REG)
-			continue;
-		if (de->d_name[0] == '.')
+		if (de->d_name[0] == '.') {
+			xlog(D_GENERAL, "Skipping dot file %s",
+					de->d_name);
 			continue;
+		}
 
 		src = nsm_make_record_pathname(NSM_MONITOR_DIR, de->d_name);
 		if (src == NULL) {
@@ -580,6 +582,20 @@ nsm_retire_monitored_hosts(void)
 			continue;
 		}
 
+		/* NB: not all file systems fill in d_type correctly */
+		if (lstat(src, &stb) == -1) {
+			xlog_warn("Bad monitor file %s, skipping: %m",
+					de->d_name);
+			free(src);
+			continue;
+		}
+		if (!S_ISREG(stb.st_mode)) {
+			xlog(D_GENERAL, "Skipping non-regular file %s",
+					de->d_name);
+			free(src);
+			continue;
+		}
+
 		dst = nsm_make_record_pathname(NSM_NOTIFY_DIR, de->d_name);
 		if (dst == NULL) {
 			free(src);
@@ -846,7 +862,7 @@ nsm_read_line(const char *hostname, const time_t timestamp, char *line,
 }
 
 /*
- * Given a filename, reads data from a file under NSM_MONITOR_DIR
+ * Given a filename, reads data from a file under "directory"
  * and invokes @func so caller can populate their in-core
  * database with this data.
  */
@@ -863,10 +879,15 @@ nsm_load_host(const char *directory, const char *filename, nsm_populate_t func)
 	if (path == NULL)

support/nsm/file.c nsm_load_host(const char *directory, const char *filename, nsm_populate_t func) · line 888

Quoted 10 lines
support/nsm/file.c +4 -1
 		goto out_err;
 
-	if (stat(path, &stb) == -1) {
+	if (lstat(path, &stb) == -1) {
 		xlog(L_ERROR, "Failed to stat %s: %m", path);
 		goto out_freepath;
 	}
+	if (!S_ISREG(stb.st_mode)) {
+		xlog(D_GENERAL, "Skipping non-regular file %s",
+				path);

Question, why do we care non-regular files are being ignored?

I understand logging the lstat() error but logging statements like "ignoring this" or "not doing that" just make the debug output a bit too noisy IMHO...

I'm thinking it would be better to log the files that are actually being used verses files that are being ignored.

Quoted 6 lines
support/nsm/file.c +2 -0
+		goto out_freepath;
+	}
 
 	f = fopen(path, "r");
 	if (f == NULL) {

support/nsm/file.c nsm_load_dir(const char *directory, nsm_populate_t func) · line 939

Quoted 9 lines
support/nsm/file.c +3 -3
@@ -913,10 +934,11 @@ nsm_load_dir(const char *directory, nsm_populate_t func)
 	}
 
 	while ((de = readdir(dir)) != NULL) {
-		if (de->d_type != (unsigned char)DT_REG)
-			continue;
-		if (de->d_name[0] == '.')
+		if (de->d_name[0] == '.') {
+			xlog(D_GENERAL, "Skipping dot file %s",
+					de->d_name);

The same goes with this... Do we really care "." and ".." are being ignored? Isn't that expected? ;-)

steved.

Quoted 6 lines
support/nsm/file.c +1 -0
 			continue;
+		}
 
 		count += nsm_load_host(directory, de->d_name, func);
 	}
#3 lore raw

Re: [PATCH 1/3] libnsm.a: sm-notify sometimes ignores monitored hosts

Quoted 94 lines · Steve Dickson

Hey Chuck,

Quoted 91 lines · Chuck Lever

Monitored host information is stored in files under /var/lib/nfs. When visiting entries in the monitored hosts directory, libnsm.a examines the value of dirent.d_type to determine if an entry is a regular file.

According to readdir(3), the d_type field is not supported by all file system types. My root file system happens to be one where d_type isn't supported. Typical installations that use an ext-derived root file system are not exposed to this issue, but those who use xfs, for instance, are.

On such file systems, not only are remote peers not notified of reboots, but the NSM state number is never incremented. A statd warm restart would not re-monitor any hosts that were monitored before the restart.

When writing support/nsm/file.c, I copied the use of d_type from the original statd code, so this has likely been an issue for some time.

Replace the use of d_type in support/nsm/file.c with a call to lstat(2). It's extra code, but is guaranteed to work on all file system types.

Note there is a usage of d_type in gssd. I'll let gssd and rpcpipefs experts decide whether that's worth changing.

Fix for:

https://bugzilla.linux-nfs.org/show_bug.cgi?id=193

---

support/nsm/file.c | 38 ++++++++++++++++++++++++++++++--------

1 files changed, 30 insertions(+), 8 deletions(-)
support/nsm/file.c +20 -4
index f4baeb9..ba2a9ce 100644
@@ -568,11 +568,13 @@ nsm_retire_monitored_hosts(void)
 
 	while ((de = readdir(dir)) != NULL) {
 		char *src, *dst;
+		struct stat stb;
 
-		if (de->d_type != (unsigned char)DT_REG)
-			continue;
-		if (de->d_name[0] == '.')
+		if (de->d_name[0] == '.') {
+			xlog(D_GENERAL, "Skipping dot file %s",
+					de->d_name);
 			continue;
+		}
 
 		src = nsm_make_record_pathname(NSM_MONITOR_DIR, de->d_name);
 		if (src == NULL) {
@@ -580,6 +582,20 @@ nsm_retire_monitored_hosts(void)
 			continue;
 		}
 
+		/* NB: not all file systems fill in d_type correctly */
+		if (lstat(src, &stb) == -1) {
+			xlog_warn("Bad monitor file %s, skipping: %m",
+					de->d_name);
+			free(src);
+			continue;
+		}
+		if (!S_ISREG(stb.st_mode)) {
+			xlog(D_GENERAL, "Skipping non-regular file %s",
+					de->d_name);
+			free(src);
+			continue;
+		}
+
 		dst = nsm_make_record_pathname(NSM_NOTIFY_DIR, de->d_name);
 		if (dst == NULL) {
 			free(src);
@@ -846,7 +862,7 @@ nsm_read_line(const char *hostname, const time_t timestamp, char *line,
 }
 
 /*
- * Given a filename, reads data from a file under NSM_MONITOR_DIR
+ * Given a filename, reads data from a file under "directory"
 * and invokes @func so caller can populate their in-core
 * database with this data.
 */
@@ -863,10 +879,15 @@ nsm_load_host(const char *directory, const char *filename, nsm_populate_t func)
 	if (path == NULL)
 		goto out_err;
 
Quoted 9 lines

support/nsm/file.c nsm_load_host(const char *directory, const char *filename, nsm_populate_t func) · line 888

Quoted 8 lines
support/nsm/file.c +4 -1
-	if (stat(path, &stb) == -1) {
+	if (lstat(path, &stb) == -1) {
 		xlog(L_ERROR, "Failed to stat %s: %m", path);
 		goto out_freepath;
 	}
+	if (!S_ISREG(stb.st_mode)) {
+		xlog(D_GENERAL, "Skipping non-regular file %s",
+				path);

Question, why do we care non-regular files are being ignored?

We probably want to report anything unexpected in the /var/lib/nfs/statd/sm{,.bak} directories.

Quoted 3 lines

I understand logging the lstat() error but logging statements like "ignoring this" or "not doing that" just make the debug output a bit too noisy IMHO...

My expectation is that under normal circumstances this message would never fire. statd shouldn't put anything in that directory that isn't a regular file. If there's something else in there, we should report it. Also, if statd (or something else) is broken and the code thinks the object isn't a regular file, then this message would point to what is wrong.

Quoted 2 lines

I'm thinking it would be better to log the files that are actually being used verses files that are being ignored.

I'd have to check, but I think the hostnames that are "used" are actually reported by the caller. If callers don't report the hostnames, then we can add something here easily enough.

Quoted 8 lines
Quoted 8 lines
support/nsm/file.c +2 -0
+		goto out_freepath;
+	}
 
 	f = fopen(path, "r");
 	if (f == NULL) {
@@ -913,10 +934,11 @@ nsm_load_dir(const char *directory, nsm_populate_t func)
 	}
 
Quoted 9 lines

support/nsm/file.c nsm_retire_monitored_hosts(void) · line 575

Quoted 7 lines
support/nsm/file.c +3 -3
 	while ((de = readdir(dir)) != NULL) {
-		if (de->d_type != (unsigned char)DT_REG)
-			continue;
-		if (de->d_name[0] == '.')
+		if (de->d_name[0] == '.') {
+			xlog(D_GENERAL, "Skipping dot file %s",
+					de->d_name);

The same goes with this... Do we really care "." and ".." are being ignored? Isn't that expected? ;-)

It's kind of a heartbeat message, if you will. But this one is optional and can be removed.

Once we agree on what messages should appear here, I'll redrive the patch.

Quoted 9 lines

steved.

Quoted 6 lines
support/nsm/file.c +1 -0
 			continue;
+		}
 
 		count += nsm_load_host(directory, de->d_name, func);
 	}
Signature · 2 lines
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
#4 lore raw

Re: [PATCH 1/3] libnsm.a: sm-notify sometimes ignores monitored hosts

Hey...

Quoted 18 lines · Chuck Lever
Quoted 5 lines
Quoted 5 lines

*/

support/nsm/file.c +0 -0
@@ -863,10 +879,15 @@ nsm_load_host(const char *directory, const char *filename, nsm_populate_t func)
 	if (path == NULL)
 		goto out_err;
 
Quoted 9 lines

support/nsm/file.c nsm_load_host(const char *directory, const char *filename, nsm_populate_t func) · line 888

Quoted 8 lines
support/nsm/file.c +4 -1
-	if (stat(path, &stb) == -1) {
+	if (lstat(path, &stb) == -1) {
 		xlog(L_ERROR, "Failed to stat %s: %m", path);
 		goto out_freepath;
 	}
+	if (!S_ISREG(stb.st_mode)) {
+		xlog(D_GENERAL, "Skipping non-regular file %s",
+				path);

Question, why do we care non-regular files are being ignored?

We probably want to report anything unexpected in
the /var/lib/nfs/statd/sm{,.bak} directories.

Quoted 6 lines
Quoted 3 lines

I understand logging the lstat() error but logging statements like "ignoring this" or "not doing that" just make the debug output a bit too noisy IMHO...

My expectation is that under normal circumstances this message would never fire.

Correct the only way they will be shown is with the "-F -d" flags...

Quoted 5 lines

statd shouldn't put anything in that directory
that isn't a regular file. If there's something else in there, we should report it. Also, if statd (or something else) is broken and the code thinks the object isn't a regular file, then this message would point to what is wrong.

To put this in context, here are the message that come up with the patch applied... I added a symlink to /var/lib/nfs/statd/sm/statd to generate both messages...

statd: Version 1.2.3 starting
statd: Flags: No-Daemon Log-STDERR TI-RPC
sm-notify: Version 1.2.3 starting
sm-notify: Already notifying clients; Exiting!
statd: Skipping dot file ..
statd: Skipping non-regular file /var/lib/nfs/statd/sm/statd
statd: Skipping dot file .

I think we both agree the "Skipping dot file" simply not needed... The "Skipping non-regular" message... well I have to say it really does not have much meaning... either.. IMHO...

But I do agree, it probably will *never* seen...

steved.

#5 lore raw

Re: [PATCH 1/3] libnsm.a: sm-notify sometimes ignores monitored hosts

Quoted 39 lines · Steve Dickson

Hey...

Quoted 18 lines · Chuck Lever
Quoted 5 lines
Quoted 5 lines

*/

support/nsm/file.c +0 -0
@@ -863,10 +879,15 @@ nsm_load_host(const char *directory, const char *filename, nsm_populate_t func)
 	if (path == NULL)
 		goto out_err;
 
Quoted 9 lines

support/nsm/file.c nsm_load_host(const char *directory, const char *filename, nsm_populate_t func) · line 888

Quoted 8 lines
support/nsm/file.c +4 -1
-	if (stat(path, &stb) == -1) {
+	if (lstat(path, &stb) == -1) {
 		xlog(L_ERROR, "Failed to stat %s: %m", path);
 		goto out_freepath;
 	}
+	if (!S_ISREG(stb.st_mode)) {
+		xlog(D_GENERAL, "Skipping non-regular file %s",
+				path);

Question, why do we care non-regular files are being ignored?

We probably want to report anything unexpected in
the /var/lib/nfs/statd/sm{,.bak} directories.

Quoted 6 lines
Quoted 3 lines

I understand logging the lstat() error but logging statements like "ignoring this" or "not doing that" just make the debug output a bit too noisy IMHO...

My expectation is that under normal circumstances this message would never fire.

Correct the only way they will be shown is with the "-F -d" flags...

Quoted 5 lines

statd shouldn't put anything in that directory
that isn't a regular file. If there's something else in there, we should report it. Also, if statd (or something else) is broken and the code thinks the object isn't a regular file, then this message would point to what is wrong.

To put this in context, here are the message that come up with the patch applied... I added a symlink to /var/lib/nfs/statd/sm/statd to generate both messages...

Quoted 7 lines

statd: Version 1.2.3 starting
statd: Flags: No-Daemon Log-STDERR TI-RPC
sm-notify: Version 1.2.3 starting
sm-notify: Already notifying clients; Exiting!
statd: Skipping dot file ..
statd: Skipping non-regular file /var/lib/nfs/statd/sm/statd
statd: Skipping dot file .

This does fix true bug, so I am going to commit the patch but without the "Skipping dot file" statements and leaving the "Skipping non-regular" ones since they will never be seen...

steved.

A message that is not in the archive (sent off-list or not yet received): 20101206160944.18361.28275.stgit-RytpoXr2tKZ9HhUboXbp9zCvJB+x5qRC@public.gmane.org

#7 lore raw

Re: [PATCH 1/3] libnsm.a: sm-notify sometimes ignores monitored hosts

Quoted 23 lines · Chuck Lever

Monitored host information is stored in files under /var/lib/nfs. When visiting entries in the monitored hosts directory, libnsm.a examines the value of dirent.d_type to determine if an entry is a regular file.

According to readdir(3), the d_type field is not supported by all file system types. My root file system happens to be one where d_type isn't supported. Typical installations that use an ext-derived root file system are not exposed to this issue, but those who use xfs, for instance, are.

On such file systems, not only are remote peers not notified of reboots, but the NSM state number is never incremented. A statd warm restart would not re-monitor any hosts that were monitored before the restart.

When writing support/nsm/file.c, I copied the use of d_type from the original statd code, so this has likely been an issue for some time.

Replace the use of d_type in support/nsm/file.c with a call to lstat(2). It's extra code, but is guaranteed to work on all file system types.

Quoted 8 lines

Note there is a usage of d_type in gssd. I'll let gssd and rpcpipefs experts decide whether that's worth changing.

Fix for:

https://bugzilla.linux-nfs.org/show_bug.cgi?id=193

Committed... But without the "Skipping dot file..." xlogs.

steved

#8 lore raw

PATCH 2/3 libnsm.a: Replace __attribute_noinline__

In reply to Chuck Lever

"Gabor Z. Papp" <[email protected]> reports:

trying to compile nfs-utils 1.2.3 on linux kernel 2.4.37.10, glibc 2.2.5:

cc -DHAVE_CONFIG_H -I. -I../../support/include -D_GNU_SOURCE -Wall
-Wextra -Wstrict-prototypes -pipe -g -O2 -MT file.o -MD -MP -MF .deps/file.Tpo -c -o file.o file.c
file.c:638: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'static' file.c: In function 'nsm_insert_monitored_host':
file.c:747: warning: implicit declaration of function 'nsm_create_monitor_record' file.c: At top level:
file.c:788: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'static' file.c: In function 'nsm_read_line':
file.c:842: warning: implicit declaration of function 'nsm_parse_line' make[3]: *** [file.o] Error 1
make[3]: Leaving directory `/home/gzp/src/nfs-utils-1.2.3/support/nsm' make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/gzp/src/nfs-utils-1.2.3/support/nsm' make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/gzp/src/nfs-utils-1.2.3/support'
make: *** [all-recursive] Error 1

[kernel]
Linux gzpLinux 2.4.37.10-gzpLinux #1 Mon Oct 4 08:57:02 CEST 2010 i686 GNU/Linux

[glibc]
GNU C Library stable release version 2.2.5, by Roland McGrath et al. Compiled by GNU CC version 3.3.6.
Compiled on a Linux 2.4.36.2-gzpLinux system on 2008-03-22.

[gcc]
gcc (GCC) 4.4.5

[binutils]
GNU ld (Linux/GNU Binutils) 2.21.51.0.1.20101110

=== cut here ===

sys/cdefs.c in glibc 2.2.5 does not define __attribute_noinline__.

Replace the __attribute_noinline__ form with

__attribute__((__noinline__)).

Even though the compiler didn't complain about __attribute_malloc__, also replace those in order to maintain consistent style throughout the source file.

Fix for:

https://bugzilla.linux-nfs.org/show_bug.cgi?id=194

---

 support/nsm/file.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
support/nsm/file.c +5 -5
index ba2a9ce..6ea6ab6 100644
@@ -126,7 +126,7 @@ exact_error_check(const ssize_t len, const size_t buflen)
  * containing an appropriate pathname, or NULL if an error
  * occurs.  Caller must free the returned result with free(3).
  */
-__attribute_malloc__
+__attribute__((__malloc__))
 static char *
 nsm_make_record_pathname(const char *directory, const char *hostname)
 {
@@ -174,7 +174,7 @@ nsm_make_record_pathname(const char *directory, const char *hostname)
  * containing an appropriate pathname, or NULL if an error
  * occurs.  Caller must free the returned result with free(3).
  */
-__attribute_malloc__
+__attribute__((__malloc__))
 static char *
 nsm_make_pathname(const char *directory)
 {
@@ -204,7 +204,7 @@ nsm_make_pathname(const char *directory)
  * containing an appropriate pathname, or NULL if an error
  * occurs.  Caller must free the returned result with free(3).
  */
-__attribute_malloc__
+__attribute__((__malloc__))
 static char *
 nsm_make_temp_pathname(const char *pathname)
 {
@@ -650,7 +650,7 @@ nsm_priv_to_hex(const char *priv, char *buf, const size_t buflen)
 /*
  * Returns the length in bytes of the created record.
  */
-__attribute_noinline__
+__attribute__((__noinline__))
 static size_t
 nsm_create_monitor_record(char *buf, const size_t buflen,
 		const struct sockaddr *sap, const struct mon *m)
@@ -800,7 +800,7 @@ out:
 	return result;
 }
 
-__attribute_noinline__
+__attribute__((__noinline__))
 static _Bool
 nsm_parse_line(char *line, struct sockaddr_in *sin, struct mon *m)
 {

A message that is not in the archive (sent off-list or not yet received): 20101206160953.18361.21885.stgit-RytpoXr2tKZ9HhUboXbp9zCvJB+x5qRC@public.gmane.org

#10 lore raw

Re: [PATCH 2/3] libnsm.a: Replace __attribute_noinline__

Quoted 48 lines · Chuck Lever

"Gabor Z. Papp" <gzp-2g/[email protected]> reports:

trying to compile nfs-utils 1.2.3 on linux kernel 2.4.37.10, glibc 2.2.5:

cc -DHAVE_CONFIG_H -I. -I../../support/include -D_GNU_SOURCE -Wall
-Wextra -Wstrict-prototypes -pipe -g -O2 -MT file.o -MD -MP -MF .deps/file.Tpo -c -o file.o file.c
file.c:638: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'static' file.c: In function 'nsm_insert_monitored_host':
file.c:747: warning: implicit declaration of function 'nsm_create_monitor_record' file.c: At top level:
file.c:788: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'static' file.c: In function 'nsm_read_line':
file.c:842: warning: implicit declaration of function 'nsm_parse_line' make[3]: *** [file.o] Error 1
make[3]: Leaving directory `/home/gzp/src/nfs-utils-1.2.3/support/nsm' make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/gzp/src/nfs-utils-1.2.3/support/nsm' make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/gzp/src/nfs-utils-1.2.3/support'
make: *** [all-recursive] Error 1

[kernel]
Linux gzpLinux 2.4.37.10-gzpLinux #1 Mon Oct 4 08:57:02 CEST 2010 i686 GNU/Linux

[glibc]
GNU C Library stable release version 2.2.5, by Roland McGrath et al. Compiled by GNU CC version 3.3.6.
Compiled on a Linux 2.4.36.2-gzpLinux system on 2008-03-22.

[gcc]
gcc (GCC) 4.4.5

[binutils]
GNU ld (Linux/GNU Binutils) 2.21.51.0.1.20101110

=== cut here ===

sys/cdefs.c in glibc 2.2.5 does not define __attribute_noinline__.

Replace the __attribute_noinline__ form with

__attribute__((__noinline__)).

Even though the compiler didn't complain about __attribute_malloc__, also replace those in order to maintain consistent style throughout the source file.

Quoted 6 lines

Fix for:

https://bugzilla.linux-nfs.org/show_bug.cgi?id=194

Committed..

steved.

#11 lore raw

PATCH 3/3 sm-notify: Make use of AI_NUMERICSERV conditional

In reply to Chuck Lever

Gabor Papp reports nfs-utils-1.2.3 doesn't build on his system that uses glibc-2.2.5:

make[3]: Entering directory `/home/gzp/src/nfs-utils-1.2.3/utils/statd'
gcc -DHAVE_CONFIG_H -I. -I../../support/include -D_GNU_SOURCE -Wall
-Wextra -Wstrict-prototypes -pipe -g -O2 -MT sm-notify.o -MD -MP -MF .deps/sm-notify.Tpo -c -o sm-notify.o sm-notify.c sm-notify.c: In function 'smn_bind_address':
sm-notify.c:247: error: 'AI_NUMERICSERV' undeclared (first use in this function) sm-notify.c:247: error: (Each undeclared identifier is reported only once sm-notify.c:247: error: for each function it appears in.)
make[3]: *** [sm-notify.o] Error 1

According to the getaddrinfo(3) man page, AI_NUMERICSERV is available only since glibc 2.3.4. getaddrinfo(3) seems to convert strings containing a number to the right port value without the use of AI_NUMERICSERV, so I think we can survive on older glibc's without it. It will allow admins to specify service names as well as port numbers on those versions.

There are uses of AI_NUMERICSERV in gssd and in nfs_svc_create(). The one in nfs_svc_create() is behind HAVE_LIBTIRPC, and the other is a issue only for those who want to deploy Kerberos -- likely in both cases, a more modern glibc will be present. I'm going to leave those two.

Fix for:

https://bugzilla.linux-nfs.org/show_bug.cgi?id=195

---

 utils/statd/sm-notify.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
utils/statd/sm-notify.c +6 -0
index b7f4371..1f490b0 100644
@@ -34,6 +34,11 @@
 #include "nsm.h"
 #include "nfsrpc.h"
 
+/* glibc before 2.3.4 */
+#ifndef AI_NUMERICSERV
+#define AI_NUMERICSERV	0
+#endif
+
 #define NSM_TIMEOUT	2
 #define NSM_MAX_TIMEOUT	120	/* don't make this too big */
 
@@ -248,6 +253,7 @@ smn_bind_address(const char *srcaddr, const char *srcport)
 	if (srcaddr == NULL)
 		hint.ai_flags |= AI_PASSIVE;
 
+	/* Do not allow "node" and "service" parameters both to be NULL */
 	if (srcport == NULL)
 		error = getaddrinfo(srcaddr, "", &hint, &ai);
 	else

A message that is not in the archive (sent off-list or not yet received): 20101206161002.18361.24632.stgit-RytpoXr2tKZ9HhUboXbp9zCvJB+x5qRC@public.gmane.org

#13 lore raw

Re: [PATCH 3/3] sm-notify: Make use of AI_NUMERICSERV conditional

Quoted 27 lines · Chuck Lever

Gabor Papp reports nfs-utils-1.2.3 doesn't build on his system that uses glibc-2.2.5:

make[3]: Entering directory `/home/gzp/src/nfs-utils-1.2.3/utils/statd'
gcc -DHAVE_CONFIG_H -I. -I../../support/include -D_GNU_SOURCE -Wall
-Wextra -Wstrict-prototypes -pipe -g -O2 -MT sm-notify.o -MD -MP -MF .deps/sm-notify.Tpo -c -o sm-notify.o sm-notify.c sm-notify.c: In function 'smn_bind_address':
sm-notify.c:247: error: 'AI_NUMERICSERV' undeclared (first use in this function) sm-notify.c:247: error: (Each undeclared identifier is reported only once sm-notify.c:247: error: for each function it appears in.)
make[3]: *** [sm-notify.o] Error 1

According to the getaddrinfo(3) man page, AI_NUMERICSERV is available only since glibc 2.3.4. getaddrinfo(3) seems to convert strings containing a number to the right port value without the use of AI_NUMERICSERV, so I think we can survive on older glibc's without it. It will allow admins to specify service names as well as port numbers on those versions.

There are uses of AI_NUMERICSERV in gssd and in nfs_svc_create(). The one in nfs_svc_create() is behind HAVE_LIBTIRPC, and the other is a issue only for those who want to deploy Kerberos -- likely in both cases, a more modern glibc will be present. I'm going to leave those two.

Quoted 6 lines

Fix for:

https://bugzilla.linux-nfs.org/show_bug.cgi?id=195

Committed...

steved.