Subject: Re: status of the mbuf API SoC project
To: None <tech-net@NetBSD.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-net
Date: 09/04/2006 00:43:01
> I've added two macros to replace mtod: mptr and mptr_rw.

> const datatype *
> mptr(struct mbuf **mp, datatype, int off, int flags);

> [...and three others...]

> differences from mtod:

> - the new macros accept an offset, to access structures which are not
>   at the beginning of the packet.

Shouldn't a redesign of mtod also include a way to deal with the
alignment issue?  I've seen code all over the place that blindly
assumes a pointer returned from mtod is correctly aligned, something
which has bit me more than once.  Yet I see no alignment argument to
these macros.

Do they simply not address the issue at all, leaving it up to the
caller to ensure that whatever stores the relevant number of bytes at
the relevant offset is correctly aligned?  I can't see how they could,
when part of the function's interface is that it may rearrange the mbuf
chain (which mtod sidestepped by leaving that up to its caller).

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B