tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: m_defrag



On Sat, Sep 01, 2018 at 09:01:37PM +0200, Maxime Villard wrote:
> Le 01/09/2018 à 20:48, coypu%sdf.org@localhost a écrit :
> > Does netbsd have a version of m_defrag that does something useful, like
> > what the openbsd version does?
> > I want to have one mbuf. netbsd gives me two.
> 
> My commit message: "It is important not to compress the first mbuf with hacks,
> because the storage of this first mbuf may be shared with other mbufs". OpenBSD
> does not support shared mbufs.

OK. sorry. Thanks for explaining why I can't use OpenBSD's code.

So, to elaborate on my situation: I want m_defrag because I want the
mbuf chain to be of a length that I can bus_dmamap_load_mbuf.

I believe m_defrag is a bad API:

- Looks like OpenBSD m_defrag, which returns error, not mbuf.
(This isn't noticed in code ports, and you had to fix one driver who got
this wrong. bwfm at pci, which I ported, also gets this wrong, and this
is why it only looks like it works).

- Doesn't give me any guarantee it is a length I can use, just "tries to
  defrag it".

- Looks like other drivers open code this now because they do need a
  guarantee (like dev/ic/bwi.c:9182-9216)

FreeBSD opted to write m_collapse, which also seems appealing.
I'm a newbie to networking so it will take a while to come with a diff,
so bear with me.

Here is another case that is wrong found by taylor:
https://nxr.netbsd.org/xref/src/sys/dev/ic/rt2860.c#1784
This won't work, because rt2860 also can only handle length 1:
https://nxr.netbsd.org/xref/src/sys/dev/ic/rt2860.c#529


Home | Main Index | Thread Index | Old Index