Traceroute ICMP option doesn't work

Denys Vlasenko vda.linux at googlemail.com
Fri Dec 11 10:51:05 UTC 2020


On Thu, Dec 10, 2020 at 1:23 PM M K Verma <manishverma1420 at gmail.com> wrote:
> Are you aware of how -I(ICMP) can be fixed on Busybox?
> I have gone through the code, tested and I see the -I(ICMP) is sent instead of UDP in case of IPv4 hosts when a flag is enabled in the defconfig.
>
> The same does not work out in case of IPv6 hosts, UDP packets are sent instead.
> Is this an architectural limitation of Busybox ? Or there is a room for a fix here ?
> If a fix is possible, we can together work on this.
> I have an IPv6 network where this can be tested.

You are right, looking at traceroute.c, send_probe():

send_probe(int seq, int ttl)
{
        int len, res;
        void *out;

        /* Payload */
#if ENABLE_TRACEROUTE6
        if (dest_lsa->u.sa.sa_family == AF_INET6) {
                struct outdata6_t *pkt = (struct outdata6_t *) outdata;
                pkt->ident6 = htonl(ident);
                pkt->seq6   = htonl(seq);
                /*gettimeofday(&pkt->tv, &tz);*/
        } else
#endif
        {
                outdata->seq = seq;
                outdata->ttl = ttl;
// UNUSED: was storing gettimeofday's result there, but never ever checked it
                /*memcpy(&outdata->tv, tp, sizeof(outdata->tv));*/

                if (option_mask32 & OPT_USE_ICMP) {
                        outicmp->icmp_seq = htons(seq);

                        /* Always calculate checksum for icmp packets */
                        outicmp->icmp_cksum = 0;
                        outicmp->icmp_cksum = inet_cksum(
                                        outicmp,
                                        ((char*)outip + packlen) -
(char*)outicmp
                        );
                        if (outicmp->icmp_cksum == 0)
                                outicmp->icmp_cksum = 0xffff;
                }
        }

The "ENABLE_TRACEROUTE6" block has no "if (option_mask32 & OPT_USE_ICMP) ..."
code path, but ipv4 alternatibe below has it. It needs to be added.


More information about the busybox mailing list