tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: routing link local addresses: where to put the scope id?



At Thu, 20 Jul 2017 15:08:34 +0200,
Edgar Fuß <ef%math.uni-bonn.de@localhost> wrote:

> > The point I'm asking all this is that I'm investigating why ipf fails to
> > send TCP RSTs over link-local addresses. I've tracked this down as far as
> > that ipf6_fastroute() calls nd6_output() with a gateway route, causing
> > EHOSTUNREACH. My impression is that ipf_fastroute6() fails to tell the
> > routing routines about the LL scope -- I just don't know whether it should
> > do the KAME stuffing before calling  the routing routines or whether it
> > should call rtcache_setdst() with sin6_scope_id filled in?
> Stuffing the scope into addr16[1] makes it work (for me).
> I tested this on 7.1; I can't tell whether the pre-4.99.11 part is correct.

I suggest using utility functions defined in scope6.c instead of
manually tweaking sin6_addr:

> +    /* KAME */
> +    if (IN6_IS_ADDR_LINKLOCAL(&u.dst6.sin6_addr))
> +        u.dst6.sin6_addr.s6_addr16[1] = htons(ifp->if_index);

These two lines could (should) be:

    if ((error = in6_setscope(&u.dst6.sin6_addr, ifp,
        &u.dst6.sin6_scope_id)) != 0)
        goto bad;
    if ((error = sa6_embedscope(&u.dst6, 0)) != 0)
        goto bad;

It tries to hide as many implementation details as possible, and also
covers other types of IPv6 scoped addresses (in practice unicast
link-local may be the only type you're interested in, but in principle
you'd need to expect it could be, e.g., a scoped multicast address).

--
JINMEI, Tatuya


Home | Main Index | Thread Index | Old Index