git: acf0be6e5192 - main - ip6: Drop dead code in ip6_input_hbh()

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 08 Jun 2026 22:50:04 UTC
The branch main has been updated by markj:

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

commit acf0be6e5192c8b1ae2c9a71d86828daf12317b2
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-06-08 22:45:44 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-06-08 22:49:51 +0000

    ip6: Drop dead code in ip6_input_hbh()
    
    After commit 069a67374ed9, ip6_input() quickly rejects packets with
    plen == 0, before ip6_input_hbh() is called.  So, there is no need to
    check this condition again in the helper function.
    
    Reviewed by:    pouria, zlei, tuexen
    Differential Revision:  https://reviews.freebsd.org/D57342
---
 sys/netinet6/ip6_input.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index 0dae879c1bd5..426b81dc9c03 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -421,24 +421,9 @@ ip6_input_hbh(struct mbuf **mp, uint32_t *rtalert, int *off,
 		goto out;	/* m have already been freed */
 	}
 
-	/* adjust pointer */
 	m = *mp;
 	ip6 = mtod(m, struct ip6_hdr *);
 
-	/*
-	 * If the payload length field is 0 and the next header field indicates
-	 * Hop-by-Hop Options header, then a Jumbo Payload option MUST be
-	 * included. We no not support Jumbo Payloads so report an error.
-	 */
-	if (ip6->ip6_plen == 0) {
-		IP6STAT_INC(ip6s_badoptions);
-		in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard);
-		in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr);
-		icmp6_error(m, ICMP6_PARAM_PROB,
-			    ICMP6_PARAMPROB_HEADER,
-			    (caddr_t)&ip6->ip6_plen - (caddr_t)ip6);
-		goto out;
-	}
 	/* ip6_hopopts_input() ensures that mbuf is contiguous */
 	hbh = (struct ip6_hbh *)(ip6 + 1);
 	*nxt = hbh->ip6h_nxt;
@@ -760,8 +745,11 @@ passin:
 	 * We don't support Jumbograms, reject packets with plen == 0 as early
 	 * as we can.
 	 */
-	if (plen == 0)
+	if (__predict_false(plen == 0)) {
+		IP6STAT_INC(ip6s_tooshort);
+		in6_ifstat_inc(rcvif, ifs6_in_hdrerr);
 		goto bad;
+	}
 
 	/*
 	 * Disambiguate address scope zones (if there is ambiguity).