git: 4a36455c4179 - stable/13 - Factor out flags preserved during mbuf demote into a separate define.

From: Hans Petter Selasky <hselasky_at_FreeBSD.org>
Date: Fri, 12 Nov 2021 14:36:58 UTC
The branch stable/13 has been updated by hselasky:

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

commit 4a36455c417978a3f7cc62c0e8e05935ab503373
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2021-11-04 17:48:23 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2021-11-12 14:33:54 +0000

    Factor out flags preserved during mbuf demote into a separate define.
    
    This define will later on be used by coming TLS RX hardware offload patches.
    
    No functional change intended.
    
    Reviewed by:    jhb@
    Sponsored by:   NVIDIA Networking
    
    (cherry picked from commit dd31400c3c2aa941d057e78296c193959a6d9ed3)
---
 sys/kern/uipc_mbuf.c | 5 +++--
 sys/sys/mbuf.h       | 6 ++++++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 5588da2dcd20..4fa94fb3019e 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -268,13 +268,14 @@ m_demote(struct mbuf *m0, int all, int flags)
 {
 	struct mbuf *m;
 
+	flags |= M_DEMOTEFLAGS;
+
 	for (m = all ? m0 : m0->m_next; m != NULL; m = m->m_next) {
 		KASSERT(m->m_nextpkt == NULL, ("%s: m_nextpkt in m %p, m0 %p",
 		    __func__, m, m0));
 		if (m->m_flags & M_PKTHDR)
 			m_demote_pkthdr(m);
-		m->m_flags = m->m_flags & (M_EXT | M_RDONLY | M_NOFREE |
-		    M_EXTPG | flags);
+		m->m_flags &= flags;
 	}
 }
 
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index 640856016e0e..9f84d0758bc6 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -494,6 +494,12 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff)
     (M_PKTHDR|M_EOR|M_RDONLY|M_BCAST|M_MCAST|M_PROMISC|M_VLANTAG|M_TSTMP| \
      M_TSTMP_HPREC|M_TSTMP_LRO|M_PROTOFLAGS)
 
+/*
+ * Flags preserved during demote.
+ */
+#define	M_DEMOTEFLAGS \
+    (M_EXT | M_RDONLY | M_NOFREE | M_EXTPG)
+
 /*
  * Mbuf flag description for use with printf(9) %b identifier.
  */