Subject: Re: pidentd
To: None <tech-net@netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-net
Date: 04/07/2000 01:57:35
>> AF_KERN sockets.
>> As in, to invent an API,
> er, you mean reinvent?

No, actually, I meant invent.

> Purpose of an AF_KERN socket: pass data into the kernel, have it do
> 		something, then return the result.
> Purpose of a system call: pass data into the kernel, have it do
> 		something, then return the result.

Purpose of just about anything: pass data around.

If your description gets sufficiently general, lots of things fit it.

> Of course, using socket/read/write results in 3 system calls instead
> of 1.  and it's a bit unwieldy.

True.  Still far cheaper in that respect than libkvm.  (Or is /dev/kmem
mmappable?  That would cure the "reading garbage addresses" problem
rather neatly.)

> What's the benefit, other than perhaps being able to use the protocol
> arg in socket() to specify a section of the kernel that the request
> is going to?

That's most of it.

I was trying to use up as little of the relevant namespace as feasible.
It seemed to me that adding a syscall just for pidentd was being
wasteful.  Adding a whole address family for the purpose would be too.
But adding an address family for kernel interfaces, distinguishing one
from another with the protocol, doesn't seem excessively wasteful to
me.  Of course it's a judgement call in any case.

It does have its problems, certainly.  sysctl would be better except
there's no obvious way that I can see to pass the port numbers in so as
to get the uid back out.

Perhaps an identdfs mount?  /identd/12345,25 could be a symlink
pointing to the relevant UID in decimal - then one readlink() call
would give you a lookup, without needing to consume any namespace
anywhere.  (Except for filesystem types, which bothers me not at all,
though I have trouble stating why.)  It needn't do anything sensible
with getdents(), though if you wanted to get fancy it could - soup it
up and it could serve for much of netstat, too.  (Speaking of
getdents(), why are there no SEE ALSO pointers between getdents(2) and
readdir(3)?)

					der Mouse

			       mouse@rodents.montreal.qc.ca
		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B