Skip to contentSkip to conversation

what's the purpose of MAXHOSTNAMELEN?

DISCUSSION Robert P. J. Day 4 participants 8 messages Dec 29, 2009

lore
Share & tools
lore
#0 lore raw

in prepping for coalescing a lot of param.h files, i'm curious about
the purpose of this macro:

$ grep -rw MAXHOSTNAMELEN *
arch/s390/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/sparc/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/alpha/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/mn10300/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/arm/include/asm/param.h:#define MAXHOSTNAMELEN  64
arch/m32r/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/mips/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/m68k/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/xtensa/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/ia64/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/h8300/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/avr32/include/asm/param.h:#define MAXHOSTNAMELEN	64
arch/cris/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/um/include/asm/param.h:#define MAXHOSTNAMELEN  64      /* max length of hostname */
arch/powerpc/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/parisc/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/frv/include/asm/param.h:#define MAXHOSTNAMELEN		64	/* max length of hostname */
include/asm-generic/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
include/net/sctp/structs.h:#include <asm/param.h>		/* We get MAXHOSTNAMELEN.     */
$

so lots of people define it but no one uses it. it *is* exported to
user space in /usr/include/asm/param.h, but i still have no idea what it's for in user space. obsolete?

rday
--

========================================================================
Robert P. J. Day Waterloo, Ontario, CANADA

Linux Consulting, Training and Kernel Pedantry.

Web page:                                          http://crashcourse.ca
Twitter:                                       http://twitter.com/rpjday

========================================================================

#1 lore raw
Quoted 3 lines · Robert P. J. Day, le Tue 29 Dec 2009 14:19:30 -0500, a écrit :

so lots of people define it but no one uses it. it *is* exported to
user space in /usr/include/asm/param.h, but i still have no idea what it's for in user space. obsolete?

It's like all these *MAX* #defines: they are a bad way to express the system limitations. They are bad because they end up compiled-in, but also because people understand them as "a typical allocation length" and get lazy. The typical example is PATH_MAX, which is #defined to 4096. A _lot_ of applications thus keep allocating 4KB for all paths.

See
http://www.gnu.org/software/hurd/hurd/porting/guidelines.html#PATH_MAX_tt_MAX_PATH_tt_MAXPATHL

If you could drop it (would be completely POSIX-compliant), that'd be a great service to GNU/Hurd porters, but I bet you'll also get a lot of angry people.

Samuel

#2 lore raw
In reply to Robert P. J. Day
Quoted 26 lines · Robert P. J. Day

in prepping for coalescing a lot of param.h files, i'm curious about
the purpose of this macro:

$ grep -rw MAXHOSTNAMELEN *
arch/s390/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/sparc/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/alpha/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/mn10300/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/arm/include/asm/param.h:#define MAXHOSTNAMELEN  64
arch/m32r/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/mips/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/m68k/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/xtensa/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/ia64/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/h8300/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/avr32/include/asm/param.h:#define MAXHOSTNAMELEN	64
arch/cris/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/um/include/asm/param.h:#define MAXHOSTNAMELEN  64      /* max length of hostname */
arch/powerpc/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/parisc/include/asm/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
arch/frv/include/asm/param.h:#define MAXHOSTNAMELEN		64	/* max length of hostname */
include/asm-generic/param.h:#define MAXHOSTNAMELEN	64	/* max length of hostname */
include/net/sctp/structs.h:#include<asm/param.h>		/* We get MAXHOSTNAMELEN.     */
$
Quoted 3 lines

so lots of people define it but no one uses it. it *is* exported to
user space in /usr/include/asm/param.h, but i still have no idea what it's for in user space. obsolete?

According to RFC 1034, "Each node has a label, which is zero to 63 octets in length"

What is it used for in userspace, and why is it export from the kernel?
Good question...

Jeff

#3 lore raw
Quoted 10 lines · Jeff Garzik, le Tue 29 Dec 2009 14:40:05 -0500, a écrit :
Quoted 6 lines · Robert P. J. Day

arch/s390/include/asm/param.h:#define MAXHOSTNAMELEN 64 /* max
length of hostname */

so lots of people define it but no one uses it. it *is* exported to
user space in /usr/include/asm/param.h, but i still have no idea what it's for in user space. obsolete?

According to RFC 1034, "Each node has a label, which is zero to 63 octets in length"

That's for Internet networks. Other kinds of networks could implement more. It could make sense to restrict ourself to Internet standards, but we don't :)

Quoted 1 line

What is it used for in userspace, and why is it export from the kernel?

Gethostname, typically, but also all kinds of functions that provide a hostname. It's also quite often completely badly used, for instance for getnameinfo()...

You have Debian's list on
http://unstable.buildd.net/buildd/hurd-i386_Failed.html

Samuel

#7 lore raw
In reply to Jeff Garzik

On Tue, 29 Dec 2009, Jeff Garzik wrote:
... snip ..

Quoted 9 lines
Quoted 3 lines

