netdev
[Top] [All Lists]

Re: UDP sockets bound to ANY send answers with wrong src ip address

To: Julian Anastasov <ja@xxxxxx>, Henrik Nordstrom <hno@xxxxxxxxxxxxxxx>
Subject: Re: UDP sockets bound to ANY send answers with wrong src ip address
From: Denis Vlasenko <vda@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 13 Jun 2004 01:08:51 +0300
Cc: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>, <yoshfuji@xxxxxxxxxxxxxx>, <netdev@xxxxxxxxxxx>, <linux-net@xxxxxxxxxxxxxxx>, <davem@xxxxxxxxxx>, <pekkas@xxxxxxxxxx>, <jmorris@xxxxxxxxxx>, <linux-kernel@xxxxxxxxxxxxxxx>
In-reply-to: <Pine.LNX.4.44.0406111651370.2763-100000@l>
References: <Pine.LNX.4.44.0406111651370.2763-100000@l>
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: KMail/1.5.4
On Friday 11 June 2004 16:53, Julian Anastasov wrote:
>       Hello,
>
> On Fri, 11 Jun 2004, Denis Vlasenko wrote:
> > Hmmm... do I have to set a *routing dest address* field
> > to set src ip address of my UDP packet?
>
>       Try such function:
>
> [snip]

Thanks for your excellent help Julian.
It helped me to finally make my code work.

Pity I did not keep it that way, because 
it wouldn't be portable. I converted it
to 'man cmsg' compliant way.

On Friday 11 June 2004 17:14, Henrik Nordstrom wrote:
> [snip]
> > I am trying to figure it out, currently I'm getting
> > -EINVAL in sendmsg in this code:
> >
> > # define SRCADDR_SOCKOPT IP_PKTINFO
> > # define SRCADDR_DATASIZE (CMSG_SPACE(sizeof(struct in_pktinfo)))
> > # define srcaddr(x) (&(((struct in_pktinfo
> > *)(CMSG_DATA(x)))->ipi_spec_dst))
>
> Drop the defines. These are only obfuscating your code and the source to
> your error. You need to pass a in_pktinfo structure in the message, and

They were there in the example recv code from the Net. That code tried
to use IP_DSTADDR (IIRC) option (a BSDism or something) if it is #defined.

Dropped #defines.

I ended up with following patch for djbdns. Run tested.

Thanks again for your help guys.
--
vda

Attachment: d.diff
Description: Text Data

<Prev in Thread] Current Thread [Next in Thread>