? share/man/man9/obj Index: share/man/man9/Makefile =================================================================== RCS file: /cvs/src/share/man/man9/Makefile,v retrieving revision 1.255 diff -u -p -r1.255 Makefile --- share/man/man9/Makefile 20 Nov 2015 11:15:07 -0000 1.255 +++ share/man/man9/Makefile 20 Nov 2015 13:11:18 -0000 @@ -273,7 +273,8 @@ MLINKS+=ml_init.9 ml_enqueue.9 ml_init.9 ml_init.9 ml_enlist.9 ml_init.9 ml_dechain.9 \ ml_init.9 ml_filter.9 ml_init.9 ml_len.9 ml_init.9 ml_empty.9 \ ml_init.9 ml_purge.9 \ - ml_init.9 MBUF_LIST_INITIALIZER.9 ml_init.9 MBUF_LIST_FOREACH.9 + ml_init.9 MBUF_LIST_INITIALIZER.9 ml_init.9 MBUF_LIST_FIRST.9 \ + ml_init.9 MBUF_LIST_NEXT.9 ml_init.9 MBUF_LIST_FOREACH.9 MLINKS+=mountroothook_establish.9 mountroothook_disestablish.9 MLINKS+=mutex.9 mtx_init.9 mutex.9 mtx_enter.9 mutex.9 mtx_leave.9 \ mutex.9 MUTEX_ASSERT_LOCKED.9 mutex.9 MUTEX_ASSERT_UNLOCKED.9 \ Index: share/man/man9/ml_init.9 =================================================================== RCS file: /cvs/src/share/man/man9/ml_init.9,v retrieving revision 1.8 diff -u -p -r1.8 ml_init.9 --- share/man/man9/ml_init.9 2 Nov 2015 09:21:48 -0000 1.8 +++ share/man/man9/ml_init.9 20 Nov 2015 13:11:18 -0000 @@ -27,6 +27,8 @@ .Nm ml_len , .Nm ml_empty , .Nm MBUF_LIST_INITIALIZER , +.Nm MBUF_LIST_FIRST , +.Nm MBUF_LIST_NEXT , .Nm MBUF_LIST_FOREACH .Nd mbuf list API .Sh SYNOPSIS @@ -57,6 +59,10 @@ .Fn ml_purge "struct mbuf_list *ml" .Ft struct mbuf_list .Fn MBUF_LIST_INITIALIZER +.Ft struct mbuf * +.Fn MBUF_LIST_FIRST "struct mbuf_list *ml" +.Ft struct mbuf * +.Fn MBUF_LIST_NEXT "struct mbuf *m" .Fn MBUF_LIST_FOREACH "struct mbuf_list *ml" "VARNAME" .Sh DESCRIPTION The mbuf list API provides implementations of data structures and operations @@ -138,6 +144,13 @@ mbuf list is empty. Free all the mbufs on the .Fa ml mbuf list. +.It Fn MBUF_LIST_FIRST "struct mbuf_list *ml" +Access the first mbuf in the +.Fa ml +mbuf list for traversal. +.It Fn MBUF_LIST_NEXT "struct mbuf *m" +Access the next mbuf in the mbuf list after +.Fa m . .It Fn MBUF_LIST_FOREACH "struct mbuf_list *ml" "VARNAME" A convenience macro that can be used to iterate over the contents of the .Fa ml @@ -158,6 +171,8 @@ Note that it is unsafe to modify the lis .Fn ml_empty , .Fn ml_purge , .Fn MBUF_LIST_INITIALIZER , +.Fn MBUF_LIST_FIRST , +.Fn MBUF_LIST_NEXT , and .Fn MBUF_LIST_FOREACH can be called during autoconf, from process context, or from interrupt context. @@ -190,5 +205,15 @@ return a non-zero value if the list is e .Pp .Fn ml_purge returns the number of mbufs that were freed. +.Pp +.Fn MBUF_LIST_FIRST +returns the first mbuf in the mbuf list, or +.Dv NULL +if the list is empty. +.Pp +.Fn MBUF_LIST_NEXT +returns the next mbuf in the mbuf list, or +.Dv NULL +if the end of the list has been reached. .Sh SEE ALSO .Xr mbuf 9 Index: sys/sys/mbuf.h =================================================================== RCS file: /cvs/src/sys/sys/mbuf.h,v retrieving revision 1.203 diff -u -p -r1.203 mbuf.h --- sys/sys/mbuf.h 20 Nov 2015 03:35:23 -0000 1.203 +++ sys/sys/mbuf.h 20 Nov 2015 13:11:19 -0000 @@ -504,8 +504,13 @@ unsigned int ml_purge(struct mbuf_list #define ml_len(_ml) ((_ml)->ml_len) #define ml_empty(_ml) ((_ml)->ml_len == 0) -#define MBUF_LIST_FOREACH(_ml, _m) \ - for ((_m) = (_ml)->ml_head; (_m) != NULL; (_m) = (_m)->m_nextpkt) +#define MBUF_LIST_FIRST(_ml) ((_ml)->ml_head) +#define MBUF_LIST_NEXT(_m) ((_m)->m_nextpkt) + +#define MBUF_LIST_FOREACH(_ml, _m) \ + for ((_m) = MBUF_LIST_FIRST(_ml); \ + (_m) != NULL; \ + (_m) = MBUF_LIST_NEXT(_m)) /* * mbuf queues