On Sun, May 03, 2026 at 02:46:55PM +0200, Stefan Sperling wrote:
> On Wed, Dec 17, 2025 at 03:44:22PM +0100, Stefan Sperling wrote:
> > On Wed, Dec 17, 2025 at 03:37:56PM +0100, Stefan Sperling wrote:
> > > + if (frags > sc->sc_tx_frags || frags > sc->sc_tx_avail) {
> >
> > Perhaps this must check frags >= sc->sc_tx_avail to prevent the assertion
> > failure in all cases.
>
> I still have not heard from anyone about this fix. I do not use xnf myself
> and I lack a test setup for it. I will drop this diff from my pending
> queue soon if I don't hear anything.
>
> And I would need an OK from another developer to commit it.
I started reworking xnf to manage ring space like other drivers,
but I haven't got it working yet. This looks like a good fix for
the current code, and it survives some basic testing.
ok jmatthew@
>
> Context: https://marc.info/?l=openbsd-bugs&m=176598512119200&w=2
>
> commit - 179a5728e367b8eca388e404a7fbcc08b887b86c
> blob - 3c423aee2e37c66eb446889acb80c2dd19a4648a
> file + sys/dev/pv/if_xnf.c
> --- sys/dev/pv/if_xnf.c
> +++ sys/dev/pv/if_xnf.c
> @@ -564,11 +564,13 @@ xnf_encap(struct xnf_softc *sc, struct mbuf *m_head, u
> struct mbuf *m, **next;
> uint32_t oprod = *prod;
> uint16_t id;
> - int i, flags, n, used = 0;
> + int i, flags, n, used = 0, frags;
>
> - if ((xnf_fragcount(m_head) > sc->sc_tx_frags) &&
> - m_defrag(m_head, M_DONTWAIT))
> - return (ENOBUFS);
> + frags = xnf_fragcount(m_head);
> + if (frags > sc->sc_tx_frags || frags >= sc->sc_tx_avail) {
> + if (m_defrag(m_head, M_DONTWAIT))
> + return (ENOBUFS);
> + }
>
> flags = (sc->sc_domid << 16) | BUS_DMA_WRITE | BUS_DMA_NOWAIT;
>
>