mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-17 21:38:11 +00:00
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:
parent
23b1f40048
commit
288b91e0bd
@ -198,14 +198,18 @@ ospf6_sendmsg (struct in6_addr *src, struct in6_addr *dst,
|
|||||||
int retval;
|
int retval;
|
||||||
struct msghdr smsghdr;
|
struct msghdr smsghdr;
|
||||||
struct cmsghdr *scmsgp;
|
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 in6_pktinfo *pktinfo;
|
||||||
struct sockaddr_in6 dst_sin6;
|
struct sockaddr_in6 dst_sin6;
|
||||||
|
|
||||||
assert (dst);
|
assert (dst);
|
||||||
assert (*ifindex);
|
assert (*ifindex);
|
||||||
|
|
||||||
scmsgp = (struct cmsghdr *)cmsgbuf;
|
scmsgp = (struct cmsghdr *)&cmsgbuf;
|
||||||
pktinfo = (struct in6_pktinfo *)(CMSG_DATA(scmsgp));
|
pktinfo = (struct in6_pktinfo *)(CMSG_DATA(scmsgp));
|
||||||
memset (&dst_sin6, 0, sizeof (struct sockaddr_in6));
|
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);
|
dst_sin6.sin6_len = sizeof (struct sockaddr_in6);
|
||||||
#endif /*SIN6_LEN*/
|
#endif /*SIN6_LEN*/
|
||||||
memcpy (&dst_sin6.sin6_addr, dst, sizeof (struct in6_addr));
|
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;
|
dst_sin6.sin6_scope_id = *ifindex;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -238,8 +242,8 @@ ospf6_sendmsg (struct in6_addr *src, struct in6_addr *dst,
|
|||||||
smsghdr.msg_iovlen = iov_count (message);
|
smsghdr.msg_iovlen = iov_count (message);
|
||||||
smsghdr.msg_name = (caddr_t) &dst_sin6;
|
smsghdr.msg_name = (caddr_t) &dst_sin6;
|
||||||
smsghdr.msg_namelen = sizeof (struct sockaddr_in6);
|
smsghdr.msg_namelen = sizeof (struct sockaddr_in6);
|
||||||
smsghdr.msg_control = (caddr_t) cmsgbuf;
|
smsghdr.msg_control = (caddr_t) &cmsgbuf.buf;
|
||||||
smsghdr.msg_controllen = scmsgp->cmsg_len;
|
smsghdr.msg_controllen = sizeof(cmsgbuf.buf);
|
||||||
|
|
||||||
retval = sendmsg (ospf6_sock, &smsghdr, 0);
|
retval = sendmsg (ospf6_sock, &smsghdr, 0);
|
||||||
if (retval != iov_totallen (message))
|
if (retval != iov_totallen (message))
|
||||||
|
Loading…
Reference in New Issue
Block a user