>> Ucred routines will shrink the actual size of the ucred exchanges: the
>> ucred structures will "shrink to fit" and only processes which use a lot
>> of groups will pay for this in ucred exchanges.
>
>How does this work?  The size of a ucred is not passed around, but
>required to be ucred_size(3C).  I guess receiving code will malloc()
>ucred_size() bytes, receive the ucred, and realloc() to the correct,
>smaller size, which would be encoded in a ucred header.  Or perhaps
>you'll be enhancing the ucredsys/doorsys syscalls so that you only alloc
>as much as needed?  Yes, implementation details, I know.  But
>interesting details nonetheless.


Ucred is currently formatted like this:

<header><pcred_t><NGROUPS_MAX * gid_t><privs>[<audit>][<txlabel>]

The new generated format is:

<header><pcred_t><cr->cr_ngroups * gid_t><privs>[<audit>][<txlabel>]

Well, you can't know how big the item you are going to receive and you 
want to be able to re-use the buffer.  (With 1024 groups, you'll need to
allocate at least 
4K)So in userland you allocate ucred_size().

In the kernel we generate the ucred and we know how big the item is going to be;
we allocate as much as we need and we copyout just that data.

Casper

Reply via email to