Let "ddb show mbuf" print all mbuf fields in a consistent way. Move
authorbluhm <bluhm@openbsd.org>
Fri, 10 Jan 2014 00:47:17 +0000 (00:47 +0000)
committerbluhm <bluhm@openbsd.org>
Fri, 10 Jan 2014 00:47:17 +0000 (00:47 +0000)
bit field names into the header file below the definitions to keep
them in sync.
OK mikeb@ mpi@

sys/kern/uipc_mbuf.c
sys/sys/mbuf.h

index 794ec87..2ba91c2 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: uipc_mbuf.c,v 1.176 2013/11/09 06:38:42 dlg Exp $     */
+/*     $OpenBSD: uipc_mbuf.c,v 1.177 2014/01/10 00:47:17 bluhm Exp $   */
 /*     $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $   */
 
 /*
@@ -1346,32 +1346,30 @@ m_print(void *v,
        struct mbuf *m = v;
 
        (*pr)("mbuf %p\n", m);
-       (*pr)("m_type: %hi\tm_flags: %b\n", m->m_type, m->m_flags,
-           "\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_CLUSTER\5M_PROTO1\6M_VLANTAG"
-           "\7M_LOOP\10M_FILDROP\11M_BCAST\12M_MCAST\13M_CONF\14M_AUTH"
-           "\15M_TUNNEL\16M_ZEROIZE\17M_LINK0");
+       (*pr)("m_type: %hi\tm_flags: %hb\n", m->m_type, m->m_flags, M_BITS);
        (*pr)("m_next: %p\tm_nextpkt: %p\n", m->m_next, m->m_nextpkt);
        (*pr)("m_data: %p\tm_len: %u\n", m->m_data, m->m_len);
-       (*pr)("m_dat: %p m_pktdat: %p\n", m->m_dat, m->m_pktdat);
+       (*pr)("m_dat: %p\tm_pktdat: %p\n", m->m_dat, m->m_pktdat);
        if (m->m_flags & M_PKTHDR) {
-               (*pr)("m_pkthdr.len: %i\tm_ptkhdr.rcvif: %p\t"
-                   "m_ptkhdr.rdomain: %u\n", m->m_pkthdr.len,
-                   m->m_pkthdr.rcvif, m->m_pkthdr.rdomain);
-               (*pr)("m_ptkhdr.tags: %p\tm_pkthdr.tagsset: %hx\n",
-                   SLIST_FIRST(&m->m_pkthdr.tags), m->m_pkthdr.tagsset);
-               (*pr)("m_pkthdr.csum_flags: %hx\tm_pkthdr.ether_vtag: %hu\n",
-                   m->m_pkthdr.csum_flags, m->m_pkthdr.ether_vtag);
-               (*pr)("m_pkthdr.pf.flags: %b\n",
-                   m->m_pkthdr.pf.flags, "\20\1GENERATED\2FRAGCACHE"
-                   "\3TRANSLATE_LOCALHOST\4DIVERTED\5DIVERTED_PACKET"
-                   "\6PF_TAG_REROUTE");
-               (*pr)("m_pkthdr.pf.hdr: %p\tm_pkthdr.pf.statekey: %p\n",
-                   m->m_pkthdr.pf.hdr, m->m_pkthdr.pf.statekey);
-               (*pr)("m_pkthdr.pf.qid:\t%u m_pkthdr.pf.tag: %hu\n",
+               (*pr)("m_ptkhdr.rcvif: %p\tm_pkthdr.len: %i\n",
+                   m->m_pkthdr.rcvif, m->m_pkthdr.len);
+               (*pr)("m_ptkhdr.tags: %p\tm_pkthdr.tagsset: %hb\n",
+                   SLIST_FIRST(&m->m_pkthdr.tags),
+                   m->m_pkthdr.tagsset, MTAG_BITS);
+               (*pr)("m_pkthdr.csum_flags: %hb\n",
+                   m->m_pkthdr.csum_flags, MCS_BITS);
+               (*pr)("m_pkthdr.ether_vtag: %hu\tm_ptkhdr.rdomain: %u\n",
+                   m->m_pkthdr.ether_vtag, m->m_pkthdr.rdomain);
+               (*pr)("m_pkthdr.pf.hdr: %p\n",
+                   m->m_pkthdr.pf.hdr);
+               (*pr)("m_pkthdr.pf.statekey: %p\tm_pkthdr.pf.inp %p\n",
+                   m->m_pkthdr.pf.statekey, m->m_pkthdr.pf.inp);
+               (*pr)("m_pkthdr.pf.qid: %u\tm_pkthdr.pf.tag: %hu\n",
                    m->m_pkthdr.pf.qid, m->m_pkthdr.pf.tag);
-               (*pr)("m_pkthdr.pf.prio:\t%u m_pkthdr.pf.tag: %hu\n",
-                   m->m_pkthdr.pf.prio, m->m_pkthdr.pf.tag);
-               (*pr)("m_pkthdr.pf.routed: %hx\n", m->m_pkthdr.pf.routed);
+               (*pr)("m_pkthdr.pf.flags: %hhb\n",
+                   m->m_pkthdr.pf.flags, MPF_BITS);
+               (*pr)("m_pkthdr.pf.routed: %hhu\tm_pkthdr.pf.prio: %hhu\n",
+                   m->m_pkthdr.pf.routed, m->m_pkthdr.pf.prio);
        }
        if (m->m_flags & M_EXT) {
                (*pr)("m_ext.ext_buf: %p\tm_ext.ext_size: %u\n",
index cc4a973..48fd183 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: mbuf.h,v 1.169 2013/11/15 16:15:42 bluhm Exp $        */
+/*     $OpenBSD: mbuf.h,v 1.170 2014/01/10 00:47:17 bluhm Exp $        */
 /*     $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $       */
 
 /*
@@ -102,6 +102,12 @@ struct pkthdr_pf {
 #define        PF_TAG_REFRAGMENTED             0x40    /* refragmented ipv6 packet */
 #define        PF_TAG_PROCESSED                0x80    /* packet was checked by pf */
 
