Skip to contentSkip to conversation

RDMA/uverbs: Add empty rdma_uattrs_has_raw_cap() declaration

PATCH Applied Leon Romanovsky 3 participants 4 messages Jul 8, 2025 – Jul 9, 2025 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/uverbs: Add empty rdma_uattrs_has_raw_cap() declaration

From: Leon Romanovsky <[email protected]>

The call to rdma_uattrs_has_raw_cap() is placed in mlx5 fs.c file, which is compiled without relation to CONFIG_INFINIBAND_USER_ACCESS.

Despite the check is used only in flows with CONFIG_INFINIBAND_USER_ACCESS=y|m, the compilers generate the following error for CONFIG_INFINIBAND_USER_ACCESS=n builds.

Quoted 1 line
Quoted 1 line

ERROR: modpost: "rdma_uattrs_has_raw_cap" [drivers/infiniband/hw/mlx5/mlx5_ib.ko] undefined!

Fixes f458ccd2aa2c ("RDMA/uverbs: Check CAP_NET_RAW in user namespace for flow create")
---
 include/rdma/ib_verbs.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
include/rdma/ib_verbs.h +6 -2
index c263327a0205..ce4180c4db14 100644
@@ -4841,15 +4841,19 @@ struct ib_ucontext *ib_uverbs_get_ucontext_file(struct ib_uverbs_file *ufile);
 
 #if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
 int uverbs_destroy_def_handler(struct uverbs_attr_bundle *attrs);
+bool rdma_uattrs_has_raw_cap(const struct uverbs_attr_bundle *attrs);
 #else
 static inline int uverbs_destroy_def_handler(struct uverbs_attr_bundle *attrs)
 {
 	return 0;
 }
+static inline bool
+rdma_uattrs_has_raw_cap(const struct uverbs_attr_bundle *attrs)
+{
+	return false;
+}
 #endif
 
