Subject: Re: status of the mbuf API SoC project
To: None <firstname.lastname@example.org>
From: Pavel Cahyna <email@example.com>
Date: 09/04/2006 08:56:40
On Mon, Sep 04, 2006 at 12:43:01AM -0400, der Mouse wrote:
> > 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.
Good question. The m_datarange function in fact has an alignment argument
in form of the flags - there are flags to request 16-bit, 32-bit and
64-bit alignment. The macros should IMHO do this automatically by
analyzing the type - there is a __builtin_offsetof function in gcc for
that. (I haven't implemented this yet.) But most of network headers are
declared as __packed, which means that there is no alignment required.
(Perhaps this should be changed after the ability to ensure correct
alignment is added to the macros.)