git: c9599b80015a - main - ktls: Take the receiving interface of each packet in sbappend_ktls_rx()

From: Olivier Cochard <olivier_at_FreeBSD.org>
Date: Fri, 16 Oct 2026 04:40:10 UTC
The branch main has been updated by olivier:

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

commit c9599b80015a50e66c907dc667334a53bc234dab
Author:     Olivier Cochard <olivier@FreeBSD.org>
AuthorDate: 2026-10-16 04:32:29 +0000
Commit:     Olivier Cochard <olivier@FreeBSD.org>
CommitDate: 2026-10-16 04:35:39 +0000

    ktls: Take the receiving interface of each packet in sbappend_ktls_rx()
    
    sbappend_ktls_rx() read the receiving interface of each packet header it
    demotes from the chain's first mbuf, whose header it had zeroed on the first
    pass. A chain of two packets or more thus had no interface, and a change of
    input interface went unnoticed: the TLS receive tag stayed on the old interface
    until a later append of one packet.
    Read it from the packet being demoted, as the decrypted mark is.
    
    Fixes: fe8c78f0d202 ("ktls: Add full support for TLS RX offloading via network interface.")
    
    Approved by:    gallatin
    Sponsored by:   Netflix
    Differential Revision:  https://reviews.freebsd.org/D60758
---
 sys/kern/uipc_sockbuf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c
index 745702bd4a4f..d69fe5bf66c6 100644
--- a/sys/kern/uipc_sockbuf.c
+++ b/sys/kern/uipc_sockbuf.c
@@ -1008,7 +1008,7 @@ sbappend_ktls_rx(struct sockbuf *sb, struct mbuf *m)
 	/* Remove all packet headers and mbuf tags to get a pure data chain. */
 	for (n = m; n != NULL; n = n->m_next) {
 		if (n->m_flags & M_PKTHDR) {
-			ifp = m->m_pkthdr.leaf_rcvif;
+			ifp = n->m_pkthdr.leaf_rcvif;
 			if ((n->m_pkthdr.csum_flags & CSUM_TLS_MASK) ==
 			    CSUM_TLS_DECRYPTED) {
 				/* Mark all mbufs in this packet decrypted. */