From 5c60fdba46553bfd2bc24c4c012b423868a26359 Mon Sep 17 00:00:00 2001 From: yangyanjun Date: Tue, 5 Nov 2024 17:26:06 +0800 Subject: [PATCH] add dpa init fun pointer, call dpa init fun pointer when dpa list adding. Signed-off-by: yangyanjun --- include/net/lowpower_protocol.h | 3 +++ net/core/lowpower_protocol.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/net/lowpower_protocol.h b/include/net/lowpower_protocol.h index 656b0741fc04..06e55cc16dc3 100644 --- a/include/net/lowpower_protocol.h +++ b/include/net/lowpower_protocol.h @@ -21,6 +21,9 @@ #define BIG_DATA_BYTES 200000 #define TCP_ACK_NUM 30 +typedef void(*ext_init)(void); +void regist_dpa_init(ext_init fun); + 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 60d564550114..8ce32873b4c4 100644 --- a/net/core/lowpower_protocol.c +++ b/net/core/lowpower_protocol.c @@ -30,6 +30,7 @@ struct dpa_node { struct list_head list_node; uid_t uid; }; +static ext_init g_dpa_init_fun; static void foreground_uid_atomic_set(uid_t val) { @@ -83,6 +84,7 @@ static int dpa_uid_add(uid_t uid); static int dpa_uid_del(uid_t uid); static int get_dpa_uids(char *buf, size_t size, u32 *uid_list, u32 index_max, u32 *index); +static void dpa_ext_init(void); static int dpa_uid_write(struct file *file, char *buf, size_t size) { u32 dpa_list[LIST_MAX]; @@ -96,6 +98,7 @@ static int dpa_uid_write(struct file *file, char *buf, size_t size) } if (strncmp(buf, "add", OPT_LEN) == 0) { + dpa_ext_init(); for (i = 0; i < index; i++) { ret = dpa_uid_add(dpa_list[i]); if (ret != 0) { @@ -288,6 +291,19 @@ bool dpa_uid_match(uid_t kuid) } EXPORT_SYMBOL(dpa_uid_match); +void regist_dpa_init(ext_init fun) +{ + if (!fun) + return; + g_dpa_init_fun = fun; +} + +static void dpa_ext_init(void) +{ + if (g_dpa_init_fun) + g_dpa_init_fun(); +} + // call this fun in net/ipv4/af_inet.c inet_init_net() void __net_init lowpower_protocol_net_init(struct net *net) { -- Gitee