Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Jan 2006 21:30:24 -0800
From:      Brooks Davis <brooks@one-eyed-alien.net>
To:        freebsd-net@freebsd.org
Subject:   sized data in struct ifreq
Message-ID:  <20060113053023.GA21887@odin.ac.hmc.edu>

next in thread | raw e-mail | index | archive | help

--2fHTh5uZTiUOsy+g
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

I'd like to introduce a new entry in the union in struct ifreq
containing a pointer and a size.  It would be used in place of ifr_data
in new ioctls.  The problem with the ifr_data (pseudo) member is that it
encourages interfaces that encode the size of the data being passed
implicitly in the kernel ABI.  There are ways around this such as making
the size the first element of the struct and doing a two copyin()s to
get the actual size, but that is no substitute for simply requiring the
specification of a size in the first place.  I have verified that the
following change does not change the size of the struct on i386, amd64,
ia64, and alpha (panther is down so I can't check sparc64).

Are there any objections to this change?  I plan to use it to add the
requested feature of interface descriptions.  Here is a diff of possible
changes to if.h.

-- Brooks

Index: if.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/sys/net/if.h,v
retrieving revision 1.99
diff -u -p -r1.99 if.h
--- if.h	1 Oct 2005 18:56:18 -0000	1.99
+++ if.h	13 Jan 2006 05:20:32 -0000
@@ -273,6 +273,10 @@ struct	ifreq {
 		int	ifru_media;
 		caddr_t	ifru_data;
 		int	ifru_cap[2];
+		struct {
+			void    *data;
+			size_t len;
+	      } ifrs_sdata;
 	} ifr_ifru;
 #define	ifr_addr	ifr_ifru.ifru_addr	/* address */
 #define	ifr_dstaddr	ifr_ifru.ifru_dstaddr	/* other end of p-to-p link */
@@ -283,7 +287,9 @@ struct	ifreq {
 #define	ifr_mtu		ifr_ifru.ifru_mtu	/* mtu */
 #define ifr_phys	ifr_ifru.ifru_phys	/* physical wire */
 #define ifr_media	ifr_ifru.ifru_media	/* physical media */
-#define	ifr_data	ifr_ifru.ifru_data	/* for use by interface */
+#define	ifr_data	ifr_ifru.ifru_data	/* deprecated in new code */
+#define ifr_sdata	ifr_ifru.ifru_sdata.data /* for use by interface */
+#define ifr_sdata_len	ifr_ifru.ifru_sdata.len	/* length of interface data =
*/
 #define	ifr_reqcap	ifr_ifru.ifru_cap[0]	/* requested capabilities */
 #define	ifr_curcap	ifr_ifru.ifru_cap[1]	/* current capabilities */
 #define	ifr_index	ifr_ifru.ifru_index	/* interface index */

--=20
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4

--2fHTh5uZTiUOsy+g
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFDxzruXY6L6fI4GtQRAg/fAKC51szrwSa9CTPW6TzskA84+0+ouQCgq4oA
WDh/sxbLeHFUzvLLzlLksyo=
=lMN5
-----END PGP SIGNATURE-----

--2fHTh5uZTiUOsy+g--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060113053023.GA21887>