diff --git a/include/net/lowpower_protocol.h b/include/net/lowpower_protocol.h index 656b0741fc04d6d9c992b90628b079aa527bb573..06e55cc16dc3da71dc3002b419c0653b1b098e12 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 60d564550114ce51624414f93cba75fad08b7920..8ce32873b4c47e2f5e4ae8b5abb48b2e46ada89e 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) {