mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: littlesmilingcloud@gmail.com
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
	dsahern@kernel.org, idosch@nvidia.com, andrew+netdev@lunn.ch,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v5 12/14] ip6_tunnel: make ip6_tnl_xmit() return a drop reason
Date: Sun, 04 Oct 2026 21:00:49 +0000	[thread overview]
Message-ID: <179114764950.434549.13525459501912673806@kernel.org> (raw)
In-Reply-To: <20260930183910.3151873-13-littlesmilingcloud@gmail.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] In net/ipv6/ip6_tunnel.c, ip6_tnl_xmit() reports
  SKB_DROP_REASON_DEV_READY every time ip6_tnl_xmit_ctl() refuses a…
- [Low] ip6_tnl_start_xmit() (net/ipv6/ip6_tunnel.c:1487-1488) now
  reports SKB_DROP_REASON_RECURSION_LIMIT when ip6_tnl_addr_conflict()…

Pre-existing issues:
- [Medium] This problem wasn't introduced by this patch, but on a
  collect_md ip6gretap device, ip6gre_xmit_ipv6()…

--

ip6_tunnel: make ip6_tnl_xmit() return a drop reason

This converts ip6_tnl_xmit(), ipxip6_tnl_xmit(), __gre6_xmit() and the
ip6gre_xmit_*() helpers to return an enum skb_drop_reason instead of 0,
-1 or an errno. ip6_tnl_start_xmit() now frees the skb with the returned
reason. The -EMSGSIZE checks that trigger ICMP errors now check for
SKB_DROP_REASON_PKT_TOO_BIG instead.

> diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
> index ba080a58ecb2d..9e94ea6b6c20f 100644
> --- a/net/ipv6/ip6_gre.c
> +++ b/net/ipv6/ip6_gre.c

[ ... ]

