Hello,

        Looks like I'm a bit late with the storm of changes
in the routing.

        By default, after allocation rt_uses_gateway was set to 0.
Later it can be set to 1 if nh_gw is not the final route target,
i.e. it is indirect GW and not a target on LAN (the RT_SCOPE_LINK
check in rt_set_nexthop).

        What remains hidden for the rt_uses_gateway semantic
is this code in rt_set_nexthop:

        if (unlikely(!cached)) {
                /* Routes we intend to cache in nexthop exception or
                 * FIB nexthop have the DST_NOCACHE bit clear.
                 * However, if we are unsuccessful at storing this
                 * route into the cache we really need to set it.
                 */
                if (!rt->rt_gateway)
                        rt->rt_gateway = daddr;
                rt_add_uncached_list(rt);
        }

and this code in rt_bind_exception:

        if (!rt->rt_gateway)
                rt->rt_gateway = daddr;

        I.e. even if rt_uses_gateway remains 0, rt_gateway
can contain address, i.e. the target is on LAN and not
behind nh_gw.

        Now I see commit 1550c171935d wrongly changes that to
"If rt_gw_family is set it implies rt_uses_gateway.".
As result, we set rt_gw_family while rt_uses_gateway was 0
for above cases. Think about it in this way: there should be
a reason why we used rt_uses_gateway flag instead a simple
"rt_gateway != 0" check, right?

        Replacing rt->rt_gateway checks with rt_gw_family
checks is right but rt_uses_gateway checks should be put
back because they indicates the route has more hops to
target.

        As the problem is related to some FNHW and non-cached
routes, redirects, etc the easiest way to see the problem is with
'ip route get LOCAL_IP oif eth0' where extra 'via GW' line is
shown.

Regards

--
Julian Anastasov <j...@ssi.bg>

Reply via email to