ospf6d: fix sendmsg on OpenBSD

When sending ancillary data on OpenBSD, we need to tell the compiler
that the ancillary data buffer should be aligned on the stack to the
minimum alignment of the first ancillary data object that will be sent.

Additionally, HAVE_SIN6_SCOPE_ID is not defined anywhere, check for
HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID instead.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
Renato Westphal 2016-08-04 10:07:25 -03:00 committed by Donald Sharp
parent 23b1f40048
commit 288b91e0bd

View File

@ -198,14 +198,18 @@ ospf6_sendmsg (struct in6_addr *src, struct in6_addr *dst,
int retval;
struct msghdr smsghdr;
struct cmsghdr *scmsgp;
u_char cmsgbuf[CMSG_SPACE(sizeof (struct in6_pktinfo))];
union
{
struct cmsghdr hdr;
u_char buf[CMSG_SPACE (sizeof (struct in6_pktinfo))];
} cmsgbuf;
struct in6_pktinfo *pktinfo;
struct sockaddr_in6 dst_sin6;
assert (dst);
assert (*ifindex);
scmsgp = (struct cmsghdr *)cmsgbuf;
scmsgp = (struct cmsghdr *)&cmsgbuf;
pktinfo = (struct in6_pktinfo *)(CMSG_DATA(scmsgp));
memset (&dst_sin6, 0, sizeof (struct sockaddr_in6));
@ -222,7 +226,7 @@ ospf6_sendmsg (struct in6_addr *src, struct in6_addr *dst,
dst_sin6.sin6_len = sizeof (struct sockaddr_in6);
#endif /*SIN6_LEN*/
memcpy (&dst_sin6.sin6_addr, dst, sizeof (struct in6_addr));
#ifdef HAVE_SIN6_SCOPE_ID
#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
dst_sin6.sin6_scope_id = *ifindex;
#endif
@ -238,8 +242,8 @@ ospf6_sendmsg (struct in6_addr *src, struct in6_addr *dst,
smsghdr.msg_iovlen = iov_count (message);
smsghdr.msg_name = (caddr_t) &dst_sin6;
smsghdr.msg_namelen = sizeof (struct sockaddr_in6);
smsghdr.msg_control = (caddr_t) cmsgbuf;
smsghdr.msg_controllen = scmsgp->cmsg_len;
smsghdr.msg_control = (caddr_t) &cmsgbuf.buf;
smsghdr.msg_controllen = sizeof(cmsgbuf.buf);
retval = sendmsg (ospf6_sock, &smsghdr, 0);
if (retval != iov_totallen (message))