2009-12-29 19:20:07

by Robert P. J. Day

[permalink] [raw]
Subject: what's the purpose of MAXHOSTNAMELEN?


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
========================================================================


2009-12-29 19:35:43

by Samuel Thibault

[permalink] [raw]
Subject: Re: what's the purpose of MAXHOSTNAMELEN?

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

2009-12-29 19:40:12

by Jeff Garzik

[permalink] [raw]
Subject: Re: what's the purpose of MAXHOSTNAMELEN?

On 12/29/2009 02:19 PM, Robert P. J. Day wrote:
>
> 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?

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


2009-12-29 19:56:12

by Samuel Thibault

[permalink] [raw]
Subject: Re: what's the purpose of MAXHOSTNAMELEN?

Jeff Garzik, le Tue 29 Dec 2009 14:40:05 -0500, a ?crit :
> On 12/29/2009 02:19 PM, Robert P. J. Day wrote:
> >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 :)

> 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

2009-12-29 20:13:50

by Robert P. J. Day

[permalink] [raw]
Subject: Re: what's the purpose of MAXHOSTNAMELEN?

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

> > 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
========================================================================

2009-12-29 20:21:01

by Jeff Garzik

[permalink] [raw]
Subject: Re: what's the purpose of MAXHOSTNAMELEN?

On 12/29/2009 02:56 PM, Samuel Thibault wrote:
> Jeff Garzik, le Tue 29 Dec 2009 14:40:05 -0500, a ?crit :
>> On 12/29/2009 02:19 PM, Robert P. J. Day wrote:
>>> 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 :)

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];



>> 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



2009-12-29 20:26:12

by Samuel Thibault

[permalink] [raw]
Subject: Re: what's the purpose of MAXHOSTNAMELEN?

Jeff Garzik, le Tue 29 Dec 2009 15:20:56 -0500, a ?crit :
> >>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

2009-12-29 21:00:40

by Vikram Dhillon

[permalink] [raw]
Subject: Re: what's the purpose of MAXHOSTNAMELEN?

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



On Tue, Dec 29, 2009 at 3:20 PM, Jeff Garzik <[email protected]> wrote:
> On 12/29/2009 02:56 PM, Samuel Thibault wrote:
>>
>> Jeff Garzik, le Tue 29 Dec 2009 14:40:05 -0500, a écrit :
>>>
>>> On 12/29/2009 02:19 PM, Robert P. J. Day wrote:
>>>>
>>>> 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 :)
>
> 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];
>
>
>
>>> 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/
>