diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2016-08-04 10:07:25 -0300 | 
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetwroks.com> | 2016-08-07 21:05:26 -0400 | 
| commit | 288b91e0bdf99bd835ce82905415011f77ce5a62 (patch) | |
| tree | a29d6320c7960ae83ae884b40673d3f5eb32f46f /ospf6d/ospf6_network.c | |
| parent | 23b1f400488df822664e62c41fa24dde9c17913d (diff) | |
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>
Diffstat (limited to 'ospf6d/ospf6_network.c')
| -rw-r--r-- | ospf6d/ospf6_network.c | 14 | 
1 files changed, 9 insertions, 5 deletions
diff --git a/ospf6d/ospf6_network.c b/ospf6d/ospf6_network.c index 7b1cf91932..5e254661f1 100644 --- a/ospf6d/ospf6_network.c +++ b/ospf6d/ospf6_network.c @@ -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))  | 
