Discussion:
Why is SIOCINITIFADDR in sys/sockio.h ??
(too old to reply)
Robert Elz
2010-09-29 07:13:20 UTC
Permalink
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?

kre


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
David Young
2010-09-29 15:39:25 UTC
Permalink
Post by Robert Elz
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
***@ojctech.com Urbana, IL * (217) 278-3933

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Robert Elz
2010-09-29 23:23:47 UTC
Permalink
Date: Wed, 29 Sep 2010 10:39:25 -0500
From: David Young <***@pobox.com>
Message-ID: <***@ojctech.com>


| How about this,

I'd omit the second para of the comment - that's too much and not needed
(the history is interesting, but the CVS log is good enough for that).

Aside from that, much better than it is now.

And someone else can suggest if perhaps the definition would be better
somewhere it isn't even visible to applications dumb enough to define
_KERNEL when they compile...

kre


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Loading...