mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: liamsmith827@grapheneos.org
Cc: netdev@vger.kernel.org, dsahern@kernel.org, idosch@nvidia.com,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org, shuah@kernel.org,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	liamsmith827@proton.me
Subject: Re: [PATCH net-next v5 4/4] ipv4: replace obsolete routing comment
Date: Wed, 18 Nov 2026 23:28:30 +0000	[thread overview]
Message-ID: <179504451061.3136.1731007912948900423@kernel.org> (raw)
In-Reply-To: <20261116202741.13106-5-liamsmith827@grapheneos.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The comment this patch adds in ip_route_output_key_hash_rcu()
  (net/ipv4/route.c) says "Non-vrf unicast honors restrictions"…

--

ipv4: replace obsolete routing comment

This commit replaces the comment above the on-link fallback in
ip_route_output_key_hash_rcu(). The commit message says the old comment
described obsolete fib_lookup(), MSG_DONTROUTE and IPv6 behavior. The new
comment explains how restriction routes and lookup misses are handled
when an oif is specified.

> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index b71443e4b522c..d0930ae4c5ae6 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -2866,24 +2866,18 @@ struct rtable *ip_route_output_key_hash_rcu(struct net *net, struct flowi4 *fl4,
>  		if (fl4->flowi4_oif &&
>  		    (ipv4_is_multicast(fl4->daddr) ||
>  		     (!fl4->flowi4_l3mdev && err == -ESRCH))) {
> -			/* Apparently, routing tables are wrong. Assume,
> -			 * that the destination is on link.
> +			/* When oif is specified, fib_lookup() is called
> +			 * primarily to determine if the destination is
> +			 * accessible directly or through a gateway. It also
> +			 * checks whether there are any traffic restrictions
> +			 * (blackhole, prohibit, unreachable), or if there's a
> +			 * routing lookup miss.
>  			 *
> -			 * WHY? DW.
> -			 * Because we are allowed to send to iface
> -			 * even if it has NO routes and NO assigned
> -			 * addresses. When oif is specified, routing
> -			 * tables are looked up with only one purpose:
> -			 * to catch if destination is gatewayed, rather than
> -			 * direct. Moreover, if MSG_DONTROUTE is set,
> -			 * we send packet, ignoring both routing tables
> -			 * and ifaddr state. --ANK
> -			 *
> -			 *
> -			 * We could make it even if oif is unknown,
> -			 * likely IPv6, but we do not.
> +			 * Multicast is sent regardless of restriction or miss.
> +			 * Non-vrf unicast honors restrictions but allows
> +			 * oif-bound sends even when oif has no routes. In both
> +			 * cases the destination is assumed on-link.

[Severity: Medium]
Does "Non-vrf unicast honors restrictions" hold for senders that do the
lookup at link scope? The commit message also calls the old MSG_DONTROUTE
remark obsolete, but it looks like that remark still describes the
current behavior.

MSG_DONTROUTE, SO_DONTROUTE and strict source routing all make
ip_sendmsg_scope() return RT_SCOPE_LINK, and that value ends up in
fl4->flowi4_scope:

include/net/ip.h:ip_sendmsg_scope() {
	if (sock_flag(&inet->sk, SOCK_LOCALROUTE) ||
	    msg->msg_flags & MSG_DONTROUTE ||
	    (ipc->opt && ipc->opt->opt.is_strictroute))
		return RT_SCOPE_LINK;
    ...
}

fib_table_lookup() applies the scope filter before it checks the route
type's error:

net/ipv4/fib_trie.c:fib_table_lookup() {
    ...
		if (fa->fa_info->fib_scope < flp->flowi4_scope)
			continue;
		fib_alias_accessed(fa);
		err = fib_props[fa->fa_type].error;
    ...
}

By default, fib_props[] gives blackhole, prohibit and unreachable routes
RT_SCOPE_UNIVERSE, so a link-scope lookup skips them. If no link-scope
route covers the destination, the lookup returns -EAGAIN. fib_lookup()
with FIB_LOOKUP_REPORT_MISS then reports that as -ESRCH.

If an oif is set through SO_BINDTODEVICE, IP_PKTINFO or IP_UNICAST_IF,
the condition above is true. The code then builds an on-link RTN_UNICAST
route even though a prohibit, blackhole or unreachable route matches the
destination:

udp_sendmsg() / raw_sendmsg() / ping_v4_sendmsg()
  ip_sendmsg_scope() -> RT_SCOPE_LINK
  ip_route_output_key_hash_rcu()
    fib_lookup(..., FIB_LOOKUP_REPORT_MISS)
      fib_table_lookup() skips the universe-scope prohibit route
      -> -EAGAIN -> -ESRCH
    on-link fallback

None of these steps need privileges. On this path, only FIB rule actions
such as FR_ACT_PROHIBIT still apply, because they are not filtered by
scope.

Could the comment and the commit message say that link-scope (DONTROUTE)
lookups bypass restriction routes here? The series aims to make
restriction routes apply comprehensively ("ipv4: restrict on-link
fallback to lookup misses"), but nothing in the series documents this
case.

>  			 */
> -
>  			if (fl4->saddr == 0)
>  				fl4->saddr = inet_select_addr(dev_out, 0,
>  							      RT_SCOPE_LINK);

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116202741.13106-1-liamsmith827%40grapheneos.org

  reply	other threads:[~2026-11-18 23:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 20:27 [PATCH net-next v5 0/4] ipv4: restrict on-link fallback to lookup misses liamsmith827
2026-11-16 20:27 ` [PATCH net-next v5 1/4] ipv4: add FIB_LOOKUP_REPORT_MISS liamsmith827
2026-11-16 20:27 ` [PATCH net-next v5 2/4] ipv4: restrict on-link fallback to lookup misses liamsmith827
2026-11-18 23:28   ` netdev-bot+sashiko
2026-11-16 20:27 ` [PATCH net-next v5 3/4] selftests: net: test restricted on-link fallback liamsmith827
2026-11-18 23:28   ` netdev-bot+sashiko
2026-11-16 20:27 ` [PATCH net-next v5 4/4] ipv4: replace obsolete routing comment liamsmith827
2026-11-18 23:28   ` netdev-bot+sashiko [this message]
2026-11-17 10:56 ` [PATCH net-next v5 0/4] ipv4: restrict on-link fallback to lookup misses Ido Schimmel

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=179504451061.3136.1731007912948900423@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=liamsmith827@grapheneos.org \
    --cc=liamsmith827@proton.me \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@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

all inboxes | Powered by JetHome®