Re: [PATCH net-next v5 4/4] ipv4: replace obsolete routing comment
From: Ido Schimmel
Date: Thu Nov 19 2026 - 10:21:18 EST
tl;dr - I believe the patch is fine as-is.
On Wed, Nov 18, 2026 at 11:28:30PM +0000, netdev-bot+sashiko@xxxxxxxxxx wrote:
> 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.
This is the same comment from patch 2 and the same reply applies:
https://lore.kernel.org/netdev/2503cfd2-5629-448f-bb9b-111ea239efb6@xxxxxxxxxxxxxx/