diff --git a/iscsi-scst/kernel/event.c b/iscsi-scst/kernel/event.c index 58e0581cf..1ac927ab7 100644 --- a/iscsi-scst/kernel/event.c +++ b/iscsi-scst/kernel/event.c @@ -171,7 +171,11 @@ out_unlock: int __init event_init(void) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(7, 0, 0) iscsi_net_ns = kobj_ns_grab_current(KOBJ_NS_TYPE_NET); +#else + iscsi_net_ns = to_net_ns(kobj_ns_grab_current(KOBJ_NS_TYPE_NET)); +#endif { struct netlink_kernel_cfg cfg = { @@ -188,7 +192,11 @@ int __init event_init(void) drop_ns: PRINT_ERROR("%s", "netlink_kernel_create() failed"); +#if LINUX_VERSION_CODE < KERNEL_VERSION(7, 0, 0) kobj_ns_drop(KOBJ_NS_TYPE_NET, iscsi_net_ns); +#else + kobj_ns_drop(KOBJ_NS_TYPE_NET, to_ns_common(iscsi_net_ns)); +#endif iscsi_net_ns = NULL; return -ENOMEM; } @@ -196,6 +204,10 @@ drop_ns: void event_exit(void) { netlink_kernel_release(nl); +#if LINUX_VERSION_CODE < KERNEL_VERSION(7, 0, 0) kobj_ns_drop(KOBJ_NS_TYPE_NET, iscsi_net_ns); +#else + kobj_ns_drop(KOBJ_NS_TYPE_NET, to_ns_common(iscsi_net_ns)); +#endif iscsi_net_ns = NULL; } diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 9bb3ffcad..53651b2fd 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -4579,7 +4579,11 @@ static int __init srpt_init_module(void) goto destroy_wq; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(7, 0, 0) srpt_net_ns = kobj_ns_grab_current(KOBJ_NS_TYPE_NET); +#else + srpt_net_ns = to_net_ns(kobj_ns_grab_current(KOBJ_NS_TYPE_NET)); +#endif if (rdma_cm_port) { struct sockaddr_in addr; @@ -4623,7 +4627,11 @@ destroy_id: rdma_destroy_id(rdma_cm_id); drop_ns: +#if LINUX_VERSION_CODE < KERNEL_VERSION(7, 0, 0) kobj_ns_drop(KOBJ_NS_TYPE_NET, srpt_net_ns); +#else + kobj_ns_drop(KOBJ_NS_TYPE_NET, to_ns_common(srpt_net_ns)); +#endif srpt_net_ns = NULL; ib_unregister_client(&srpt_client); @@ -4642,7 +4650,11 @@ static void __exit srpt_cleanup_module(void) if (rdma_cm_id) rdma_destroy_id(rdma_cm_id); +#if LINUX_VERSION_CODE < KERNEL_VERSION(7, 0, 0) kobj_ns_drop(KOBJ_NS_TYPE_NET, srpt_net_ns); +#else + kobj_ns_drop(KOBJ_NS_TYPE_NET, to_ns_common(srpt_net_ns)); +#endif srpt_net_ns = NULL; ib_unregister_client(&srpt_client);