sized data in struct ifreq

Brooks Davis brooks at one-eyed-alien.net
Thu Jan 12 21:30:26 PST 2006


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
===================================================================
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 */

-- 
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-net/attachments/20060112/caca078c/attachment.bin


More information about the freebsd-net mailing list