NETMAP and off-by-one?

Luigi Rizzo rizzo at iet.unipi.it
Fri Nov 13 23:40:07 UTC 2015


On Fri, Nov 13, 2015 at 1:30 PM, Slawa Olhovchenkov <slw at zxy.spb.ru> wrote:
> I am see strange things: like NETMAP stop transmit after `head` and `cur`
> touch `tail`.
>
> But:
>
> /*
>  * check if space is available in the ring.
>  */
> static inline int
> nm_ring_empty(struct netmap_ring *ring)
> {
>         return (ring->cur == ring->tail);
> }
>
> i.e. if cur == (tail-1) mod ring_size -- space is available in the
> ring and I can put packet in output buffer.

The design requires to leave at least one empty slot in the buffer.
The name of the function is correct, the comment is probably not,
unless a bug has creeped in recently the code was very careful
in not using the free slot that separates the two regions.

cheers
luigi

> After put this packet ring is full, but no transmiting.
>
> This is bug?
> _______________________________________________
> freebsd-stable at freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-stable
> To unsubscribe, send any mail to "freebsd-stable-unsubscribe at freebsd.org"



-- 
-----------------------------------------+-------------------------------
 Prof. Luigi RIZZO, rizzo at iet.unipi.it  . Dip. di Ing. dell'Informazione
 http://www.iet.unipi.it/~luigi/        . Universita` di Pisa
 TEL      +39-050-2217533               . via Diotisalvi 2
 Mobile   +39-338-6809875               . 56122 PISA (Italy)
-----------------------------------------+-------------------------------


More information about the freebsd-stable mailing list