Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - problem routing udp traffic out a specific interface: (4 Items)
   
problem routing udp traffic out a specific interface  
We have a strange problem that we're hoping to get some help with.  We have the following scenario:

# route show
Routing tables
 
Internet:
Destination                  Gateway                     Flags 
default                        192.168.99.1              UG     
10.0.0.1                       10.68.0.89                  UH    
localhost.localdom      127.0.0.1                    UH    
192.168.99.0/24          link#2                         U     
192.168.99.1               00:1a:e2:06:9b:f9       UHL

Our network interfaces are as follows:

# ifconfig -a
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33192
        inet 127.0.0.1 netmask 0xff000000
mos0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        address: 00:18:5a:81:06:0c
        media: Ethernet autoselect (100baseTX full-duplex)
        status: active
        inet 192.168.99.166 netmask 0xffffff00 broadcast 192.168.99.255
ppp0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1600
        inet 10.68.0.89 -> 10.0.0.1 netmask 0xff000000

We have a UDP socket that we want to send/recv on, but we only want that traffic to go over the ppp0 interface.  We're 
using SO_BINDTODEVICE, and have also called bind() on the socket to bind it to only the ppp0 ip addr.

However, when we try to call sendto() on the socket, we get no route to host.  Specifically, we're sending to an ip 
address that is not on either of the directly attached networks.

From my read on the docs though, this should work; the udp packets should be sent out the ppp0 interface, because of the
 binding and the use of the SO_BINDTODEVICE socket option.

What am I missing?

-garyf
Re: problem routing udp traffic out a specific interface  
IIRC routing is still consulted.  Where are you trying to send
to?  It could be the route points out the mos0 iface or no
route at all.  You could also try the SO_DONTROUTE option.

-seanb

On Fri, Dec 12, 2008 at 01:02:13PM -0500, Gary Faulkner wrote:
> We have a strange problem that we're hoping to get some help with.  We have the following scenario:
> 
> # route show
> Routing tables
>  
> Internet:
> Destination                  Gateway                     Flags 
> default                        192.168.99.1              UG     
> 10.0.0.1                       10.68.0.89                  UH    
> localhost.localdom      127.0.0.1                    UH    
> 192.168.99.0/24          link#2                         U     
> 192.168.99.1               00:1a:e2:06:9b:f9       UHL
> 
> Our network interfaces are as follows:
> 
> # ifconfig -a
> lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33192
>         inet 127.0.0.1 netmask 0xff000000
> mos0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
>         address: 00:18:5a:81:06:0c
>         media: Ethernet autoselect (100baseTX full-duplex)
>         status: active
>         inet 192.168.99.166 netmask 0xffffff00 broadcast 192.168.99.255
> ppp0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1600
>         inet 10.68.0.89 -> 10.0.0.1 netmask 0xff000000
> 
> We have a UDP socket that we want to send/recv on, but we only want that traffic to go over the ppp0 interface.  We're
 using SO_BINDTODEVICE, and have also called bind() on the socket to bind it to only the ppp0 ip addr.
> 
> However, when we try to call sendto() on the socket, we get no route to host.  Specifically, we're sending to an ip 
address that is not on either of the directly attached networks.
> 
> From my read on the docs though, this should work; the udp packets should be sent out the ppp0 interface, because of 
the binding and the use of the SO_BINDTODEVICE socket option.
> 
> What am I missing?
> 
> -garyf
> 
> _______________________________________________
> General
> http://community.qnx.com/sf/go/post18533
> 
Re: problem routing udp traffic out a specific interface  
Thanks for the quick reply, Sean!

So, here's the deal:

mos0 is our onboard ethernet interface.  The ppp0 interface is for a GPRS modem.  If we loose general connectivity over 
ethernet, we will fall back to ppp0.

However, we want to be able to continually send a periodic "heartbeat" over GPRS (to indicate that the device is still 
alive).

So, the ip address in sendto might be something like 172.17.99.147.

We did try the SO_DONTROUTE, but then sendto gives us a ENETUNREACH.

So, my follow-on question is if the routing table is still consulted, then what does SO_BINDTODEVICE really buy us?  

Thanks again, Sean!

-garyf
Re: problem routing udp traffic out a specific interface  
On Fri, Dec 12, 2008 at 01:21:54PM -0500, Gary Faulkner wrote:
> Thanks for the quick reply, Sean!
> 
> So, here's the deal:
> 
> mos0 is our onboard ethernet interface.  The ppp0 interface is for a GPRS modem.  If we loose general connectivity 
over ethernet, we will fall back to ppp0.
> 
> However, we want to be able to continually send a periodic "heartbeat" over GPRS (to indicate that the device is still
 alive).
> 
> So, the ip address in sendto might be something like 172.17.99.147.
> 
> We did try the SO_DONTROUTE, but then sendto gives us a ENETUNREACH.
> 
> So, my follow-on question is if the routing table is still consulted, then what does SO_BINDTODEVICE really buy us?  
> 
> Thanks again, Sean!

It might not do what you want here.  It's been found useful to
direct broadcasts out a specific iface before BPF.  It also
filters on input.  This page I just created may be useful for
setting up a route on the ppp iface ('ifp' or 'iface' option
to the route utility).

http://community.qnx.com/sf/wiki/do/viewPage/projects.networking/wiki/UnnumberedInterfaces