Date: Fri, 2 Nov 2012 16:38:17 +0400 From: Gleb Smirnoff <glebius@FreeBSD.org> To: net@FreeBSD.org Subject: splitting m_flags to pkthdr.flags + m_flags Message-ID: <20121102123817.GP70741@FreeBSD.org>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Hello networkers,
some (most) of m_flags bits are describing features that can
be present on a packet only, not on a single mbuf. Since we are
close to exhaustion of available bits, and many subsystems prefer
to use one of M_PROTO bits instead of grabbing a flag, I propose
to split m_flags to two parts:
In the m_flags remain:
#define M_EXT 0x00000001 /* has associated external storage */
#define M_PKTHDR 0x00000002 /* start of record */
#define M_EOR 0x00000004 /* end of record */
#define M_RDONLY 0x00000008 /* associated data is marked read-only */
and all M_PROTO flags.
struct pkthdr grows by one word and its new flag word now
posesses:
#define M_BCAST 0x00000200 /* send/received as link-level broadcast */
#define M_MCAST 0x00000400 /* send/received as link-level multicast */
#define M_FRAG 0x00000800 /* packet is a fragment of a larger packet */
#define M_FIRSTFRAG 0x00001000 /* packet is first fragment */
#define M_LASTFRAG 0x00002000 /* packet is last fragment */
#define M_SKIP_FIREWALL 0x00004000 /* skip firewall processing */
#define M_VLANTAG 0x00010000 /* ether_vtag is valid */
#define M_PROMISC 0x00020000 /* packet was not for us */
#define M_FLOWID 0x00400000 /* deprecated: flowid is valid */
#define M_HASHTYPEBITS 0x0F000000 /* mask of bits holding flowid hash type */
Some M_PROTO abusements like M_FASTFWD_OURS and recently added M_IP_NEXTHOP
also go to the pkthdr mbuf flags.
P.S.
An attentive reader may have noticed that I missed M_NOFREE and M_FREELIST.
Yep, these flags coming from historical mbuf allocator from FreeBSD 4.x times
are about to be deleted, we carefully examine them, but never set. Patch
for review attached.
--
Totus tuus, Glebius.
[-- Attachment #2 --]
Index: share/man/man9/mbuf.9
===================================================================
--- share/man/man9/mbuf.9 (revision 242471)
+++ share/man/man9/mbuf.9 (working copy)
@@ -215,7 +215,6 @@
#define M_PROTO4 0x0080 /* protocol-specific */
#define M_PROTO5 0x0100 /* protocol-specific */
#define M_PROTO6 0x4000 /* protocol-specific (avoid M_BCAST conflict) */
-#define M_FREELIST 0x8000 /* mbuf is on the free list */
/* mbuf pkthdr flags (also stored in m_flags) */
#define M_BCAST 0x0200 /* send/received as link-level broadcast */
Index: sys/sys/mbuf.h
===================================================================
--- sys/sys/mbuf.h (revision 242471)
+++ sys/sys/mbuf.h (working copy)
@@ -192,10 +192,10 @@
#define M_FIRSTFRAG 0x00001000 /* packet is first fragment */
#define M_LASTFRAG 0x00002000 /* packet is last fragment */
#define M_SKIP_FIREWALL 0x00004000 /* skip firewall processing */
-#define M_FREELIST 0x00008000 /* mbuf is on the free list */
+/* 0x00008000 was M_FREELIST */
#define M_VLANTAG 0x00010000 /* ether_vtag is valid */
#define M_PROMISC 0x00020000 /* packet was not for us */
-#define M_NOFREE 0x00040000 /* do not free mbuf, embedded in cluster */
+/* 0x00040000 was M_NOFREE */
#define M_PROTO6 0x00080000 /* protocol-specific */
#define M_PROTO7 0x00100000 /* protocol-specific */
#define M_PROTO8 0x00200000 /* protocol-specific */
@@ -650,7 +650,7 @@
if (m->m_flags & M_EXT)
mb_free_ext(m);
- else if ((m->m_flags & M_NOFREE) == 0)
+ else
uma_zfree(zone_mbuf, m);
return (n);
}
Index: sys/kern/uipc_mbuf.c
===================================================================
--- sys/kern/uipc_mbuf.c (revision 242471)
+++ sys/kern/uipc_mbuf.c (working copy)
@@ -210,17 +210,10 @@
void
mb_free_ext(struct mbuf *m)
{
- int skipmbuf;
KASSERT((m->m_flags & M_EXT) == M_EXT, ("%s: M_EXT not set", __func__));
KASSERT(m->m_ext.ref_cnt != NULL, ("%s: ref_cnt not set", __func__));
-
- /*
- * check if the header is embedded in the cluster
- */
- skipmbuf = (m->m_flags & M_NOFREE);
-
/* Free attached storage if this mbuf is the only reference to it. */
if (*(m->m_ext.ref_cnt) == 1 ||
atomic_fetchadd_int(m->m_ext.ref_cnt, -1) == 1) {
@@ -261,8 +254,6 @@
("%s: unknown ext_type", __func__));
}
}
- if (skipmbuf)
- return;
/*
* Free this mbuf back to the mbuf zone with all m_ext
@@ -327,7 +318,7 @@
m_freem(m->m_nextpkt);
m->m_nextpkt = NULL;
}
- m->m_flags = m->m_flags & (M_EXT|M_RDONLY|M_FREELIST|M_NOFREE);
+ m->m_flags = m->m_flags & (M_EXT|M_RDONLY);
}
}
Index: sys/kern/kern_mbuf.c
===================================================================
--- sys/kern/kern_mbuf.c (revision 242471)
+++ sys/kern/kern_mbuf.c (working copy)
@@ -443,7 +443,6 @@
if ((flags & MB_NOTAGS) == 0 && (m->m_flags & M_PKTHDR) != 0)
m_tag_delete_chain(m, NULL);
KASSERT((m->m_flags & M_EXT) == 0, ("%s: M_EXT set", __func__));
- KASSERT((m->m_flags & M_NOFREE) == 0, ("%s: M_NOFREE set", __func__));
#ifdef INVARIANTS
trash_dtor(mem, size, arg);
#endif
Index: sys/dev/bce/if_bce.c
===================================================================
--- sys/dev/bce/if_bce.c (revision 242471)
+++ sys/dev/bce/if_bce.c (working copy)
@@ -9878,7 +9878,7 @@
"csum_flags = %b\n", mp->m_pkthdr.len,
mp->m_flags, "\20\12M_BCAST\13M_MCAST\14M_FRAG"
"\15M_FIRSTFRAG\16M_LASTFRAG\21M_VLANTAG"
- "\22M_PROMISC\23M_NOFREE",
+ "\22M_PROMISC",
mp->m_pkthdr.csum_flags,
"\20\1CSUM_IP\2CSUM_TCP\3CSUM_UDP\4CSUM_IP_FRAGS"
"\5CSUM_FRAGMENT\6CSUM_TSO\11CSUM_IP_CHECKED"
Index: sys/dev/bxe/if_bxe.c
===================================================================
--- sys/dev/bxe/if_bxe.c (revision 242471)
+++ sys/dev/bxe/if_bxe.c (working copy)
@@ -16279,7 +16279,7 @@
"csum_flags = %b\n", m->m_pkthdr.len,
m->m_flags, "\20\12M_BCAST\13M_MCAST\14M_FRAG"
"\15M_FIRSTFRAG\16M_LASTFRAG\21M_VLANTAG"
- "\22M_PROMISC\23M_NOFREE",
+ "\22M_PROMISC",
m->m_pkthdr.csum_flags,
"\20\1CSUM_IP\2CSUM_TCP\3CSUM_UDP\4CSUM_IP_FRAGS"
"\5CSUM_FRAGMENT\6CSUM_TSO\11CSUM_IP_CHECKED"
Index: sys/net80211/ieee80211_freebsd.h
===================================================================
--- sys/net80211/ieee80211_freebsd.h (revision 242471)
+++ sys/net80211/ieee80211_freebsd.h (working copy)
@@ -223,14 +223,14 @@
#define IEEE80211_MBUF_TX_FLAG_BITS \
"\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_RDONLY\5M_ENCAP\6M_WEP\7M_EAPOL" \
"\10M_PWR_SAV\11M_MORE_DATA\12M_BCAST\13M_MCAST\14M_FRAG\15M_FIRSTFRAG" \
- "\16M_LASTFRAG\17M_SKIP_FIREWALL\20M_FREELIST\21M_VLANTAG\22M_PROMISC" \
- "\23M_NOFREE\24M_FF\25M_TXCB\26M_AMPDU_MPDU\27M_FLOWID"
+ "\16M_LASTFRAG\17M_SKIP_FIREWALL\21M_VLANTAG\22M_PROMISC" \
+ "\24M_FF\25M_TXCB\26M_AMPDU_MPDU\27M_FLOWID"
#define IEEE80211_MBUF_RX_FLAG_BITS \
"\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_RDONLY\5M_AMPDU\6M_WEP\7M_PROTO3" \
"\10M_PROTO4\11M_PROTO5\12M_BCAST\13M_MCAST\14M_FRAG\15M_FIRSTFRAG" \
- "\16M_LASTFRAG\17M_SKIP_FIREWALL\20M_FREELIST\21M_VLANTAG\22M_PROMISC" \
- "\23M_NOFREE\24M_PROTO6\25M_PROTO7\26M_AMPDU_MPDU\27M_FLOWID"
+ "\16M_LASTFRAG\17M_SKIP_FIREWALL\21M_VLANTAG\22M_PROMISC" \
+ "\24M_PROTO6\25M_PROTO7\26M_AMPDU_MPDU\27M_FLOWID"
/*
* Store WME access control bits in the vlan tag.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20121102123817.GP70741>
