On Wed, 2019-02-13 at 19:23 +0200, Leon Romanovsky wrote: > From: Parav Pandit <parav@xxxxxxxxxxxx> > > This is a preparation patch to provide isolation of rdma device in a > network namespace. > As first step, make rdma device visible only in init net namespace. > Subsequent patch will enable rdma device visibility back in multiple > net namespaces using compat ib_core_device device/sysfs tree. > > Given that ib subsystem depends on net stack, it needs to be > initialized after netdev stack and since it support devices, it needs > to be initialized before device subsystem; therefore, change initcall > sequence to fs_initcall, so that when ib_core is compiled in kernel > image, right init sequence is followed. > > Signed-off-by: Parav Pandit <parav@xxxxxxxxxxxx> > Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> > --- > drivers/infiniband/core/device.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c > index 1bad96c1c139..35b4bfec91c3 100644 > --- a/drivers/infiniband/core/device.c > +++ b/drivers/infiniband/core/device.c > @@ -312,10 +312,17 @@ static int ib_device_uevent(struct device *device, > return 0; > } > > +static const void *net_namespace(struct device *d) > +{ > + return &init_net; > +} > + > static struct class ib_class = { > .name = "infiniband", > .dev_release = ib_device_release, > .dev_uevent = ib_device_uevent, > + .ns_type = &net_ns_type_operations, > + .namespace = net_namespace, > }; > > static void rdma_init_coredev(struct ib_core_device *coredev, > @@ -1570,5 +1577,8 @@ static void __exit ib_core_cleanup(void) > > MODULE_ALIAS_RDMA_NETLINK(RDMA_NL_LS, 4); > > -subsys_initcall(ib_core_init); > +/* ib core relies on netdev stack to first register net_ns_type_operations > + * ns kobject type before ib_core initialization. > + */ > +fs_initcall(ib_core_init); > module_exit(ib_core_cleanup); While I can't fault you for doing what everyone else has done, I can't help but think that namespace support has grown to be much more than just net_namespace support and should be pulled from the net subsystem and moved into a core subsystem and initialized with the other core features. Looking through the other items in fs_initcall(), we have lots of company, so I won't object, but it does make me go "Hmmm..." -- Doug Ledford <dledford@xxxxxxxxxx> GPG KeyID: B826A3330E572FDD Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
Attachment:
signature.asc
Description: This is a digitally signed message part