[Xorp-users] Question on supporting multiple routing tables.

Pavlin Radoslavov pavlin at icir.org
Thu Aug 9 17:56:09 PDT 2007


> > I could be wrong, but for transmitting unicast packets (if we
> > exclude the Linux-specific SO_BINDTODEVICE) I don't think we (can)
> > explicitly specify the outgoing interface. I believe it will be
> > automatically chosen by the kernel (based on the matching forwarding
> > entry toward the destination). Only if the destination is on the same
> > subnet, we could use SO_DONTROUTE socket option or MSG_DONTROUTE
> > flag for send*(); currently we don't which we might need to change.
> > 
> > Could you confirm that SO_BINDTODEVICE has impact when choosing the
> > outgoing interface for transmitting packets?
> > The socket(7) Linux manual page describes SO_BINDTODEVICE's impact 
> > only for receiving packets, but the manual page itself might be
> > incomplete:
> 
> SO_BINDTODEVICE does bind to the out-going interface as well.  Please
> note that I also bind the local IP address (which matches the interface).
> I then configure the routing tables with rules so that pkts from a
> particular IP use a particular routing table.  I *think* that you could
> skip the SO_BINDTODEVICE and just bind to the local IP, as long as you have
> rules set up similar to mine.  But, by also binding with SO_BINDTODEVICE I
> think it will work in slightly more cases where the routing tables may
> be configured differently.

Thank you for the info.
Yes, I like the semantics of SO_BINDTODEVICE, because it simplifies
various things, but unfortunately it is available only on Linux.
This doesn't mean that we are definitely opposing using it, it is
just that I wish there is a similar solution for other OS-es as
well so we get reasonably consistent behavior.

Question to Bruce: is there a similar equivalent in BSD and Windows
userland?

> I'm sure you'll want to be able to bind the socket to a local IP, but
> if you want to leave out the SO_BINDTODEVICE I can test it and see
> if it works.  I can add the SO_BINDTODEVICE if needed and send you a patch.

Currently, we don't bind to the local IP (we do but in certain cases
only). I believe even if you bind to a local IP you cannot really
force the unicast IP packet to exit the system on the particular
interface. Anyway, I might be wrong here, so please let me know if
you find that bind()-ing only gives us the desired behavior.

BTW, what protocols are you planning to run? Without SO_BINDTODEVICE
we might have to use different solution for each type of
sockets/packets: raw IP packets, TCP, UDP.
FYI, the I/O system-specific stuff is inside fea/data_plane/io,
though io_tcpudp_socket.cc itself uses the xorp/libcomm wrapper
library.
BGP only doesn't use the FEA (yet) and does its own TCP connection
(inside bgp/socket.{hh,cc}).

Also, there could be some gotchas with RIP's UDP socket, but lets
address first the protocols you are actually going to use.


> No need to mess with MSG_DONTROUTE.
> 
> In case it helps, here is a snippet of 'ip ru show' on a test system:
> 
> 400:    from 10.1.0.2 lookup 9
> 400:    from 2.2.2.3 lookup 19
> 400:    from 2.2.2.2 lookup 23
> 
> foo# ip route show table 9
> 10.1.0.0/24 via 10.1.0.2 dev rddVR4
> default via 10.1.0.1 dev rddVR4

OK, that's useful to know.

Thanks,
Pavlin



More information about the Xorp-users mailing list