>Synopsis: When neighbour discovery for the IPv6 next hop of an MPLS
route fails, the labelled packets that waited for it are
passed to icmp6_error() as if they were IPv6.  The
"address unreachable" error is built from the bytes behind
the label stack and sent to an address made of them.
>Category: kernel
>Severity: non-critical
>Priority: low
>Class: sw-bug
>Release: OpenBSD 8.0-current (source as of 2026-11-03)
>Environment:
System      : OpenBSD 8.0-current
Details     : OpenBSD 8.0-current (GENERIC.MP); also with WITNESS
Architecture: OpenBSD.amd64
Machine     : amd64 (QEMU/KVM guest, 2 vcpu)
Source      : sys/net/if_ethersubr.c rev 1.308,
     sys/netinet6/nd6.c rev 1.305,
     sys/netinet6/icmp6.c rev 1.281;
     openbsd/src as of 2026-11-03, git d5b06e73

>Description:

On an Ethernet interface with "ifconfig ... mpls", ether_resolve()
handles an AF_MPLS destination whose next hop is an IPv6 address
by calling nd6_resolve() (if_ethersubr.c:291, in the AF_MPLS case
at :272-309).  The mbuf already starts with the shim header.  If
the neighbour is not resolved yet, nd6_resolve() keeps the mbuf
on the hold queue of the neighbour entry (ln_mq, nd6.c:1337) and
returns EAGAIN.  Nothing records that it is an MPLS packet.

If the neighbour never answers, nd6_llinfo_timer() gives up after
nd6_mmaxtries solicitations (nd6.c:339) and hands every held mbuf
to icmp6_error(ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADDR)
(nd6.c:343-361), which is right for an IPv6 packet but not for a
labelled one.  icmp6_do_error() (icmp6.c:230) reads the start of
the mbuf as an IPv6 header (icmp6.c:248).  Behind a single shim,
its source address is bytes 4-19 of the inner packet (for an
inner IPv6 packet: payload length, next header, hop limit and the
first 12 bytes of the real source) and its destination is bytes
20-35.  Only the multicast and unspecified checks apply
(icmp6.c:272), so icmp6_reflect() (icmp6.c:1026) sends an ICMPv6
destination unreachable to that made-up address whenever a route
matches it (icmp6.c:1132), for example a default route.  The error
quotes the labelled packet.

This happens on a router pushing a label towards an IPv6 next hop
that does not answer, and on a label switch router swapping a
label towards such a next hop.  In the second case the bytes that
become the destination of the error come from the packet a remote
host sent.

>How-To-Repeat:

As root (kernel with MPLS, as GENERIC):

1.  ifconfig pair101 create rdomain 101 up
2.  ifconfig pair102 create rdomain 102 up
3.  ifconfig pair101 inet6 fd00:101::1/64
4.  ifconfig pair102 inet6 fd00:101::2/64
5.  ifconfig pair101 patch pair102
6.  ifconfig pair101 mpls
   (wait a few seconds for duplicate address detection)
7.  route -T101 add -inet6 default fd00:101::2
8.  route -T101 add -inet6 fd00:102::/64 fd00:101::5 -mplslabel 100
9.  in a second terminal: tcpdump -n -i pair102 icmp6
10. ping6 -V101 -c 1 fd00:102::1

Nothing answers for fd00:101::5.  After three neighbour
solicitations for it, tcpdump shows (after the solicitation for
the default router fd00:101::2 and its answer)

   fd00:101::1 > 40:3a40:fd00:101::: icmp6: 0:1:fd00:102::
   unreachable address

The destination is the payload length (0x0040), next header
(0x3a) and hop limit (0x40) of the echo request followed by the
first 12 bytes of its source fd00:101::1; the quoted "destination"
0:1:fd00:102:: is the rest of the source and the start of the
real destination.  Step 7 only gives the error a route.

For comparison, the same with a plain IPv6 route:

11. route -T101 add -inet6 fd00:103::/64 fd00:101::5
12. ping6 -v -V101 -c 1 -w 5 fd00:103::1

Here ping6 reports "Destination Host Unreachable" from
fd00:101::1 for its own echo request, as expected, and no error
appears on pair102.

Clean up with "ifconfig pair101 destroy; ifconfig pair102 destroy".

>Fix:

Only IPv6 packets should get an ICMPv6 error.  ether_resolve() is
the only caller of nd6_resolve(); it now stores the family of the
packet in m_pkthdr.ph_family ("af, used when queueing") before
calling it: AF_INET6 for an IPv6 packet, AF_MPLS for a labelled
packet with an IPv6 next hop.  Setting AF_INET6 explicitly also
overwrites whatever an earlier stage left in the field.

nd6_llinfo_timer() frees held packets whose ph_family is not
AF_INET6 instead of passing them to icmp6_error().  The hold
queue accounting is unchanged (len is taken before the loop).
There is no IPv6 sender to report the failure to for a labelled
packet; it is dropped.

Index: sys/net/if_ethersubr.c
===================================================================
RCS file: /cvs/src/sys/net/if_ethersubr.c,v
diff -u -p -r1.308 if_ethersubr.c
--- sys/net/if_ethersubr.c 19 Dec 2025 02:04:13 -0000 1.308
+++ sys/net/if_ethersubr.c 6 Nov 2026 09:00:00 -0000
@@ -262,6 +262,7 @@ ether_resolve(struct ifnet *ifp, struct
  break;
 #ifdef INET6
  case AF_INET6:
+ m->m_pkthdr.ph_family = AF_INET6;
  error = nd6_resolve(ifp, rt, m, dst, eh->ether_dhost);
  if (error)
  return (error);
@@ -288,6 +289,8 @@ ether_resolve(struct ifnet *ifp, struct
  break;
 #ifdef INET6
  case AF_INET6:
+ /* nd6_llinfo_timer() must not treat it as IPv6 */
+ m->m_pkthdr.ph_family = AF_MPLS;
  error = nd6_resolve(ifp, rt, m, dst, eh->ether_dhost);
  if (error)
  return (error);
Index: sys/netinet6/nd6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/nd6.c,v
diff -u -p -r1.305 nd6.c
--- sys/netinet6/nd6.c 27 Nov 2025 21:54:28 -0000 1.305
+++ sys/netinet6/nd6.c 6 Nov 2026 09:00:00 -0000
@@ -349,6 +349,11 @@ nd6_llinfo_timer(struct rtentry *rt, int
  mq_delist(&ln->ln_mq, &ml);
  len = ml_len(&ml);
  while ((m = ml_dequeue(&ml)) != NULL) {
+ /* only IPv6 packets get an ICMPv6 error */
+ if (m->m_pkthdr.ph_family != AF_INET6) {
+ m_freem(m);
+ continue;
+ }
  /*
  * Fake rcvif to make the ICMP error
  * more helpful in diagnosing for the

>Verification:

The diff above (md5 e762d0758d0ca14b27df5da21adb39ea) was applied
with patch -p0 -F0 to a fresh export of the 2026-11-03 tree (git
d5b06e73); all three hunks applied with no offset or fuzz.  The
unpatched and the patched tree contain the 10504 files of the git
tree and differ only in sys/net/if_ethersubr.c and
sys/netinet6/nd6.c.  Kernels: GENERIC.MP (DIAGNOSTIC comes from
GENERIC), unpatched and patched, and the patched tree also with
"option WITNESS"; amd64, built without warnings; 2-vcpu guest.
Unpatched and patched GENERIC.MP were booted alternately, three
times each, and every boot ran the How-To-Repeat and the checks
below.

How-To-Repeat, steps 1-12 exactly as listed:
 unpatched   3/3: "fd00:101::1 > 40:3a40:fd00:101::: icmp6:
             0:1:fd00:102:: unreachable address" on pair102;
             step 12 "Destination Host Unreachable"
 patched     3/3: only the neighbour solicitations on pair102;
             step 12 "Destination Host Unreachable"
 With "option WITNESS": unpatched 1/1 as above, patched 1/1 as
 above; no WITNESS report.

Further checks, in rdomains 157-159 over pair(4) (results
unpatched / patched, 3 runs each, plus 1 run with WITNESS on the
patched and the unpatched kernel, same results):
 - label 100 pushed by a -mplslabel route towards an IPv6 next
   hop that never answers, default route present: one ICMPv6
   "unreachable address" to 40:3a40:fd00:170:: on the wire,
   1 call to icmp6_error / nothing on the wire, 0 calls
 - label switch router swapping 410 -> 420 towards an IPv6 next
   hop that never answers, the labelled echo request coming from
   another host: the router sends "unreachable address" to
   40:3a40:fd00:170:: (bytes of the remote packet), 2 calls to
   icmp6_error / nothing on the wire, 0 calls
 - plain IPv6, first packet while the neighbour resolves: 3/3
   echo requests sent correctly and answered in both kernels
 - plain IPv6 from the host itself, neighbour never answers:
   ping6 -v reports "Destination Host Unreachable", 1 call to
   icmp6_error in both kernels
 - plain IPv6 forwarded by a router, neighbour never answers:
   the sender receives "unreachable address" for its
   destination from the router in both kernels
 - push 411 and swap 411 -> 421 over IPv6 next hops: 3/3 sent
   with label 421 in both kernels
 - push 412 and pop towards an IPv6 next hop, reply pushed with
   413 and popped towards the sender: 3/3 answered in both
   kernels
No kernel messages in any run.

Reply via email to