git: f16c8e3dda5d - stable/15 - LinuxKPI: skbuff: improve debugging

Bjoern A. Zeeb <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a66a1fa.26d3a.12d98a5c__36004.6346251451$1785111112$gmane$org@gitrepo.freebsd.org>
The branch stable/15 has been updated by bz:

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

commit f16c8e3dda5da9bb0d0e4504b70647d8f0ad5301
Author:     Bjoern A. Zeeb <[email protected]>
AuthorDate: 2026-02-03 22:13:24 +0000
Commit:     Bjoern A. Zeeb <[email protected]>
CommitDate: 2026-07-26 16:48:00 +0000

    LinuxKPI: skbuff: improve debugging
    
    Deal with SKB_TRACE_FMT optional arguments; while here properly indent.
    
    Add KASSERT to __skb_unlink() to catch incorrect skbuffs encountered
    while debugging a wireless driver (which had other pre-conditions failing).
    
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit e5bcf7b99fcbe06d381525ffdd5027b846cdc1d3)
---
 sys/compat/linuxkpi/common/include/linux/skbuff.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/skbuff.h b/sys/compat/linuxkpi/common/include/linux/skbuff.h
index c43d6daff5ee..3133944ed72e 100644
--- a/sys/compat/linuxkpi/common/include/linux/skbuff.h
+++ b/sys/compat/linuxkpi/common/include/linux/skbuff.h
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2020-2025 The FreeBSD Foundation
+ * Copyright (c) 2020-2026 The FreeBSD Foundation
  * Copyright (c) 2021-2025 Bjoern A. Zeeb
  *
  * This software was developed by Björn Zeeb under sponsorship from
@@ -74,9 +74,9 @@ extern int linuxkpi_debug_skb;
     if (linuxkpi_debug_skb & DSKB_TRACE)				\
 	printf("SKB_TRACE %s:%d %p, %p\n", __func__, __LINE__, _s, _p)
 #define	SKB_TRACE_FMT(_s, _fmt, ...)					\
-   if (linuxkpi_debug_skb & DSKB_TRACE)					\
+    if ((linuxkpi_debug_skb & DSKB_TRACE) != 0)				\
 	printf("SKB_TRACE %s:%d %p " _fmt "\n", __func__, __LINE__, _s,	\
-	    __VA_ARGS__)
+	    ##__VA_ARGS__)
 #else
 #define	SKB_TODO()		do { } while(0)
 #define	SKB_IMPROVE(...)	do { } while(0)
@@ -653,6 +653,8 @@ __skb_unlink(struct sk_buff *skb, struct sk_buff_head *q)
 	WRITE_ONCE(q->qlen, q->qlen - 1);
 	p = skb->prev;
 	n = skb->next;
+	KASSERT(p != NULL && n != NULL,
+	    ("%s: skb %p q %p p %p n %p\n", __func__, skb, q, p, n));
 	WRITE_ONCE(n->prev, p);
 	WRITE_ONCE(p->next, n);
 	skb->prev = skb->next = NULL;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.