tech-net archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Why is SIOCINITIFADDR in sys/sockio.h ??
On Wed, Sep 29, 2010 at 02:13:20PM +0700, Robert Elz wrote:
> I think I understand the purpose of this ioctl. and if I
> do understand it correctly, SIOCINITIFADDR is an in-kernel only
> ioctl (that's reinforced by seeing it all over the -current
> interface drivers, and nowhere outside the kernel), plus the EPERM.
>
> Given that, wouldn't a comment in sockio.h indicating that the
> number is taken, with the actual #define of the ioctl command
> value in some kernel only header file be a more sensible choice?
>
> I noticed this as I wanted to add some data to struct ifaddr, and
> was checking to make sure (which I presumed, but wanted to verify)
> that this struct is a 100% in kernel data structure, not visible
> externally (so no API/ABI would be broken by changing the struct,
> just kernel modules that I don't care about...)
>
> Then I saw SIOCINITIFADDR in sys/sockio.h and paniced!
>
> Then I saw its usage, and calmed a little, but that definition seems
> wrong to me - even if it is the correct file, couldn't it be #ifdef KERNEL,
> or at the very least, have some kind of comment?
I don't know if it's the correct file or not. You're right that the
definition should be bracketed by #ifdef _KERNEL and commented. How
about this,
/* For in-kernel use only, SIOCINITIFADDR tells an interface to prepare
* itself for transmitting/receiving packets using the address in the
* given struct ifaddr. An interface may prepare by, for example,
* reprogramming MAC address filters or initializing protocol-specific
* state (ARP-table entry).
*
* Until NetBSD 6.0, the kernel reused SIOCSIFADDR for this purpose, so
* SIOCSIFADDR was used with a struct ifreq argument at the kernel/user
* boundary, and a struct ifaddr argument in calls to an interface's
* ioctl routine.
*/
#ifdef _KERNEL
#define SIOCINITIFADDR _IOWR('i', 132, struct ifaddr)
#endif
Dave
--
David Young OJC Technologies
dyoung%ojctech.com@localhost Urbana, IL * (217) 278-3933
Home |
Main Index |
Thread Index |
Old Index