From 5aed627f56527431164370b70bf8be29cdd06ab3 Mon Sep 17 00:00:00 2001 From: liangbotong Date: Tue, 22 Apr 2025 14:24:51 +0800 Subject: [PATCH] add lowpower protocol net exit Signed-off-by: liangbotong --- include/net/lowpower_protocol.h | 1 + net/core/lowpower_protocol.c | 6 ++++++ net/ipv4/af_inet.c | 10 ++++++++++ 3 files changed, 17 insertions(+) diff --git a/include/net/lowpower_protocol.h b/include/net/lowpower_protocol.h index 06e55cc16dc3..601f9956d52c 100644 --- a/include/net/lowpower_protocol.h +++ b/include/net/lowpower_protocol.h @@ -24,6 +24,7 @@ typedef void(*ext_init)(void); void regist_dpa_init(ext_init fun); +void __net_exit lowpower_protocol_net_exit(struct net *net); void __net_init lowpower_protocol_net_init(struct net *net); int tcp_ack_num(struct sock *sk); bool netfilter_bypass_enable(struct net *net, struct sk_buff *skb, diff --git a/net/core/lowpower_protocol.c b/net/core/lowpower_protocol.c index a3ef37549c1e..4ab617de498d 100644 --- a/net/core/lowpower_protocol.c +++ b/net/core/lowpower_protocol.c @@ -309,6 +309,12 @@ static void dpa_ext_init(void) g_dpa_init_fun(); } +void __net_exit lowpower_protocol_net_exit(struct net *net) +{ + remove_proc_entry("foreground_uid", net->proc_net); + remove_proc_entry("dpa_uid", net->proc_net); +} + // call this fun in net/ipv4/af_inet.c inet_init_net() void __net_init lowpower_protocol_net_init(struct net *net) { diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 17cc21b28755..89c025967c87 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1844,6 +1844,13 @@ static int __init init_ipv4_mibs(void) return register_pernet_subsys(&ipv4_mib_ops); } +#ifdef CONFIG_LOWPOWER_PROTOCOL +static __net_exit void inet_exit_net(struct net *net) +{ + lowpower_protocol_net_exit(net); +} +#endif /* CONFIG_LOWPOWER_PROTOCOL */ + static __net_init int inet_init_net(struct net *net) { /* @@ -1890,6 +1897,9 @@ static __net_init int inet_init_net(struct net *net) static __net_initdata struct pernet_operations af_inet_ops = { .init = inet_init_net, +#ifdef CONFIG_LOWPOWER_PROTOCOL + .exit = inet_exit_net, +#endif /* CONFIG_LOWPOWER_PROTOCOL */ }; static int __init init_inet_pernet_ops(void) -- Gitee