git: 503ecf5bf454 - main - if_geneve: Read the outer IP header from the start of the packet

From: Pouria Mousavizadeh Tehrani <pouria_at_FreeBSD.org>
Date: Fri, 13 Nov 2026 17:16:39 UTC
The branch main has been updated by pouria:

URL: https://cgit.FreeBSD.org/src/commit/?id=503ecf5bf454a7d716111365471e879560e870c7

commit 503ecf5bf454a7d716111365471e879560e870c7
Author:     Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
AuthorDate: 2026-11-13 13:51:43 +0000
Commit:     Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
CommitDate: 2026-11-13 17:15:47 +0000

    if_geneve: Read the outer IP header from the start of the packet
    
    The offset passed to geneve_udp_input() points at the UDP header,
    which for IPv6 comes after any extension headers.
    The outer header is always at the start of the mbuf.
    
    Reported by:    llm-postcr
    Fixes:          e44d2e941e8e ("if_geneve: Add Support for Geneve (RFC8926)")
---
 sys/net/if_geneve.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/net/if_geneve.c b/sys/net/if_geneve.c
index e13075ec583d..f08c0f5e1ebf 100644
--- a/sys/net/if_geneve.c
+++ b/sys/net/if_geneve.c
@@ -2983,11 +2983,11 @@ geneve_udp_input(struct mbuf *m, int offset, struct inpcb *inpcb,
 	memset(&info, 0, sizeof(info));
 	info.ethertype = geneve_get_ethertype(m);
 	if (info.ethertype == ETHERTYPE_IP) {
-		iphdr = mtodo(m, offset - sizeof(struct ip));
+		iphdr = mtod(m, struct ip *);
 		info.ecn = (iphdr->ip_tos & IPTOS_ECN_MASK);
 		info.ttl = iphdr->ip_ttl;
 	} else if (info.ethertype == ETHERTYPE_IPV6) {
-		ip6hdr = mtodo(m, offset - sizeof(struct ip6_hdr));
+		ip6hdr = mtod(m, struct ip6_hdr *);
 		info.ecn = IPV6_ECN(ip6hdr);
 		info.ttl = ip6hdr->ip6_hlim;
 	}