-bool rdma_uattrs_has_raw_cap(const struct uverbs_attr_bundle *attrs);
-
 struct net_device *rdma_alloc_netdev(struct ib_device *device, u32 port_num,
 				     enum rdma_netdev_t type, const char *name,
 				     unsigned char name_assign_type,
Signature · 1 line
2.50.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 54 lines

From: Leon Romanovsky <[email protected]>
Sent: 08 July 2025 03:02 PM
From: Leon Romanovsky <[email protected]>

The call to rdma_uattrs_has_raw_cap() is placed in mlx5 fs.c file, which is compiled without relation to CONFIG_INFINIBAND_USER_ACCESS.

Despite the check is used only in flows with
CONFIG_INFINIBAND_USER_ACCESS=y|m,
the compilers generate the following error for
CONFIG_INFINIBAND_USER_ACCESS=n builds.

Quoted 1 line
Quoted 1 line

ERROR: modpost: "rdma_uattrs_has_raw_cap"

[drivers/infiniband/hw/mlx5/mlx5_ib.ko] undefined!

Fixes f458ccd2aa2c ("RDMA/uverbs: Check CAP_NET_RAW in user namespace

for flow create")

[email protected]/

---
 include/rdma/ib_verbs.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
include/rdma/ib_verbs.h index renamed from include/rdma/ib_verbs.h +0 -0

c263327a0205..ce4180c4db14 100644

include/rdma/ib_verbs.h +5 -2
@@ -4841,15 +4841,19 @@ struct ib_ucontext
 *ib_uverbs_get_ucontext_file(struct ib_uverbs_file *ufile);
 
 #if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
 int uverbs_destroy_def_handler(struct uverbs_attr_bundle *attrs);
+bool rdma_uattrs_has_raw_cap(const struct uverbs_attr_bundle *attrs);
 #else
 static inline int uverbs_destroy_def_handler(struct uverbs_attr_bundle *attrs)
 {
 	return 0;
 }
+static inline bool
+rdma_uattrs_has_raw_cap(const struct uverbs_attr_bundle *attrs) {
+	return false;
+}
 #endif
 
-bool rdma_uattrs_has_raw_cap(const struct uverbs_attr_bundle *attrs);
-
 struct net_device *rdma_alloc_netdev(struct ib_device *device, u32
 port_num,
 				     enum rdma_netdev_t type, const char
Quoted 4 lines

*name,
unsigned char name_assign_type,
--
2.50.0

Reviewed-by on v1 1/1
#2 lore raw
In reply to Leon Romanovsky
Quoted 29 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

The call to rdma_uattrs_has_raw_cap() is placed in mlx5 fs.c file, which is compiled without relation to CONFIG_INFINIBAND_USER_ACCESS.

Despite the check is used only in flows with CONFIG_INFINIBAND_USER_ACCESS=y|m, the compilers generate the following error for CONFIG_INFINIBAND_USER_ACCESS=n builds.

Quoted 1 line
Quoted 1 line

ERROR: modpost: "rdma_uattrs_has_raw_cap" [drivers/infiniband/hw/mlx5/mlx5_ib.ko] undefined!

Fixes f458ccd2aa2c ("RDMA/uverbs: Check CAP_NET_RAW in user namespace for flow create")
---
  include/rdma/ib_verbs.h | 8 ++++++--
  1 file changed, 6 insertions(+), 2 deletions(-)
include/rdma/ib_verbs.h +1 -0
index c263327a0205..ce4180c4db14 100644
@@ -4841,15 +4841,19 @@ struct ib_ucontext *ib_uverbs_get_ucontext_file(struct ib_uverbs_file *ufile);
 
  #if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
  int uverbs_destroy_def_handler(struct uverbs_attr_bundle *attrs);
+bool rdma_uattrs_has_raw_cap(const struct uverbs_attr_bundle *attrs);
  #else

include/rdma/ib_verbs.h struct ib_ucontext *ib_uverbs_get_ucontext_file(struct ib_uverbs_file *ufile); · line 4855

Quoted 10 lines
include/rdma/ib_verbs.h +5 -0
  static inline int uverbs_destroy_def_handler(struct uverbs_attr_bundle *attrs)
  {
  	return 0;
  }
+static inline bool
+rdma_uattrs_has_raw_cap(const struct uverbs_attr_bundle *attrs)
+{
+	return false;
+}
  #endif

The function rdma_uattrs_has_raw_cap is implemented in the file rdma_core.c. This file is included in the build via the Makefile:

"
...

ib_uverbs-y := uverbs_main.o uverbs_cmd.o uverbs_marshall.o \
               rdma_core.o uverbs_std_types.o uverbs_ioctl.o \
               ...

"
As a result, rdma_core.o is compiled only when CONFIG_INFINIBAND_USER_ACCESS is enabled.

In other words, the implementation of the rdma_uattrs_has_raw_cap function is guarded by CONFIG_INFINIBAND_USER_ACCESS.

Given this, it is reasonable to move the declaration of rdma_uattrs_has_raw_cap into the scope of CONFIG_INFINIBAND_USER_ACCESS in ib_verbs.h.

Zhu Yanjun

Quoted 6 lines
include/rdma/ib_verbs.h +0 -2
-bool rdma_uattrs_has_raw_cap(const struct uverbs_attr_bundle *attrs);
-
  struct net_device *rdma_alloc_netdev(struct ib_device *device, u32 port_num,
  				     enum rdma_netdev_t type, const char *name,
  				     unsigned char name_assign_type,
author Applied
#3 lore raw
In reply to Leon Romanovsky
Quoted 8 lines · Leon Romanovsky

The call to rdma_uattrs_has_raw_cap() is placed in mlx5 fs.c file, which is compiled without relation to CONFIG_INFINIBAND_USER_ACCESS.

Despite the check is used only in flows with CONFIG_INFINIBAND_USER_ACCESS=y|m, the compilers generate the following error for CONFIG_INFINIBAND_USER_ACCESS=n builds.

[...]

Applied, thanks!

[1/1] RDMA/uverbs: Add empty rdma_uattrs_has_raw_cap() declaration

      https://git.kernel.org/rdma/rdma/c/98269398c02ab2

Best regards,

Signature · 1 line
Leon Romanovsky <[email protected]>