diff mbox series

[net] net: vrf: fix remove vrf module error when there's no reference

Message ID da552b69-f9d4-5359-07fc-cbf6949194cc@huawei.com
State Rejected
Delegated to: David Miller
Headers show
Series [net] net: vrf: fix remove vrf module error when there's no reference | expand

Commit Message

Miaohe Lin March 2, 2019, 12:31 p.m. UTC
From: Miaohe Lin <linmiaohe@huawei.com>

If we insmod vrf.ko, there is no way to remove it because of lack of module_exit.
I think we may need it.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 drivers/net/vrf.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

David Ahern March 2, 2019, 8:15 p.m. UTC | #1
On 3/2/19 5:31 AM, linmiaohe wrote:
> From: Miaohe Lin <linmiaohe@huawei.com>
> 
> If we insmod vrf.ko, there is no way to remove it because of lack of module_exit.
> I think we may need it.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>  drivers/net/vrf.c | 8 ++++++++
>  1 file changed, 8 insertions(+)

The ability to unload the vrf driver was removed by
9ab179d83b4e31ea277a123492e419067c2f129a.
Miaohe Lin March 4, 2019, 1:53 a.m. UTC | #2
On 2019/3/3 4:15, David Ahern wrote:
> On 3/2/19 5:31 AM, linmiaohe wrote:
>> From: Miaohe Lin <linmiaohe@huawei.com>
>>
>> If we insmod vrf.ko, there is no way to remove it because of lack of module_exit.
>> I think we may need it.
>>
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>> ---
>>  drivers/net/vrf.c | 8 ++++++++
>>  1 file changed, 8 insertions(+)
> 
> The ability to unload the vrf driver was removed by
> 9ab179d83b4e31ea277a123492e419067c2f129a.
> 
> 
> 
I think I should git blame the vrf more carefully next time.
Thank you very much for your replay.
kernel test robot March 4, 2019, 8:40 a.m. UTC | #3
Hi Miaohe,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net/master]

url:    https://github.com/0day-ci/linux/commits/linmiaohe/net-vrf-fix-remove-vrf-module-error-when-there-s-no-reference/20190303-082433
config: x86_64-randconfig-u0-03041013 (attached as .config)
compiler: gcc-5 (Debian 5.5.0-3) 5.4.1 20171010
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

>> WARNING: drivers/net/vrf.o(.exit.text+0x14): Section mismatch in reference from the function cleanup_module() to the variable .init.data:vrf_net_ops
   The function __exit cleanup_module() references
   a variable __initdata vrf_net_ops.
   This is often seen when error handling in the exit function
   uses functionality in the init path.
   The fix is often to remove the __initdata annotation of
   vrf_net_ops so it may be used outside an init section.

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox series

Patch

diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index 7c1430ed0244..0e93690482d4 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -1462,7 +1462,15 @@  static int __init vrf_init_module(void)
 	return rc;
 }

+static void __exit vrf_fini_module(void)
+{
+	rtnl_link_unregister(&vrf_link_ops);
+	unregister_pernet_subsys(&vrf_net_ops);
+	unregister_netdevice_notifier(&vrf_notifier_block);
+}
+
 module_init(vrf_init_module);
+module_exit(vrf_fini_module);
 MODULE_AUTHOR("Shrijeet Mukherjee, David Ahern");
 MODULE_DESCRIPTION("Device driver to instantiate VRF domains");
 MODULE_LICENSE("GPL");