From: Stanislav Fomichev Date: Tue, 1 Apr 2025 16:34:45 +0000 (-0700) Subject: net: rename rtnl_net_debug to lock_debug X-Git-Tag: ceph-for-6.16-rc1~288^2~12^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b912d599d3d83ff9a2db58c17b5c76429a206db5;p=ceph-client.git net: rename rtnl_net_debug to lock_debug And make it selected by CONFIG_DEBUG_NET. Don't rename any of the structs/functions. Next patch will use rtnl_net_debug_event in netdevsim. Reviewed-by: Jakub Kicinski Signed-off-by: Stanislav Fomichev Link: https://patch.msgid.link/20250401163452.622454-5-sdf@fomichev.me Signed-off-by: Jakub Kicinski --- diff --git a/net/core/Makefile b/net/core/Makefile index a10c3bd96798..b2a76ce33932 100644 --- a/net/core/Makefile +++ b/net/core/Makefile @@ -45,5 +45,5 @@ obj-$(CONFIG_BPF_SYSCALL) += bpf_sk_storage.o obj-$(CONFIG_OF) += of_net.o obj-$(CONFIG_NET_TEST) += net_test.o obj-$(CONFIG_NET_DEVMEM) += devmem.o -obj-$(CONFIG_DEBUG_NET_SMALL_RTNL) += rtnl_net_debug.o +obj-$(CONFIG_DEBUG_NET) += lock_debug.o obj-$(CONFIG_FAIL_SKB_REALLOC) += skb_fault_injection.o diff --git a/net/core/lock_debug.c b/net/core/lock_debug.c new file mode 100644 index 000000000000..f3272b09c255 --- /dev/null +++ b/net/core/lock_debug.c @@ -0,0 +1,116 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* Copyright Amazon.com Inc. or its affiliates. */ + +#include +#include +#include +#include +#include +#include + +static int rtnl_net_debug_event(struct notifier_block *nb, + unsigned long event, void *ptr) +{ + struct net_device *dev = netdev_notifier_info_to_dev(ptr); + struct net *net = dev_net(dev); + enum netdev_cmd cmd = event; + + /* Keep enum and don't add default to trigger -Werror=switch */ + switch (cmd) { + case NETDEV_UP: + case NETDEV_DOWN: + case NETDEV_REBOOT: + case NETDEV_CHANGE: + case NETDEV_REGISTER: + case NETDEV_UNREGISTER: + case NETDEV_CHANGEMTU: + case NETDEV_CHANGEADDR: + case NETDEV_PRE_CHANGEADDR: + case NETDEV_GOING_DOWN: + case NETDEV_FEAT_CHANGE: + case NETDEV_BONDING_FAILOVER: + case NETDEV_PRE_UP: + case NETDEV_PRE_TYPE_CHANGE: + case NETDEV_POST_TYPE_CHANGE: + case NETDEV_POST_INIT: + case NETDEV_PRE_UNINIT: + case NETDEV_RELEASE: + case NETDEV_NOTIFY_PEERS: + case NETDEV_JOIN: + case NETDEV_CHANGEUPPER: + case NETDEV_RESEND_IGMP: + case NETDEV_PRECHANGEMTU: + case NETDEV_CHANGEINFODATA: + case NETDEV_BONDING_INFO: + case NETDEV_PRECHANGEUPPER: + case NETDEV_CHANGELOWERSTATE: + case NETDEV_UDP_TUNNEL_PUSH_INFO: + case NETDEV_UDP_TUNNEL_DROP_INFO: + case NETDEV_CHANGE_TX_QUEUE_LEN: + case NETDEV_CVLAN_FILTER_PUSH_INFO: + case NETDEV_CVLAN_FILTER_DROP_INFO: + case NETDEV_SVLAN_FILTER_PUSH_INFO: + case NETDEV_SVLAN_FILTER_DROP_INFO: + case NETDEV_OFFLOAD_XSTATS_ENABLE: + case NETDEV_OFFLOAD_XSTATS_DISABLE: + case NETDEV_OFFLOAD_XSTATS_REPORT_USED: + case NETDEV_OFFLOAD_XSTATS_REPORT_DELTA: + case NETDEV_XDP_FEAT_CHANGE: + ASSERT_RTNL(); + break; + + case NETDEV_CHANGENAME: + ASSERT_RTNL_NET(net); + break; + } + + return NOTIFY_DONE; +} + +static int rtnl_net_debug_net_id; + +static int __net_init rtnl_net_debug_net_init(struct net *net) +{ + struct notifier_block *nb; + + nb = net_generic(net, rtnl_net_debug_net_id); + nb->notifier_call = rtnl_net_debug_event; + + return register_netdevice_notifier_net(net, nb); +} + +static void __net_exit rtnl_net_debug_net_exit(struct net *net) +{ + struct notifier_block *nb; + + nb = net_generic(net, rtnl_net_debug_net_id); + unregister_netdevice_notifier_net(net, nb); +} + +static struct pernet_operations rtnl_net_debug_net_ops __net_initdata = { + .init = rtnl_net_debug_net_init, + .exit = rtnl_net_debug_net_exit, + .id = &rtnl_net_debug_net_id, + .size = sizeof(struct notifier_block), +}; + +static struct notifier_block rtnl_net_debug_block = { + .notifier_call = rtnl_net_debug_event, +}; + +static int __init rtnl_net_debug_init(void) +{ + int ret; + + ret = register_pernet_subsys(&rtnl_net_debug_net_ops); + if (ret) + return ret; + + ret = register_netdevice_notifier(&rtnl_net_debug_block); + if (ret) + unregister_pernet_subsys(&rtnl_net_debug_net_ops); + + return ret; +} + +subsys_initcall(rtnl_net_debug_init); diff --git a/net/core/rtnl_net_debug.c b/net/core/rtnl_net_debug.c deleted file mode 100644 index f3272b09c255..000000000000 --- a/net/core/rtnl_net_debug.c +++ /dev/null @@ -1,116 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* Copyright Amazon.com Inc. or its affiliates. */ - -#include -#include -#include -#include -#include -#include - -static int rtnl_net_debug_event(struct notifier_block *nb, - unsigned long event, void *ptr) -{ - struct net_device *dev = netdev_notifier_info_to_dev(ptr); - struct net *net = dev_net(dev); - enum netdev_cmd cmd = event; - - /* Keep enum and don't add default to trigger -Werror=switch */ - switch (cmd) { - case NETDEV_UP: - case NETDEV_DOWN: - case NETDEV_REBOOT: - case NETDEV_CHANGE: - case NETDEV_REGISTER: - case NETDEV_UNREGISTER: - case NETDEV_CHANGEMTU: - case NETDEV_CHANGEADDR: - case NETDEV_PRE_CHANGEADDR: - case NETDEV_GOING_DOWN: - case NETDEV_FEAT_CHANGE: - case NETDEV_BONDING_FAILOVER: - case NETDEV_PRE_UP: - case NETDEV_PRE_TYPE_CHANGE: - case NETDEV_POST_TYPE_CHANGE: - case NETDEV_POST_INIT: - case NETDEV_PRE_UNINIT: - case NETDEV_RELEASE: - case NETDEV_NOTIFY_PEERS: - case NETDEV_JOIN: - case NETDEV_CHANGEUPPER: - case NETDEV_RESEND_IGMP: - case NETDEV_PRECHANGEMTU: - case NETDEV_CHANGEINFODATA: - case NETDEV_BONDING_INFO: - case NETDEV_PRECHANGEUPPER: - case NETDEV_CHANGELOWERSTATE: - case NETDEV_UDP_TUNNEL_PUSH_INFO: - case NETDEV_UDP_TUNNEL_DROP_INFO: - case NETDEV_CHANGE_TX_QUEUE_LEN: - case NETDEV_CVLAN_FILTER_PUSH_INFO: - case NETDEV_CVLAN_FILTER_DROP_INFO: - case NETDEV_SVLAN_FILTER_PUSH_INFO: - case NETDEV_SVLAN_FILTER_DROP_INFO: - case NETDEV_OFFLOAD_XSTATS_ENABLE: - case NETDEV_OFFLOAD_XSTATS_DISABLE: - case NETDEV_OFFLOAD_XSTATS_REPORT_USED: - case NETDEV_OFFLOAD_XSTATS_REPORT_DELTA: - case NETDEV_XDP_FEAT_CHANGE: - ASSERT_RTNL(); - break; - - case NETDEV_CHANGENAME: - ASSERT_RTNL_NET(net); - break; - } - - return NOTIFY_DONE; -} - -static int rtnl_net_debug_net_id; - -static int __net_init rtnl_net_debug_net_init(struct net *net) -{ - struct notifier_block *nb; - - nb = net_generic(net, rtnl_net_debug_net_id); - nb->notifier_call = rtnl_net_debug_event; - - return register_netdevice_notifier_net(net, nb); -} - -static void __net_exit rtnl_net_debug_net_exit(struct net *net) -{ - struct notifier_block *nb; - - nb = net_generic(net, rtnl_net_debug_net_id); - unregister_netdevice_notifier_net(net, nb); -} - -static struct pernet_operations rtnl_net_debug_net_ops __net_initdata = { - .init = rtnl_net_debug_net_init, - .exit = rtnl_net_debug_net_exit, - .id = &rtnl_net_debug_net_id, - .size = sizeof(struct notifier_block), -}; - -static struct notifier_block rtnl_net_debug_block = { - .notifier_call = rtnl_net_debug_event, -}; - -static int __init rtnl_net_debug_init(void) -{ - int ret; - - ret = register_pernet_subsys(&rtnl_net_debug_net_ops); - if (ret) - return ret; - - ret = register_netdevice_notifier(&rtnl_net_debug_block); - if (ret) - unregister_pernet_subsys(&rtnl_net_debug_net_ops); - - return ret; -} - -subsys_initcall(rtnl_net_debug_init);