tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CMSG_SPACE: too clever by half?



On Thu, Feb 24, 2011 at 07:13:20PM +0300, Alexander Nasonov wrote:
> 24.02.2011, 19:06, "Julio Merino" <jmmv%NetBSD.org@localhost>:
> > - Import tmux into src/external/bsd/tmux.
> 
> Please take a note on this NetBSD issue:
> http://comments.gmane.org/gmane.comp.terminal-emulators.tmux.user/38

The issue involves the way we arranged for binary compatibility across
changes in the unix-domain file descriptor and credentials passing code.

A macro, CMSG_SPACE(), is used to walk around the out-of-band data area
used for these purposes.  On most operating systems it enforces a constant
alignment at compile time, so it can be used to size local arrays.

However, the standard does not require the alignment to be constant, and
we take advantage of that "feature" to allow us to change the alignment
in new kernels without requiring compat code in the kernel to handle old
applications.

I think this is too clever.  It makes it impossible to declare local arrays
to hold these things, and that results in dynamic allocation in places it
really probably isn't wanted, or by guesswork or hand computation in an
attempt to be sure that "enough" space is allocated to hold, let's say,
5 attached file descriptors (see the OpenSSH sources for an example of
this).

I would appreciate others' opinions on this.  I am pretty sure what we
are doing now conforms to the standard but I still do not think it is
a great thing to do.

Thor


Home | Main Index | Thread Index | Old Index