|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCH v4 05/11] lib/uknetdev: Netbuf headroom and tailroom helpers
Hello Simon,There are minor typos in the comments which can be fixed while we pushing them. Please find them inline Reviewed-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx> On 10/10/2018 02:00 PM, Simon Kuenzer wrote: Introduce helpers for calculating available headroom and tailroom on a Netbuf's data buffer. A header manipulation function is added to simplify prepending bytes to the packet data or claiming bytes back to the headroom. Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx> --- lib/uknetdev/include/uk/netbuf.h | 86 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/lib/uknetdev/include/uk/netbuf.h b/lib/uknetdev/include/uk/netbuf.h index 5b0907c..0f8f6a3 100644 --- a/lib/uknetdev/include/uk/netbuf.h +++ b/lib/uknetdev/include/uk/netbuf.h @@ -308,6 +308,18 @@ static inline struct uk_netbuf *uk_netbuf_ref_single(struct uk_netbuf *m) }/** replace m with head replace m with head + /* m has to be the first element of a netbuf chain. */ + UK_ASSERT(head->prev == NULL); + + /* If len > 0, we take bytes from the headroom and add + * them to data. We are limited to the available headroom size. + * If len < 0, we return bytes back to the headroom. + * We are limited to the available data length. + */ + if (unlikely((len > (ssize_t) uk_netbuf_headroom(head)) + || (-len > head->len))) + return -ENOSPC; + + /* We should never make the packet bigger than 64kB */ + if (unlikely((int32_t) len + (int32_t) head->len + > (int32_t) UINT16_MAX)) + return -EFAULT; + + head->data -= len; + head->len += len; + return 1; +} + #ifdef __cplusplus } #endif Thanks & Regards Sharan _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |