Index | Thread | Search

From:
Claudio Jeker <cjeker@diehard.n-r-g.com>
Subject:
Re: ddb mbuf chains
To:
Alexander Bluhm <bluhm@openbsd.org>
Cc:
Vitaliy Makkoveev <mvs@openbsd.org>, tech@openbsd.org
Date:
Tue, 10 Sep 2024 15:34:13 +0200

Download raw body.

Thread
On Fri, Sep 06, 2024 at 05:11:33PM +0200, Alexander Bluhm wrote:
> On Thu, Sep 05, 2024 at 10:29:21AM +0300, Vitaliy Makkoveev wrote:
> > > > > Additionally we can print mbuf type and offset.  Then a UDP receive
> > > > > socket buffer looks like this:
> > > > > 
> > > > > ++- mbuf 0xfffffd806dcddd00, nam, off 0, len 16
> > > > > |+- mbuf 0xfffffd806dcddf00, dat, off 52, len 1472, pktlen 2049, clsize 2048
> > > > > |+- mbuf 0xfffffd806dcdd400, dat, off 44, len 577, clsize 2048
> > > > > |\- total chain 3, len 2065, size 4320
> > > > > ++- mbuf 0xfffffd806dcdde00, nam, off 0, len 16
> > > > > |+- mbuf 0xfffffd806dcdd800, dat, off 52, len 4, pktlen 4, clsize 2048
> > > > > |\- total chain 2, len 20, size 2272
> > > > > \-- total packets 2
> 
> I would like to print mbuf size also for non cluster.
> 
> ddb> show mbuf /c 0xfffffd807c113000
> -+- mbuf 0xfffffd807c113000, nam, off 0, len 28, size 224
>  \- total chain 1, len 28, size 224
> 
> Prototype for m_print_chain() is in ddb/db_interface.h.  By including
> it, compiler checks that it matches the implementation.
> 
> ok?
> 
> bluhm
> 
> Index: kern/uipc_mbuf.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/kern/uipc_mbuf.c,v
> diff -u -p -r1.292 uipc_mbuf.c
> --- kern/uipc_mbuf.c	5 Sep 2024 08:52:27 -0000	1.292
> +++ kern/uipc_mbuf.c	6 Sep 2024 14:56:35 -0000
> @@ -90,6 +90,7 @@
>  
>  #ifdef DDB
>  #include <machine/db_machdep.h>
> +#include <ddb/db_interface.h>
>  #endif
>  
>  #if NPF > 0
> @@ -1567,6 +1568,9 @@ m_print_chain(void *v, int deep,
>  			(*pr)(", pktlen %d", m->m_pkthdr.len);
>  		if (m->m_flags & M_EXT)
>  			(*pr)(", clsize %u", m->m_ext.ext_size);
> +		else
> +			(*pr)(", size %u",
> +			    m->m_flags & M_PKTHDR ? MHLEN : MLEN);
>  		(*pr)("\n");
>  		indent = deep ? "|+-" : " +-";
>  	}

This fails on sparc64:
/sys/kern/uipc_mbuf.c: In function 'm_print_chain':
/sys/kern/uipc_mbuf.c:1573: warning: format '%u' expects type 'unsigned
int', but argument 2 has type 'long unsigned int'
 
Both MHLEN and MLEN use sizeof in their definition and require therefor a
%zu fromat string. Surprised this didn't trigger on amd64.

-- 
:wq Claudio