Subject: Re: CMSG_ALIGN
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: None <itojun@iijlab.net>
List: tech-net
Date: 06/28/2003 13:20:22
>>> So that, for example, a cmsg_len that's natively 20 would be
>>> increased to 24 by the kernel (probably in recvit()'s loop), so that
>>> cmsg_len is _always_ the right amount for userland to advance its
>>> pointer by?
>> cmsg is bidirectional.  when userland passes cmsg to kernel, we can
>> not do such trick (userland does not know what kind of alignment
>> kernel wants),

	add: and the kernel does not know what kind of alignment userland have
	used!

>Yes...but there's no reason it has to.  If userland doesn't align it to
>whatever alignment the kernel wants, the kernel should copy it.  (It
>has to be prepared to copy it anyway, if only because the buffer itself
>might not be aligned.  Arguably it would be wrong to use it directly
>out of userland memory anyway, meaning it would always get copied - I
>note that the code currently copies it always.)

	so the kernel cannot copy like you suggested here.

	by using __cmsg_alignbytes() userland and kernel can share the align
	constraint easily and the problem goes away.

itojun