pretty
pretty

Reputation: 67

SO_DEBUG and SO_DONTROUTE in traceroute

Can anyone explain the difference between SO_DEBUG and SO_DONTROUTE . This is my understanding

SO_DONTROUTE

            Enable / disable routing bypass for outgoing message

            Routing takes place only when it goes to out of subnet.

            This tell that do not route, directly connect to the destination instead of routing

            SO_DONTROUTE refers to the local routing

            But default it is zero

            Do not route send directly to the connected network

            If the host is not on a directly-attached network
    an error is returned.  This option can be used to ping
    a local host through an interface that has no route.

SO_DEBUG

            When enabled, the kernel keeps track of detailed
    information about the packets sent and received by TCP for the socket

But in traceroute if i give -d option in commandline, SO_DONTROUTE option is also enabled . Also when i enable -r option -d is also enabling . May i know why ?

Upvotes: 2

Views: 4657

Answers (1)

Malt
Malt

Reputation: 30285

I don't see any clear relation between the two flags, so this is (probably) some implementation specific behavior, maybe even a bug.

I've ran traceroute -d 8.8.8.8 on an Ubuntu 14.04 machine with the default traceroute installed - Modern traceroute for Linux, version 2.0.20, Aug 19 2014 and managed to reach 8.8.8.8 just fine. With the -r flag the traceroute fails with a Network is unreachable error message since the machine can't find 8.8.8.8.

Looking at the strace of both traceroute -r and traceroute -d I've also verified that one calls only setsockopt(3, SOL_SOCKET, SO_DONTROUTE, [1], 4), while the other one calls only setsockopt(3, SOL_SOCKET, SO_DEBUG, [1], 4).

The sources for Van Jacobson's traceroute from the official (?) should behave in the same way. Here is (a piece) of the code that parses the command line switches:

case 'r':
    options |= SO_DONTROUTE;
    break;

case 'd':
    options |= SO_DEBUG;
    break;

And here are the socket options:

if (options & SO_DEBUG)
    (void)setsockopt(s, SOL_SOCKET, SO_DEBUG, (char *)&on,
        sizeof(on));
if (options & SO_DONTROUTE)
    (void)setsockopt(s, SOL_SOCKET, SO_DONTROUTE, (char *)&on,
        sizeof(on));

But perhaps the sources are from a different version..

Upvotes: 1

Related Questions