Subject: Re: dhcpd
To: Nicolas Joly <njoly@pasteur.fr>
From: Greg Troxel <gdt@ir.bbn.com>
List: current-users
Date: 09/13/2007 14:29:28
I looked at the ifconf() code and now think that the kernel wasn't
copying the whole sockaddr.  I have compile tested but not run the
following patch, which I think will fix the 'missing two bytes' of the
mac address problem, as well as unbreak v6 addresses.

Index: sys/net/if.c
===================================================================
RCS file: /cvsroot/src/sys/net/if.c,v
retrieving revision 1.200
diff -u -p -r1.200 if.c
--- sys/net/if.c	11 Sep 2007 19:31:22 -0000	1.200
+++ sys/net/if.c	13 Sep 2007 18:28:48 -0000
@@ -1669,7 +1669,7 @@ ifconf(u_long cmd, void *data)
 
 			if (ifrp != NULL)
 			{
-				ifr.ifr_addr = *sa;
+				memcpy(&ifr.ifr_space, sa, sa->sa_len);
 				if (space >= sz) {
 					error = copyout(&ifr, ifrp, sz);
 					if (error != 0)
Index: sys/net/if.h
===================================================================
RCS file: /cvsroot/src/sys/net/if.h,v
retrieving revision 1.126
diff -u -p -r1.126 if.h
--- sys/net/if.h	2 Sep 2007 00:24:18 -0000	1.126
+++ sys/net/if.h	13 Sep 2007 18:28:48 -0000
@@ -552,6 +552,7 @@ struct	ifreq {
 #define	ifr_addr	ifr_ifru.ifru_addr	/* address */
 #define	ifr_dstaddr	ifr_ifru.ifru_dstaddr	/* other end of p-to-p link */
 #define	ifr_broadaddr	ifr_ifru.ifru_broadaddr	/* broadcast address */
+#define	ifr_space	ifr_ifru.ifru_space	/* sockaddr_storage */
 #define	ifr_flags	ifr_ifru.ifru_flags	/* flags */
 #define	ifr_metric	ifr_ifru.ifru_metric	/* metric */
 #define	ifr_mtu		ifr_ifru.ifru_mtu	/* mtu */