Date: Tue, 27 Mar 2001 13:47:51 +0100 From: David Malone <dwmalone@maths.tcd.ie> To: freebsd-hackers@freebsd.org, freebsd-alpha@freebsd.org Cc: wpaul@freebsd.org, brian@freebsd.org Subject: Control messages. Message-ID: <200103271347.aa40230@salmon.maths.tcd.ie>
next in thread | raw e-mail | index | archive | help
I was looking at our implimention of passing descriptors and credentials over unix domain sockets (I want to add the ability to pass more than one message at a time). According to Steven's book you should use the CMSG_DATA macro to find the data in associated with a struct cmsghdr. We define this macro as: #define CMSG_DATA(cmsg) ((u_char *)(cmsg) + \ _ALIGN(sizeof(struct cmsghdr))) However, the kernel seems to get the address of the data by looking at (void *)(&cmsg[1]). Some applications either find the data either using the kernel's method or by using: struct blah { struct cmsghdr header; sturct wibble data; }; and taking the address of "data". Fortunately all these methods are the same on the i386 'cos the sizeof(sizeof(struct cmsghdr)) is a multiple of the alighment size. However on the alpha the alignment requirement is 8 bytes and so: CMSG_DATA(cmsg) != (&cmsg[1]) If you use the struct method then offset of "data" will line up with one or the other of these depending on the alignment requirements of data. I'd like to change the code to always use the CMSG_DATA method, which will change the ABI on the alpha. This shouldn't cause too much disruption as descriptor and credential passing is rarely used. (I think ppp and maybe some rpc stuff use it - not much else does). (As far as I can tell descriptor passing for a large number of descriptors will panic an alpha running FreeBSD too. If anyone can give access to an alpha that it's OK for me to crash I can test this). David. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-alpha" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi? <200103271347.aa40230>