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)
struct svc_sock *svsk = rqstp->rq_sock;
struct socket *sock = svsk->sk_sock;
int slen;
struct { struct cmsghdr cmh;
struct in_pktinfo pki;
} cm;
char buffer[CMSG_SPACE(sizeof(struct in_pktinfo))];
struct cmsghdr *cmh = (struct cmsghdr *)buffer;
struct in_pktinfo *pki = (struct in_pktinfo *)CMSG_DATA(cmh);
int len = 0;
int result;
int size;
......@@ -374,13 +374,13 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr)
msg.msg_iovlen = 0;
msg.msg_flags = MSG_MORE;
msg.msg_control = &cm;
msg.msg_controllen = sizeof(cm);
cm.cmh.cmsg_len = sizeof(cm);
cm.cmh.cmsg_level = SOL_IP;
cm.cmh.cmsg_type = IP_PKTINFO;
cm.pki.ipi_ifindex = 0;
cm.pki.ipi_spec_dst.s_addr = rqstp->rq_daddr;
msg.msg_control = cmh;
msg.msg_controllen = sizeof(buffer);
cmh->cmsg_len = CMSG_LEN(sizeof(*pki));
cmh->cmsg_level = SOL_IP;
cmh->cmsg_type = IP_PKTINFO;
pki->ipi_ifindex = 0;
pki->ipi_spec_dst.s_addr = rqstp->rq_daddr;
if (sock_sendmsg(sock, &msg, 0) < 0)
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