so lots of people define it but no one uses it. it *is*
exported to user space in /usr/include/asm/param.h, but i still have no idea what it's for in user space. obsolete?

According to RFC 1034, "Each node has a label, which is zero to 63 octets in length"

What is it used for in userspace, and why is it export from the kernel? Good question...

it's not clear what value that macro has in user space since (as
i've always understood it) the point of exporting a macro like that to user space is so that user space apps can *agree* with kernel code that employs the same macro.

but if absolutely *nothing* in the kernel uses that macro, then
there's nothing for user space to "agree" with. in other words, that macro cannot *possibly* have any meaningful value in user space. does that make sense?

my reaction at this point is to simply remove that macro definition
from include/asm-generic/param.h. anything in user space that's using that macro is simply using a macro with a completely arbitrary value.

rday
--

========================================================================
Robert P. J. Day Waterloo, Ontario, CANADA

Linux Consulting, Training and Kernel Pedantry.

Web page:                                          http://crashcourse.ca
Twitter:                                       http://twitter.com/rpjday

========================================================================

#4 lore raw
In reply to Samuel Thibault
Quoted 9 lines · Samuel Thibault
Quoted 8 lines · Jeff Garzik, le Tue 29 Dec 2009 14:40:05 -0500, a écrit :
Quoted 6 lines · Robert P. J. Day

arch/s390/include/asm/param.h:#define MAXHOSTNAMELEN 64 /* max
length of hostname */

so lots of people define it but no one uses it. it *is* exported to
user space in /usr/include/asm/param.h, but i still have no idea what it's for in user space. obsolete?

Quoted 6 lines
Quoted 2 lines

According to RFC 1034, "Each node has a label, which is zero to 63 octets in length"

That's for Internet networks. Other kinds of networks could implement more. It could make sense to restrict ourself to Internet standards, but we don't :)

Er huh? That was a description of the origin of the limit.

And as a point of fact, we do restrict ourself to that:

	#define __NEW_UTS_LEN 64

	struct new_utsname {
	        char sysname[__NEW_UTS_LEN + 1];
	        char nodename[__NEW_UTS_LEN + 1];
Quoted 8 lines
Quoted 1 line

What is it used for in userspace, and why is it export from the kernel?

Gethostname, typically, but also all kinds of functions that provide a hostname. It's also quite often completely badly used, for instance for getnameinfo()...

You have Debian's list on
http://unstable.buildd.net/buildd/hurd-i386_Failed.html

No one cares about Hurd.

Jeff

#5 lore raw
Quoted 10 lines · Jeff Garzik, le Tue 29 Dec 2009 15:20:56 -0500, a écrit :
Quoted 8 lines
Quoted 1 line

What is it used for in userspace, and why is it export from the kernel?

Gethostname, typically, but also all kinds of functions that provide a hostname. It's also quite often completely badly used, for instance for getnameinfo()...

You have Debian's list on
http://unstable.buildd.net/buildd/hurd-i386_Failed.html

No one cares about Hurd.

That wasn't at all the point of my inclusion of the URL, see above. If you drop it, you'll get all kinds of build failures. I just happened to use the Debian Hurd build failures as a quick way to get a list.

Samuel

#6 lore raw
In reply to Jeff Garzik

I care about Hurd :D, but yah as it is mentioned before, would it sometime in future be possible to remove this from the kernel ?

Regards,
Vikram Dhillon

~~~
There are lots of Linux users who don't care how the kernel works, but only want to use it. That is a tribute to how good Linux is. -- Linus Torvalds

Quoted 54 lines · Jeff Garzik
Quoted 12 lines · Samuel Thibault
Quoted 10 lines · Jeff Garzik, le Tue 29 Dec 2009 14:40:05 -0500, a écrit :
Quoted 7 lines · Robert P. J. Day

arch/s390/include/asm/param.h:#define MAXHOSTNAMELEN    64      /* max length of hostname */

  so lots of people define it but no one uses it.  it *is* exported to user space in /usr/include/asm/param.h, but i still have no idea what it's for in user space.  obsolete?

Quoted 6 lines
Quoted 2 lines

According to RFC 1034, "Each node has a label, which is zero to 63 octets in length"

That's for Internet networks.  Other kinds of networks could implement more.  It could make sense to restrict ourself to Internet standards, but we don't :)

Er huh?  That was a description of the origin of the limit.

And as a point of fact, we do restrict ourself to that:

       #define __NEW_UTS_LEN 64

       struct new_utsname {
               char sysname[__NEW_UTS_LEN + 1];
               char nodename[__NEW_UTS_LEN + 1];

Quoted 8 lines
Quoted 1 line

What is it used for in userspace, and why is it export from the kernel?

Gethostname, typically, but also all kinds of functions that provide a hostname.  It's also quite often completely badly used, for instance for getnameinfo()...

You have Debian's list on
http://unstable.buildd.net/buildd/hurd-i386_Failed.html

No one cares about Hurd.

       Jeff

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