[PATCH 08/20] headers: add dropreason-core.h backport for kernels < 5.17

Yi Cong <[email protected]> Wed, 24 Jun 2026 15:38:32 +0800
Newsgroups org.kernel.vger.backports
Message-ID <[email protected]>
From: Yi Cong <[email protected]>

The skb drop reason infrastructure was introduced in v5.17. Provide
minimal enum skb_drop_reason definitions (SKB_NOT_DROPPED_YET,
SKB_CONSUMED) and SKB_DROP_REASON_SUBSYS_SHIFT/MASK constants so that
mac80211 drop.h compiles on older kernels.

Signed-off-by: Yi Cong <[email protected]>
---
 .../backport-include/net/dropreason-core.h    | 34 +++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 backport/backport-include/net/dropreason-core.h

diff --git a/backport/backport-include/net/dropreason-core.h b/backport/backport-include/net/dropreason-core.h
new file mode 100644
index 00000000..2b02a8f1
--- /dev/null
+++ b/backport/backport-include/net/dropreason-core.h
@@ -0,0 +1,34 @@
+#ifndef __BACKPORT_NET_DROPREASON_CORE_H
+#define __BACKPORT_NET_DROPREASON_CORE_H
+#include <linux/version.h>
+
+/*
+ * On kernels >= 5.17, enum skb_drop_reason and the related helpers exist
+ * in the kernel's own skbuff.h / dropreason-core.h.  For older kernels we
+ * provide minimal definitions so that backported wireless drivers compile.
+ */
+#if LINUX_VERSION_IS_LESS(5,17,0)
+
+/**
+ * enum skb_drop_reason - reasons an sk_buff was dropped
+ *
+ * This is a minimal backport that only defines the few values used by
+ * the mac80211 subsystem.  The full upstream enum is much larger.
+ */
+enum skb_drop_reason {
+	SKB_NOT_DROPPED_YET = 0,
+	SKB_CONSUMED,
+	SKB_DROP_REASON_NOT_SPECIFIED,
+};
+
+/*
+ * Subsystem support was added in 6.0.  For kernels between 5.17 and 6.0
+ * the subsys fields do not exist; for kernels < 5.17 we define them here
+ * so that the mac80211 drop.h header compiles.
+ */
+#define SKB_DROP_REASON_SUBSYS_SHIFT		16
+#define SKB_DROP_REASON_SUBSYS_MASK		0xffff0000
+
+#endif /* < 5.17 */
+
+#endif /* __BACKPORT_NET_DROPREASON_CORE_H */
-- 
2.43.0