Bug 296656 - IPv6 ND SIOCSIFINFO_IN6 cannot raise stale nd_linkmtu above already-clamped in6_ifmtu()
Summary: IPv6 ND SIOCSIFINFO_IN6 cannot raise stale nd_linkmtu above already-clamped i...
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 16.0-CURRENT
Hardware: amd64 Any
: --- Affects Many People
Assignee: freebsd-net (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-07-10 01:29 UTC by Oleg
Modified: 2026-07-27 11:31 UTC (History)
1 user (show)

See Also:


Attachments
nd6_linkmtu_ioctl.patch (1.00 KB, patch)
2026-07-10 01:29 UTC, Oleg
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Oleg 2026-07-10 01:29:35 UTC
Created attachment 272677 [details]
nd6_linkmtu_ioctl.patch

I found an IPv6 ND link-MTU recovery problem on FreeBSD 16.0-CURRENT.

  System:

  FreeBSD 16.0-CURRENT
  Interface: rge0
  Driver: if_rge
  Interface MTU: 4074

  The machine is directly connected to another FreeBSD machine over Ethernet. The physical link and driver can pass larger frames; for example,
  large IPv6 pings succeed.

  Problem state:

  ifconfig rge0

  shows:

  rge0 ... mtu 4074

  but:

  ndp -i rge0

  shows:

  linkmtu=1500, maxmtu=4074

  This affects TCP. A packet capture of an IPv6 TCP handshake showed the peer sending mss 4014, but this machine replied with:

  options [mss 1440,...]

  even though the interface MTU was 4074 and large IPv6 ping packets worked.

  I tried disabling RA, removing the autoconf global IPv6 address, flushing NDP entries, flushing prefixes/default routers, disabling/re-enabling
  IPv6 on the interface, and changing MTU 1500 -> 4074 -> 9000 -> 4074. The effective ND link MTU stayed stuck at 1500.

  The kernel source appears to contain a self-clamping validation problem in sys/netinet6/nd6.c:

  if (ND.linkmtu < IPV6_MMTU ||
      ND.linkmtu > in6_ifmtu(ifp)) {
          error = EINVAL;
          break;
  }

  in6_ifmtu(ifp) already returns the lower stale nd_linkmtu when it is below if_mtu, so once nd_linkmtu is 1500, userland cannot raise it to a
  valid value such as 4074 via SIOCSIFINFO_IN6.

  I tested the attached patch, which validates against the interface’s allowed maximum MTU instead of the already-clamped effective MTU, and calls
  rt_updatemtu(ifp) when nd_linkmtu changes.

  Runtime test after patch:

  /tmp/set_nd_linkmtu rge0 1500
  rge0 linkmtu=1500 maxmtu=4074

  /tmp/set_nd_linkmtu rge0 4074
  rge0 linkmtu=4074 maxmtu=4074

  After raising linkmtu to 4074, tcpdump showed the IPv6 TCP SYN-ACK correctly advertising:

  options [mss 4014,...]

  instead of mss 1440.

  IPv6 iperf also improved from about 2.0 Gbit/s to about 2.28 Gbit/s on this direct 2.5G link.

  I am attaching the patch I tested.
Comment 1 Andrey V. Elsukov freebsd_committer freebsd_triage 2026-07-27 09:33:06 UTC
I assume you did copy handling from nd6_ra_opt_mtu(). This looks reasonable, but I think you need add some handling to nd6_setmtu() too. Thus changing MTU via ifconfig will also modify linkmtu.
Comment 2 Oleg 2026-07-27 11:31:11 UTC
If you think updating nd6_setmtu() is the right approach, please feel free to proceed. I hope we can get this bug fixed and the report resolved. Thank you!