[PATCH 04/10] RDMA: Add ib_is_udata_in_empty()

Jason Gunthorpe
2026-02-06T01:51:42Z

If the driver doesn't yet support any request driver data it should check
that it is all zeroed. This is a common pattern, add a helper to do this.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
include/rdma/ib_verbs.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index c0dd82a77e7a13..973d9ec6875e63 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -3119,6 +3119,20 @@ static inline bool ib_is_udata_cleared(struct ib_udata *udata,
return ib_is_buffer_cleared(udata->inbuf + offset, len);
}

+/**
+ * ib_is_udata_in_empty - Check if the udata is empty
+ * @udata: The system calls ib_udata struct
+ *
+ * This should be used if the driver does not currently define a driver data
+ * struct.
+ */
+static inline bool ib_is_udata_in_empty(struct ib_udata *udata)
+{
+ if (udata && udata->inlen != 0)
+ return ib_is_buffer_cleared(udata->inbuf, udata->inlen);
+ return true;
+}
+
static inline int _ib_copy_validate_udata_in(struct ib_udata *udata, void *req,
size_t kernel_size,
size_t minimum_size)
--
2.43.0