tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

re: COMPAT_50 vs NET_RT_IFLIST



Alas, making the suggested changes does not help.  Same results as
before:

Userland and Kernel both -current with suggested changes (the diffs
are attached to this Email):

	# ifconfig -l
	wm0 lo0
	# ifconfig lo0
	lo0: flags=0x8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33624
	        inet 127.0.0.1/8 flags 0x0
	        inet6 ::1/128 flags 0x20<NODAD>
	        inet6 fe80::1%lo0/64 flags 0x0 scopeid 0x2
	#


And with a 5.2 base system loaded in /chroot52 directory:

	# chroot /chroot52 ifconfig -l

	# chroot /chroot52 ifconfig lo0

	#


On Mon, 29 Apr 2019, matthew green wrote:

I still cannot explain how things got broken between 5.2 and 8.0.  I
will defer to those who are more expert in this area than am I.  My
suspicion is that the breakage is related to sys/socket.h rev 1.99
which versioned AF_{,O}ROUTE for some 64-bit cleanliness.

i think i have a guess about the problem.

sys/net/if.h, sys/net/route.h, and sys/compat/net/if.h all
have this code:

/*
* Message format for use in obtaining information about interfaces from
* sysctl and the routing socket.  We need to force 64-bit alignment if we
* aren't using compatiblity definitons.
*/
#if !defined(_KERNEL) || !defined(COMPAT_RTSOCK)
#define __align64       __aligned(sizeof(uint64_t))
#else
#define __align64
#endif
struct if_msghdr {
       u_short ifm_msglen __align64;

but i think this comment is wrong.

the compat structures are defined in the compat headers and
the above structure should never change, however when the
code handling code wants to talk to the *real* structure it
will get this adjusted one (without the align), and thus
it will copy the wrong portions out from it.

the fix may be as simple as removing this from these headers
(leaving it always defined for the current defs), and making
sure that the compat headers have the right alignment (my
quick look seem ok.)

this will, obviously, need a recompile of the newer kernel.


.mrg.

!DSPAM:5cc6a3b33697082216442!



+--------------------+--------------------------+-----------------------+
| Paul Goyette       | PGP Key fingerprint:     | E-mail addresses:     |
| (Retired)          | FA29 0E3B 35AF E8AE 6651 | paul%whooppee.com@localhost     |
| Software Developer | 0786 F758 55DE 53BA 7731 | pgoyette%netbsd.org@localhost   |
+--------------------+--------------------------+-----------------------+
Index: if.h
===================================================================
RCS file: /cvsroot/src/sys/net/if.h,v
retrieving revision 1.269
diff -u -p -r1.269 if.h
--- if.h	23 Mar 2019 09:48:04 -0000	1.269
+++ if.h	29 Apr 2019 11:34:55 -0000
@@ -737,14 +737,10 @@ struct ifaddr {
 
 /*
  * Message format for use in obtaining information about interfaces from
- * sysctl and the routing socket.  We need to force 64-bit alignment if we
- * aren't using compatiblity definitons.
+ * sysctl and the routing socket.  We need to force 64-bit alignment.
  */
-#if !defined(_KERNEL) || !defined(COMPAT_RTSOCK)
 #define	__align64	__aligned(sizeof(uint64_t))
-#else
-#define	__align64
-#endif
+
 struct if_msghdr {
 	u_short	ifm_msglen __align64;
 				/* to skip over non-understood messages */
Index: route.h
===================================================================
RCS file: /cvsroot/src/sys/net/route.h,v
retrieving revision 1.121
diff -u -p -r1.121 route.h
--- route.h	29 Apr 2019 05:42:09 -0000	1.121
+++ route.h	29 Apr 2019 11:34:55 -0000
@@ -204,16 +204,11 @@ struct	rtstat {
  * at a 64-bit boundary, we also force the size to be a multiple of 64-bits.
  */
 
-#if !defined(_KERNEL) || !defined(COMPAT_RTSOCK)
 /*
- * If we aren't being compiled for backwards compatiblity, enforce 64-bit
- * alignment so any routing message is the same regardless if the kernel
- * is an ILP32 or LP64 kernel.
+ * Enforce 64-bit alignment so any routing message is the same regardless
+ * if the kernel is an ILP32 or LP64 kernel.
  */
 #define	__align64	__aligned(sizeof(uint64_t))
-#else
-#define	__align64
-#endif
 
 struct rt_msghdr {
 	u_short	rtm_msglen __align64;


Home | Main Index | Thread Index | Old Index