+#ifdef _KERNEL
+#define MPF_BITS \
+    ("\20\1GENERATED\3TRANSLATE_LOCALHOST\4DIVERTED\5DIVERTED_PACKET" \
+    "\6REROUTE\7REFRAGMENTED\10PROCESSED")
+#endif
+
 /* record/packet header in first mbuf of chain; valid if M_PKTHDR set */
 struct pkthdr {
        struct ifnet            *rcvif;         /* rcv interface */
@@ -180,6 +186,13 @@ struct mbuf {
 #define M_COMP         0x4000  /* header was decompressed */
 #define M_LINK0                0x8000  /* link layer specific flag */
 
+#ifdef _KERNEL
+#define M_BITS \
+    ("\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_CLUSTER\5M_PROTO1\6M_VLANTAG\7M_LOOP" \
+    "\10M_FILDROP\11M_BCAST\12M_MCAST\13M_CONF\14M_AUTH\15M_TUNNEL" \
+    "\16M_ZEROIZE\17M_COMP\20M_LINK0")
+#endif
+
 /* flags copied when copying m_pkthdr */
 #define        M_COPYFLAGS     (M_PKTHDR|M_EOR|M_PROTO1|M_BCAST|M_MCAST|M_CONF|M_COMP|\
                         M_AUTH|M_LOOP|M_TUNNEL|M_LINK0|M_VLANTAG|M_FILDROP|\
@@ -199,6 +212,13 @@ struct mbuf {
 #define        M_ICMP_CSUM_IN_OK       0x0400  /* ICMP checksum verified */
 #define        M_ICMP_CSUM_IN_BAD      0x0800  /* ICMP checksum bad */
 
+#ifdef _KERNEL
+#define MCS_BITS \
+    ("\20\1IPV4_CSUM_OUT\2TCP_CSUM_OUT\3UDP_CSUM_OUT\4IPV4_CSUM_IN_OK" \
+    "\5IPV4_CSUM_IN_BAD\6TCP_CSUM_IN_OK\7TCP_CSUM_IN_BAD\10UDP_CSUM_IN_OK" \
+    "\11UDP_CSUM_IN_BAD\12ICMP_CSUM_OUT\13ICMP_CSUM_IN_OK\14ICMP_CSUM_IN_BAD")
+#endif
+
 /* mbuf types */
 #define        MT_FREE         0       /* should be on free list */
 #define        MT_DATA         1       /* dynamic (data) allocation */
@@ -457,6 +477,11 @@ struct m_tag *m_tag_next(struct mbuf *, struct m_tag *);
 #define PACKET_TAG_SRCROUTE            0x1000 /* IPv4 source routing options */
 #define PACKET_TAG_TUNNEL              0x2000  /* Tunnel endpoint address */
 
+#define MTAG_BITS \
+    ("\20\1IPSEC_IN_DONE\2IPSEC_OUT_DONE\3IPSEC_IN_CRYPTO_DONE" \
+    "\4IPSEC_OUT_CRYPTO_NEEDED\5IPSEC_PENDING_TDB\6BRIDGE\7GIF\10GRE\11DLT" \
+    "\12PF_DIVERT\13PIPEX\14PF_REASSEMBLED\15SRCROUTE\16TUNNEL")
+
 /*
  * Maximum tag payload length (that is excluding the m_tag structure).
  * Please make sure to update this value when increasing the payload