netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Julian Anastasov <ja@ssi.bg>
To: David Ahern <dsahern@gmail.com>
Cc: netdev@vger.kernel.org, Ido Schimmel <idosch@mellanox.com>
Subject: rt_uses_gateway was removed?
Date: Sun, 15 Sep 2019 12:08:53 +0300 (EEST)	[thread overview]
Message-ID: <alpine.LFD.2.21.1909151104060.2546@ja.home.ssi.bg> (raw)


	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 <ja@ssi.bg>

             reply	other threads:[~2019-09-15  9:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-15  9:08 Julian Anastasov [this message]
2019-09-16  0:05 ` rt_uses_gateway was removed? David Ahern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.21.1909151104060.2546@ja.home.ssi.bg \
    --to=ja@ssi.bg \
    --cc=dsahern@gmail.com \
    --cc=idosch@mellanox.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).