> -static inline int ip6gre_xmit_ipv6(struct sk_buff *skb, struct net_device *dev)
> +static inline enum skb_drop_reason ip6gre_xmit_ipv6(struct sk_buff *skb,
> +						    struct net_device *dev)
>  {
>  	struct ip6_tnl *t = netdev_priv(dev);
>  	struct ipv6hdr *ipv6h = ipv6_hdr(skb);
> +	enum skb_drop_reason reason;
>  	int encap_limit = -1;
>  	struct flowi6 fl6;
>  	__u8 dsfield = 0;
>  	__u32 mtu;
> -	int err;
>  
>  	if (ipv6_addr_equal(&t->parms.raddr, &ipv6h->saddr))
> -		return -1;
> +		return SKB_DROP_REASON_RECURSION_LIMIT;

[Severity: Medium]
This is a pre-existing issue and was not introduced by this patch. Does
this check drop valid traffic on a collect_md ip6gretap device?

In collect_md mode t->parms.raddr is ::. The real endpoint is taken from
the tunnel metadata later, in __gre6_xmit():

	fl6->daddr = key->u.ipv6.dst;

Take an inner IPv6 packet whose source is ::, for example a DAD neighbour
solicitation or an MLD report sent before a link-local address exists.
Suppose it is bridged into the tunnel and tc tunnel_key or BPF gives it
valid IPv6 transmit metadata. It matches ipv6_addr_equal(::, ::) here and
is dropped before __gre6_xmit() can use the metadata destination.

ip6erspan_tunnel_xmit() does the same raddr == saddr check only in its
non-collect_md branch. Should ip6gre_xmit_ipv6() also skip the check when
t->parms.collect_md is set?

This patch only turns "return -1" into SKB_DROP_REASON_RECURSION_LIMIT. The
commit message also notes that these packets were dropped before.

[ ... ]

> diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
> index 52f6a38657b9f..7e444115f4314 100644
> --- a/net/ipv6/ip6_tunnel.c
> +++ b/net/ipv6/ip6_tunnel.c

[ ... ]

> @@ -1192,8 +1203,10 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
>  	if (use_cache)
>  		dst = dst_cache_get(&t->dst_cache);
>  
> -	if (!ip6_tnl_xmit_ctl(t, &fl6->saddr, &fl6->daddr))
> +	if (!ip6_tnl_xmit_ctl(t, &fl6->saddr, &fl6->daddr)) {
> +		reason = SKB_DROP_REASON_DEV_READY;
>  		goto tx_err_link_failure;
> +	}

[Severity: Low]
Is SKB_DROP_REASON_DEV_READY the right reason for every refusal from
ip6_tnl_xmit_ctl()?

ip6_tnl_xmit_ctl() returns 0 in three cases:

- the local address is not configured yet,
- the remote address is found on this node,
- the tunnel lacks IP6_TNL_F_CAP_XMIT for the given addresses.

net/ipv6/ip6_tunnel.c:ip6_tnl_xmit_ctl() {
    ...
		if (unlikely(!ipv6_chk_addr_and_flags(net, laddr, ldev, false,
						      0, IFA_F_TENTATIVE)))
			pr_warn_ratelimited("%s xmit: Local address not yet configured!\n",
					    p->name);
		else if (!(p->flags & IP6_TNL_F_ALLOW_LOCAL_REMOTE) &&
			 ...
			pr_warn_ratelimited("%s xmit: Routing loop! Remote address found on this node!\n",
					    p->name);
    ...
}

The kernel-doc in include/net/dropreason-core.h describes DEV_READY as:

 * @SKB_DROP_REASON_DEV_READY: the device is not ready to xmit/recv due to
 * any of its data structure that is not up/ready/initialized,
 * e.g., the IFF_UP is not set, or driver specific tun->tfiles[txq]
 * is not initialized

That description covers only the first case. The routing loop case is
closer to SKB_DROP_REASON_RECURSION_LIMIT, which ip6_tnl_xmit() already
uses for tdev == dev.

As a result, a tunnel whose remote address is local shows up in
drop_monitor or skb:kfree_skb as a device that is not ready. Later in the
series, ip6gre_tunnel_xmit() and ip6erspan_tunnel_xmit() use the same
mapping when ip6_tnl_xmit_ctl() fails.

The commit message acknowledges this and leaves the split for a follow-up.
Could ip6_tnl_xmit_ctl() return a reason as part of this series instead?

[ ... ]

> @@ -1462,27 +1484,31 @@ ip6_tnl_start_xmit(struct sk_buff *skb, struct net_device *dev)
>  		ipproto = IPPROTO_IPIP;
>  		break;
>  	case htons(ETH_P_IPV6):
> -		if (ip6_tnl_addr_conflict(t, ipv6_hdr(skb)))
> +		if (ip6_tnl_addr_conflict(t, ipv6_hdr(skb))) {
> +			reason = SKB_DROP_REASON_RECURSION_LIMIT;
>  			goto tx_err;
> +		}

[Severity: Low]
Does RECURSION_LIMIT describe these drops on a tunnel that has no fixed
exit point?

On collect_md devices and NBMA ip6tnl devices, t->parms.raddr is ::. So
ip6_tnl_addr_conflict() matches every inner IPv6 packet whose source is
::. The raddr == saddr check in ip6gre_xmit_ipv6() above behaves the same
way on a collect_md ip6gretap device.

The kernel-doc for this reason says:

 * @SKB_DROP_REASON_RECURSION_LIMIT: Dead loop on virtual device, e.g. a
 * tunnel whose route to its remote end goes out of the tunnel device
 * itself.

On the IPv4 side it is only used for the tdev == dev route loop. A packet
from :: on such a tunnel is not a loop.

The commit message acknowledges this and says the reason "names the check
that drops them".

The next patch, "ip6_gre: add drop reasons to the transmit path", only
reclassifies ip6gretap packets without IPv6 tunnel metadata, as
SKB_DROP_REASON_TUNNEL_TXINFO. Packets from :: that do carry metadata are
still reported as RECURSION_LIMIT.

Could packets from :: be reported under a different reason on tunnels
whose raddr is ::?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260930183910.3151873-1-littlesmilingcloud%40gmail.com

  reply	other threads:[~2026-10-04 21:00 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30 18:38 [PATCH net-next v5 00/14] tunnels: add core and gre drop reasons Anton Danilov
2026-09-30 18:38 ` [PATCH net-next v5 01/14] vxlan: rename the drop reasons for use by other tunnels Anton Danilov
2026-09-30 18:38 ` [PATCH net-next v5 02/14] ip_tunnel: make __iptunnel_pull_header() return a drop reason Anton Danilov
2026-10-04 21:00   ` netdev-bot+sashiko
2026-09-30 18:38 ` [PATCH net-next v5 03/14] vxlan: report the drop reason of __iptunnel_pull_header() Anton Danilov
2026-09-30 18:39 ` [PATCH net-next v5 04/14] ip_tunnel: add drop reasons to the generic RX path Anton Danilov
2026-10-04 16:06   ` Ido Schimmel
2026-09-30 18:39 ` [PATCH net-next v5 05/14] ip6_tunnel: add drop reasons to the receive path Anton Danilov
2026-10-04 16:47   ` Ido Schimmel
2026-10-04 21:00   ` netdev-bot+sashiko
2026-09-30 18:39 ` [PATCH net-next v5 06/14] gre: make gre_parse_header() report a drop reason Anton Danilov
2026-09-30 18:39 ` [PATCH net-next v5 07/14] ip_gre: add drop reasons to the RX path Anton Danilov
2026-10-04 21:00   ` netdev-bot+sashiko
2026-09-30 18:39 ` [PATCH net-next v5 08/14] ip6_gre: " Anton Danilov
2026-09-30 18:39 ` [PATCH net-next v5 09/14] ip_tunnel: add drop reasons to the transmit path Anton Danilov
2026-10-04 16:08   ` Ido Schimmel
2026-10-04 16:15     ` Ido Schimmel
2026-09-30 18:39 ` [PATCH net-next v5 10/14] ip_gre: " Anton Danilov
2026-09-30 18:39 ` [PATCH net-next v5 11/14] ip6_gre: make prepare_ip6gre_xmit_other() void Anton Danilov
2026-09-30 18:39 ` [PATCH net-next v5 12/14] ip6_tunnel: make ip6_tnl_xmit() return a drop reason Anton Danilov
2026-10-04 21:00   ` netdev-bot+sashiko [this message]
2026-09-30 18:39 ` [PATCH net-next v5 13/14] ip6_gre: add drop reasons to the transmit path Anton Danilov
2026-10-04 21:00   ` netdev-bot+sashiko
2026-09-30 18:39 ` [PATCH net-next v5 14/14] vxlan: report a circular route as SKB_DROP_REASON_RECURSION_LIMIT Anton Danilov
2026-10-04 16:50 ` [PATCH net-next v5 00/14] tunnels: add core and gre drop reasons 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=179114764950.434549.13525459501912673806@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=littlesmilingcloud@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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®