James Yonan wrote:
Stephen Borrill wrote:
Hi,
I've been looking at the 2.1 betas and getting excited about the
port-share option. There's numerous caveats about lack of portability
in the source and man page, but I don't know why. sendmsg and recvfrom
have been in BSD since, well, ever, really. NetBSD and FreeBSD have
both had MSG_NOSIGNAL support added (NetBSD very recently in response
to my feedback about OpenVPN), so the only outstanding issue is the
union fdmsg declarationon row 80 of ps.c. On NetBSD (at least)
CMSG_SPACE() isn't static and so can't used in a compile-time context
(it calls a function for CMSG_ALIGN()). Can this be worked around in
OpenVPN to improve portability? Perhaps a static and malloc in the
relevant places in port_share_sendmsg() and
control_message_from_parent()? I guess they don't need to be re-rentrant.
Feel free to port this to BSD. Basically the only aspect of the
port-share implementation which is problematic from a portability
perspective is that it needs the ability to pass an open file descriptor
to another process.
That doesn't seem to be a problem at all. The code just works once compiled,
but required me to manually expand the CMSG_SPACE macro based on the Linux
version. This is not particular portable as it's dependent upon the unit of
alignment being the same as long; I suspect this isn't necessary the case
for all processor architectures. It's just the allocation of the union fdmsg
that's the problem. I guess you have a preferred memory allocation method
which could be used to allocate a buffer held in a static in the above
functions. I could bodge something up, but you'd probably have a
preferential way to do it.
--
Stephen