Commit 26be93ad authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] knfsd: Fix cmsg setup for sock_sendmsg in svc_sendto

From: Trond Myklebust <trond.myklebust@fys.uio.no>

... see the code in ip_sockglue.c + the macros in socket.h....
AFAICS the control messages have wierd alignment requirements.
parent aa8bf616
...@@ -352,9 +352,9 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr) ...@@ -352,9 +352,9 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr)
struct svc_sock *svsk = rqstp->rq_sock; struct svc_sock *svsk = rqstp->rq_sock;
struct socket *sock = svsk->sk_sock; struct socket *sock = svsk->sk_sock;
int slen; int slen;
struct { struct cmsghdr cmh; char buffer[CMSG_SPACE(sizeof(struct in_pktinfo))];
struct in_pktinfo pki; struct cmsghdr *cmh = (struct cmsghdr *)buffer;
} cm; struct in_pktinfo *pki = (struct in_pktinfo *)CMSG_DATA(cmh);
int len = 0; int len = 0;
int result; int result;
int size; int size;
...@@ -374,13 +374,13 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr) ...@@ -374,13 +374,13 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr)
msg.msg_iovlen = 0; msg.msg_iovlen = 0;
msg.msg_flags = MSG_MORE; msg.msg_flags = MSG_MORE;
msg.msg_control = &cm; msg.msg_control = cmh;
msg.msg_controllen = sizeof(cm); msg.msg_controllen = sizeof(buffer);
cm.cmh.cmsg_len = sizeof(cm); cmh->cmsg_len = CMSG_LEN(sizeof(*pki));
cm.cmh.cmsg_level = SOL_IP; cmh->cmsg_level = SOL_IP;
cm.cmh.cmsg_type = IP_PKTINFO; cmh->cmsg_type = IP_PKTINFO;
cm.pki.ipi_ifindex = 0; pki->ipi_ifindex = 0;
cm.pki.ipi_spec_dst.s_addr = rqstp->rq_daddr; pki->ipi_spec_dst.s_addr = rqstp->rq_daddr;
if (sock_sendmsg(sock, &msg, 0) < 0) if (sock_sendmsg(sock, &msg, 0) < 0)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment