Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: littlesmilingcloud@gmail.com
Cc: netdev@vger.kernel.org, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, davem@davemloft.net, horms@kernel.org,
	dsahern@kernel.org, willemb@google.com, idosch@nvidia.com,
	fw@strlen.de, u9012063@gmail.com, mvohra@vmware.com,
	matthias.may@westermo.com, mazin@getstate.dev, shuah@kernel.org,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v8 4/5] ip6_gre: go by the inner protocol behind VLAN tags in ip6erspan
Date: Thu, 03 Dec 2026 12:39:02 +0000	[thread overview]
Message-ID: <179630154270.3146.6100860750270294903@kernel.org> (raw)
In-Reply-To: <20261202123613.1708463-5-littlesmilingcloud@gmail.com>

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

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

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 advertised MTU on the -EMSGSIZE path is too large for
  ip6erspan, and this patch now sends it to VLAN-tagged IPv4 senders as…
- [Low] The commit message does not mention several behaviour changes the
  patch makes.
- [Low] The patch fixes user-visible bugs in ip6erspan_tunnel_xmit() but
  has no Fixes: tag.

--

ip6_gre: go by the inner protocol behind VLAN tags in ip6erspan

This patch makes ip6erspan_tunnel_xmit() and ip6_tnl_xmit() use the
payload protocol classified on tunnel entry instead of skb->protocol. With
this, VLAN-tagged IPv4/IPv6 frames get traffic class inheritance, length
checks and the matching ICMP error. On -EMSGSIZE, non-IP payloads no
longer go down the ICMPv6 error path.

> ip6erspan_tunnel_xmit() uses skb->protocol to select the inner header
> for traffic class and flow label inheritance, length checks and ICMP
> errors. ip6_tnl_xmit() uses it to select the minimum MTU. When the
> protocol is a VLAN EtherType, a tagged IPv4 packet can lose its traffic
> class and take the ICMPv6 error path on -EMSGSIZE.

[ ... ]

> Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>

[Severity: Low]
Should this patch have a Fixes: tag?

Users can see both behaviours fixed here:

- On native ip6erspan, tagged IPv4/IPv6 lost traffic class and flow
  label inheritance because the switch fell into the default branch.
- On -EMSGSIZE, every non-IPv4 payload (ARP, or IPv4 behind a tag) went
  to icmpv6_ndo_send() through the unconditional else.

Both go back to the original ip6erspan native and collect_md support.

This patch also depends on payload_protocol, which comes from the
previous patch in the series, "ip6_gre: classify the inner packet once
on transmit". That patch does carry Fixes: tags.

Without a tag here, could stable tooling pick up the prerequisite but
miss this follow-up? That would leave ip6erspan only partly fixed in
stable trees.

> diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
> index c413e47c6ceb0..0ecee2271bbd1 100644
> --- a/net/ipv6/ip6_gre.c
> +++ b/net/ipv6/ip6_gre.c

[ ... ]

> @@ -1087,7 +1087,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
>  			goto tx_err;
>  		}
>  	} else {
> -		switch (skb->protocol) {
> +		switch (payload_protocol) {

[Severity: Low]
This isn't a bug, but should the commit message describe the other
behaviour changes for tagged frames on native ip6erspan?

With switch (payload_protocol), VLAN-tagged IPv4/IPv6 frames now go
through prepare_ip6gre_xmit_ipv4() and prepare_ip6gre_xmit_ipv6(). They
used to take the default branch, which left encap_limit at -1:

		default:
			memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6));
			break;

For tagged traffic this means:

- encap_limit now comes from t->parms.encap_limit unless
  IP6_TNL_F_IGN_ENCAP_LIMIT is set. Unset is the default, because
  ip6gre_netlink_parms() zeroes the flags. ip6_tnl_xmit() then lowers
  mtu by 8 and pushes an 8-byte Tunnel Encapsulation Limit destination
  option, so the packets on the wire change.
- With IP6_TNL_F_USE_ORIG_FWMARK, the outer route lookup now uses
  skb->mark.
- Tagged IPv6 frames whose source equals t->parms.raddr are now dropped.
- Tagged IPv6 frames that carry an encap limit option of 0 are now
  dropped, and an ICMPv6 Parameter Problem is sent.

The subject mentions only ip6erspan, but the floor change in
ip6_tnl_xmit() also affects ip6gretap. ip6gre_xmit_ipv6() passes
ETH_P_IPV6 as payload_protocol for tagged IPv6:

	err = __gre6_xmit(skb, dev, dsfield, &fl6, encap_limit,
			  &mtu, skb->protocol, htons(ETH_P_IPV6));

So tagged IPv6 on ip6gretap now gets the IPV6_MIN_MTU floor instead of
IPV4_MIN_MTU.

Untagged traffic already behaves this way, so these changes are probably
intended. The previous patch in the series, "ip6_gre: classify the inner
packet once on transmit", has a "What changes for traffic that was not
broken before" section. Could this patch have a similar one?

>  		case htons(ETH_P_IP):
>  			memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
>  			prepare_ip6gre_xmit_ipv4(skb, dev, &fl6,
> @@ -1132,10 +1132,10 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
>  	if (err != 0) {
>  		/* XXX: send ICMP error even if DF is not set. */
>  		if (err == -EMSGSIZE) {
> -			if (skb->protocol == htons(ETH_P_IP))
> +			if (payload_protocol == htons(ETH_P_IP))
>  				icmp_ndo_send(skb, ICMP_DEST_UNREACH,
>  					      ICMP_FRAG_NEEDED, htonl(mtu));
> -			else
> +			else if (payload_protocol == htons(ETH_P_IPV6))
>  				icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);

[Severity: Medium]
Is the mtu reported here small enough for ip6erspan? VLAN-tagged IPv4
senders now receive it too.

In ip6_tnl_xmit(), the only tunnel header subtracted from the advertised
value is the GRE header, via t->tun_hlen:

	mtu = dst6_mtu(dst) - eth_hlen - psh_hlen - t->tun_hlen;
	...
	if (skb->len - t->tun_hlen - eth_hlen > mtu && !skb_is_gso(skb)) {
		*pmtu = mtu;
		err = -EMSGSIZE;

ip6erspan_calc_hlen() sets tun_hlen to 8 and counts the ERSPAN header
only in t->hlen:

	tunnel->tun_hlen = 8;
	tunnel->hlen = tunnel->tun_hlen + tunnel->encap_hlen +
		       erspan_hdr_len(tunnel->parms.erspan_ver);

By the time ip6_tnl_xmit() runs, ip6erspan_tunnel_xmit() has already
pushed the ERSPAN and GRE headers. ip6gre_xmit_classify() has also put
the network header behind the tags, at depth = ETH_HLEN + 4 * n_tags.

So the length check passes only when the inner IP length is at most
mtu - erspan_hdr_len - 4 * n_tags. Yet icmp_ndo_send() and
icmpv6_ndo_send() advertise mtu itself, and
skb_dst_update_pmtu_no_confirm() caches that same value on the inner
route.

A sender that honours this Frag Needed or Packet Too Big would shrink
its packets to mtu, get rejected again with the same mtu, and never
converge. Wouldn't packets in the window
(mtu - erspan_hdr_len - 4 * n_tags, mtu] be black-holed?

The test result in the commit message looks like an example of this:

  "Each error quoted the original Echo Request and advertised MTU 1338."

With that path MTU, the largest inner packet that passes the check seems
to be 1330 bytes for v1 without a tag, and 1326 bytes for v1 with one
802.1Q tag.

The ERSPAN header part already affected untagged traffic before this
patch. The tag bytes part is new exposure for tagged IPv4 on ip6erspan.

>  		}
>  

[ ... ]

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

  reply	other threads:[~2026-12-03 12:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 12:36 [PATCH net-next v8 0/5] ip6_gre, erspan: fix inner header handling for VLAN-tagged and short frames Anton Danilov
2026-12-02 12:36 ` [PATCH net-next v8 1/5] erspan: bound the VLAN tag read in erspan_build_header{,_v2}() Anton Danilov
2026-12-02 12:36 ` [PATCH net-next v8 2/5] erspan: take the COS from the mirrored frame, not from the tunnel family Anton Danilov
2026-12-03 12:38   ` netdev-bot+sashiko
2026-12-02 12:36 ` [PATCH net-next v8 3/5] ip6_gre: classify the inner packet once on transmit Anton Danilov
2026-12-03 12:39   ` netdev-bot+sashiko
2026-12-02 12:36 ` [PATCH net-next v8 4/5] ip6_gre: go by the inner protocol behind VLAN tags in ip6erspan Anton Danilov
2026-12-03 12:39   ` netdev-bot+sashiko [this message]
2026-12-02 12:36 ` [PATCH net-next v8 5/5] selftests: net: add a test for ip6gretap and ip6erspan with VLAN tags Anton Danilov

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=179630154270.3146.6100860750270294903@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=littlesmilingcloud@gmail.com \
    --cc=matthias.may@westermo.com \
    --cc=mazin@getstate.dev \
    --cc=mvohra@vmware.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    --cc=u9012063@gmail.com \
    --cc=willemb@google.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