In article <[EMAIL PROTECTED]>,
Alan DeKok <[EMAIL PROTECTED]> wrote:
>"John Gruber" <[EMAIL PROTECTED]> wrote:
>> But bind on * should work too.. and the reply should come from the address
>> for the interface the request was sent to. It just doesn't, and I did not
>> have the time at the time to see why in the code.
>
>  It only works if you call bind() immediately upon receiving a
>packet.  That's expensive, and causes the server to do a *lot* of
>work.

You mean immediately before sending a reply. But that creates
a race condition, since you can then not receive packets from
other interfaces anymore. Unless you use a seperate send and
receive socket. However then you need to lock around the
bind() / sendto() calls, to prevent race conditions between
threads. It's not worth it.

It's also impossible for another reason: you cannot know on
which interface a certain UDP packet was received. recvfrom()
only records the clients IP address, not the address of the
interface the packet was received on.

With Linux, you can use recvmsg() / sendmsg() with IP_PKTINFO
in the ancillary data to get / set the local address, but that
is not portable (though *BSD appears to have something similar).

>  A better solution is to explicitely list the addresses the server
>listens on, which is much less expensive, but requires a bit more
>code.

And just open one socket for each address/port to listen
on. Yes, that is the easiest solution by far.

Mike.
-- 
Anyone who is capable of getting themselves made President should
on no account be allowed to do the job -- Douglas Adams.


- 
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Reply via email to