diff options
| author | Jason Gunthorpe <jgg@nvidia.com> | 2026-03-03 22:50:03 +0300 |
|---|---|---|
| committer | Jason Gunthorpe <jgg@nvidia.com> | 2026-03-08 13:20:25 +0300 |
| commit | 4c379ba04c110ba55182535140fda3a7f285d597 (patch) | |
| tree | df686953895b4f373cdb98a24b4c9df7584c7275 /include | |
| parent | 14badc323ed7153c24a0a9c3175e594aaf1366c9 (diff) | |
| download | linux-4c379ba04c110ba55182535140fda3a7f285d597.tar.xz | |
RDMA: Add ib_is_udata_in_empty()
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 around
_ib_copy_validate_udata_in() to do this.
Link: https://patch.msgid.link/r/6-v3-bd56dd443069+49-bnxt_re_uapi_jgg@nvidia.com
Tested-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Acked-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/rdma/uverbs_ioctl.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/rdma/uverbs_ioctl.h b/include/rdma/uverbs_ioctl.h index 38a11bfe1374..e2af17da3e32 100644 --- a/include/rdma/uverbs_ioctl.h +++ b/include/rdma/uverbs_ioctl.h @@ -1076,6 +1076,21 @@ int _ib_copy_validate_udata_cm_fail(struct ib_udata *udata, u64 req_cm, }) /** + * ib_is_udata_in_empty - Check if the udata input buffer is all zeros + * @udata: The system calls ib_udata struct + * + * This should be used if the driver does not currently define a driver data + * struct. Returns 0 if the buffer is empty or all zeros, -EOPNOTSUPP if + * non-zero data is present, or a negative error code on failure. + */ +static inline int ib_is_udata_in_empty(struct ib_udata *udata) +{ + if (!udata || udata->inlen == 0) + return 0; + return _ib_copy_validate_udata_in(udata, NULL, 0, 0); +} + +/** * ib_respond_udata - Copy a driver data response to userspace * @_udata: The system calls ib_udata struct * @_rep: Kernel buffer containing the response driver data on the stack |
