Index | Thread | Search

From:
Giovanni Pimpinella <pimpinella@di.uniroma1.it>
Subject:
Bug or feature? TCP chksum fails when IPv6 packet carries ext. headers
To:
tech@openbsd.org
Date:
Fri, 28 Feb 2025 19:18:24 +0100

Download raw body.

Thread
Hi,

While working on some tests with IPv6 extension headers I noticed that
OpenBSD
drops TCP packets if there is any extension header (pf is disabled).

I managed to pinpoint the problem to the `in6_cksum` function as it doesn't
receive
the correct offset where to find the TCP header (thus "failing" and
dropping the packet).
Instead, it receives a fixed offset of 40 bytes a.k.a `sizeof(struct
ip6_hdr)`.

Applying the following diff fixed the issue.

Index: src/sys/netinet/tcp_input.c

===================================================================

RCS file: /cvs/src/sys/netinet/tcp_input.c,v

retrieving revision 1.431

diff -u -p -u -p -r1.431 tcp_input.c

--- src/sys/netinet/tcp_input.c 17 Feb 2025 08:56:33 -0000 1.431

+++ src/sys/netinet/tcp_input.c 28 Feb 2025 17:23:51 -0000

@@ -469,7 +469,7 @@ tcp_input(struct mbuf **mp, int *offp, i

  break;

 #ifdef INET6

  case AF_INET6:

- sum = in6_cksum(m, IPPROTO_TCP, sizeof(struct ip6_hdr),

+ sum = in6_cksum(m, IPPROTO_TCP, iphlen,

      tlen);

  break;

 #endif

As this was a trivial mistake I was wondering whether it was intentional.
As such, in OpenBSD,
are IPv6 packets carrying TCP as the upper layer protocol NOT supposed to
also carry ext. headers?

--
Best regards,
Giovanni