[Bug 218508] Tunneling and aliases using the tun device, reusing a destination address works with IPv4, but not IPv6

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Thu Feb 25 15:39:43 UTC 2021


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=218508

Denton Gentry <denny at geekhold.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |denny at geekhold.com

--- Comment #2 from Denton Gentry <denny at geekhold.com> ---
We've been encountering this in
https://github.com/tailscale/tailscale/issues/1307

The problem occurs because rtrequest1_fib returns EEXIST.

root at freebsd12:~ # dtrace -n 'fbt:::return /(int)arg1 == EEXIST / { stack(); }'
-c "ifconfig tun0 inet6 fd7a:115c:a1e0:ab12:4843:cd96:625c:1f1b
fd7a:115c:a1e0:ab12:4843:cd96:625c:1f1b prefixlen 128"
dtrace: description 'fbt:::return ' matched 29364 probes
ifconfig: ioctl (SIOCAIFADDR): File exists
dtrace: pid 1175 exited with status 1
CPU     ID                    FUNCTION:NAME
  1  52657            rtrequest1_fib:return
              kernel`rtinit+0x421
              kernel`in6_update_ifa+0xc6b
              kernel`in6_control+0x96f
              kernel`ifioctl+0x47f
              kernel`kern_ioctl+0x2b7
              kernel`sys_ioctl+0xfa
              kernel`amd64_syscall+0x387
              kernel`0xffffffff8106785e

That happens because rn_addroute returns NULL:

rn_addroute(void *v_arg, void *n_arg, struct radix_head *head,
    struct radix_node treenodes[2])
...
        /*
         * Deal with duplicated keys: attach node to previous instance
         */
        saved_tt = tt = rn_insert(v, head, &keyduplicated, treenodes);
        if (keyduplicated) {
                for (t = tt; tt; t = tt, tt = tt->rn_dupedkey) {
#ifdef RADIX_MPATH
                        /* permit multipath, if enabled for the family */
                        ...
#endif
                        if (tt->rn_mask == netmask)
                                return (0);


There is a bunch of code within the #ifdef RADIX_MPATH block above. Enabling
RADIX_MPATH in the kernel config does allow the tun0 address assignment to
succeed, though I haven't fully tested if it works as expected.


It looks like this behavior was understood, in a comment in
sys/netinet6/in6.c:in6_notify_ifa from 2004:

        /*
         * If a new destination address is specified for a point-to-point
         * interface, install a route to the destination as an interface
         * direct route.
         * XXX: the logic below rejects assigning multiple addresses on a p2p.
         * interface that share the same destination.
         */
        plen = in6_mask2len(&ia->ia_prefixmask.sin6_addr, NULL); /* XXX */
        if (!(ia->ia_flags & IFA_ROUTE) && plen == 128 &&
            ia->ia_dstaddr.sin6_family == AF_INET6) {

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-net mailing list