diff mbox series

[net] vrf: fix vrf driver unloading

Message ID 20220525204628.297931-1-eyal.birger@gmail.com (mailing list archive)
State Rejected
Delegated to: Netdev Maintainers
Headers show
Series [net] vrf: fix vrf driver unloading | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 17 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Eyal Birger May 25, 2022, 8:46 p.m. UTC
The commit referenced in the "Fixes" tag has removed the vrf driver
cleanup function leading to a "Device or resource busy" error when
trying to rmmod vrf.

Fix by re-introducing the cleanup function with the relevant changes.

Fixes: 9ab179d83b4e ("net: vrf: Fix dst reference counting")
Signed-off-by: Eyal Birger <eyal.birger@gmail.com>

----

Note: the commit message in 9ab179d83b4e did not document it
and it is not apparent to me why the ability to rmmod the driver is
linked to that change, but maybe there's some hidden reason.
---
 drivers/net/vrf.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

David Ahern May 25, 2022, 9:12 p.m. UTC | #1
On 5/25/22 2:46 PM, Eyal Birger wrote:
> The commit referenced in the "Fixes" tag has removed the vrf driver
> cleanup function leading to a "Device or resource busy" error when
> trying to rmmod vrf.
> 
> Fix by re-introducing the cleanup function with the relevant changes.
> 
> Fixes: 9ab179d83b4e ("net: vrf: Fix dst reference counting")
> Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
> 
> ----
> 
> Note: the commit message in 9ab179d83b4e did not document it
> and it is not apparent to me why the ability to rmmod the driver is
> linked to that change, but maybe there's some hidden reason.

dst output handler references VRF functions. You can not remove the
module until all dst references have been dropped. Since there is no way
to know and the rmmod command can not just hang waiting for dst entries
to be dropped the module can not be unloaded. The same is true for IPv6
as module; it can not be removed and I believe for the same reason.
Eyal Birger May 26, 2022, 7:35 a.m. UTC | #2
On Thu, May 26, 2022 at 12:12 AM David Ahern <dsahern@kernel.org> wrote:
>
> On 5/25/22 2:46 PM, Eyal Birger wrote:
> > The commit referenced in the "Fixes" tag has removed the vrf driver
> > cleanup function leading to a "Device or resource busy" error when
> > trying to rmmod vrf.
> >
> > Fix by re-introducing the cleanup function with the relevant changes.
> >
> > Fixes: 9ab179d83b4e ("net: vrf: Fix dst reference counting")
> > Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
> >
> > ----
> >
> > Note: the commit message in 9ab179d83b4e did not document it
> > and it is not apparent to me why the ability to rmmod the driver is
> > linked to that change, but maybe there's some hidden reason.
>
> dst output handler references VRF functions. You can not remove the
> module until all dst references have been dropped. Since there is no way
> to know and the rmmod command can not just hang waiting for dst entries
> to be dropped the module can not be unloaded. The same is true for IPv6
> as module; it can not be removed and I believe for the same reason.
>
I thought it was related to such cleanup, but couldn't see why the device
unregistration wouldn't void the dsts.

Probably better be safe than sorry :)

Thanks for the clarification.
Eyal.
diff mbox series

Patch

diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index cfc30ce4c6e1..7dff865d7283 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -2064,7 +2064,17 @@  static int __init vrf_init_module(void)
 	return rc;
 }
 
+static void __exit vrf_cleanup_module(void)
+{
+	rtnl_link_unregister(&vrf_link_ops);
+	l3mdev_table_lookup_unregister(L3MDEV_TYPE_VRF,
+				       vrf_ifindex_lookup_by_table_id);
+	unregister_pernet_subsys(&vrf_net_ops);
+	unregister_netdevice_notifier(&vrf_notifier_block);
+}
+
 module_init(vrf_init_module);
+module_exit(vrf_cleanup_module);
 MODULE_AUTHOR("Shrijeet Mukherjee, David Ahern");
 MODULE_DESCRIPTION("Device driver to instantiate VRF domains");
 MODULE_LICENSE("GPL");