lkml.org 
[lkml]   [2003]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
SubjectRe: sendmsg and IP_PKTINFO
On Tuesday February 18, davem@redhat.com wrote:
> From: Neil Brown <neilb@cse.unsw.edu.au>
> Date: Tue, 18 Feb 2003 22:00:37 +1100
>
> It does go on to say that the outgoing packet will be sent over the
> same interface, however I feel that is an illogical conclusion given
> the description of the meaning of the field.
>
> So yes, the current behaviour seems to match part of the
> documentation. However I argue that the documented behaviour is
> irrational.
>
> Alexey and myself totally disagree. We have described for you
> the intended purpose of this feature. Please do not try to use
> it in some other way, it may prove to be painful :-)


Thankyou for making that clear.

I am currently working towards testing a patch that will fix the
behaviour of glibc.

Currently the sunrpc/svc_udp.c code asks for an IP_PKTINFO from
recvmsg, and passes it verbatim down through sendmsg.
My patch checks that the returned data looks believable and, if it
does, zeros the ipi_ifindex field.

NeilBrown



--- sunrpc/svc_udp.c.orig 2003-02-19 11:25:20.000000000 +1100
+++ sunrpc/svc_udp.c 2003-02-19 14:28:46.000000000 +1100
@@ -256,8 +256,26 @@
mesgp->msg_controllen = sizeof(xprt->xp_pad)
- sizeof (struct iovec) - sizeof (struct msghdr);
rlen = recvmsg (xprt->xp_sock, mesgp, 0);
- if (rlen >= 0)
- len = mesgp->msg_namelen;
+ if (rlen >= 0) {
+ struct cmsghdr *cmsg;
+ len = mesgp->msg_namelen;
+ cmsg = CMSG_FIRSTHDR(mesgp);
+ if (cmsg == NULL ||
+ CMSG_NXTHDR(mesgp, cmsg) != NULL ||
+ cmsg->cmsg_level != SOL_IP ||
+ cmsg->cmsg_type != IP_PKTINFO ||
+ cmsg->cmsg_len != sizeof(struct in_pktinfo)) {
+ /* Not a simple IP_PKTINFO, ignore it */
+ mesgp->msg_control = NULL;
+ mesgp->msg_controllen = 0;
+ } else {
+ /* it was a simple IP_PKTIFO as we expected,
+ * Discard the interface field
+ */
+ struct in_pktinfo *pkti = CMSG_DATA(cmsg);
+ pkti->ipi_ifindex = 0;
+ }
+ }
}
else
#endif
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:33    [W:0.084 / U:0.488 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site