lkml.org 
[lkml]   [2003]   [Feb]   [18]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
FromNeil Brown <>
DateTue, 18 Feb 2003 22:00:37 +1100
SubjectRe: sendmsg and IP_PKTINFO
On  February 17, davem@redhat.com wrote:
> On Fri, 2003-02-14 at 17:53, Neil Brown wrote:
> > No.
> > My application (which is just using standard rpc server libraries) is
> > saying
> >   "This is in reply to a request that came in through a given
> >   interface".
> > 
> > It is not reasonable to treat that statement as equivalent to:
> >   "This packet must go out that interface"
> > 
> > which is what appears to be happening.
> 
> You misunderstand what this control message knob means during
> a sendmsg() then, it means "send this over interface X"
> 
> There is no other valid expectation.
> 
> I'm curious where you read something that would suggest otherwise
> for sendmsg() behavior wrt. ip_pktinfo

man 7 ip

on debian (unstable).

I quote:

       IP_PKTINFO
              Pass an IP_PKTINFO ancillary message  that  contains  a  pktinfo
              structure  that  supplies  some  information  about the incoming
              packet.  This only works for  datagram  oriented  sockets.   The
              argument  is a flag that tells the socket whether the IP_PKTINFO
              message should be passed or not. The message itself can only  be
              sent/retrieved as control message with a packet using recvmsg(2)
              or sendmsg(2).

              struct in_pktinfo {
                  unsigned int   ipi_ifindex;  /* Interface index */
                  struct in_addr ipi_spec_dst; /* Local address */
                  struct in_addr ipi_addr;     /* Header Destination address */
              };
              ipi_ifindex is the unique index of the interface the packet  was
              received  on.   ipi_spec_dst  is the local address of the packet
              and ipi_addr is the destination address in  the  packet  header.
              If  IP_PKTINFO  is passed to sendmsg(2) then the outgoing packet
              will be sent over the interface specified  in  ipi_ifindex  with
              the destination address set to ipi_spec_dst


Note that the in_pktinfo is described as "some information about the
incoming packet".  In particular ipi_ifindex is "the unique index of
the interface the packets was received on".

i.e. it is more about the incoming than the outgoing packet.

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.
A more rational behaviour is
 "the outgoing packet will be sent over the interface specified in
 ipi_ifindex if that interface has a valid route to the packets
 destination.  Otherwise normal rouing rules apply".

I further argue that this is not only more rational, but is actually
more useful (which is a more telling point).

NeilBrown
-
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 12:33    [from the cache]
©2003-2008