提交 94e5e308 编写于 作者: C Christian Brauner 提交者: David S. Miller

net: add uevent socket member

This commit adds struct uevent_sock to struct net. Since struct uevent_sock
records the position of the uevent socket in the uevent socket list we can
trivially remove it from the uevent socket list during cleanup. This speeds
up the old removal codepath.
Note, list_del() will hit __list_del_entry_valid() in its call chain which
will validate that the element is a member of the list. If it isn't it will
take care that the list is not modified.
Signed-off-by: NChristian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 aa65f636
...@@ -40,7 +40,7 @@ struct net_device; ...@@ -40,7 +40,7 @@ struct net_device;
struct sock; struct sock;
struct ctl_table_header; struct ctl_table_header;
struct net_generic; struct net_generic;
struct sock; struct uevent_sock;
struct netns_ipvs; struct netns_ipvs;
...@@ -83,6 +83,8 @@ struct net { ...@@ -83,6 +83,8 @@ struct net {
struct sock *rtnl; /* rtnetlink socket */ struct sock *rtnl; /* rtnetlink socket */
struct sock *genl_sock; struct sock *genl_sock;
struct uevent_sock *uevent_sock; /* uevent socket */
struct list_head dev_base_head; struct list_head dev_base_head;
struct hlist_head *dev_name_head; struct hlist_head *dev_name_head;
struct hlist_head *dev_index_head; struct hlist_head *dev_index_head;
......
...@@ -32,11 +32,13 @@ u64 uevent_seqnum; ...@@ -32,11 +32,13 @@ u64 uevent_seqnum;
#ifdef CONFIG_UEVENT_HELPER #ifdef CONFIG_UEVENT_HELPER
char uevent_helper[UEVENT_HELPER_PATH_LEN] = CONFIG_UEVENT_HELPER_PATH; char uevent_helper[UEVENT_HELPER_PATH_LEN] = CONFIG_UEVENT_HELPER_PATH;
#endif #endif
#ifdef CONFIG_NET
struct uevent_sock { struct uevent_sock {
struct list_head list; struct list_head list;
struct sock *sk; struct sock *sk;
}; };
#ifdef CONFIG_NET
static LIST_HEAD(uevent_sock_list); static LIST_HEAD(uevent_sock_list);
#endif #endif
...@@ -621,6 +623,9 @@ static int uevent_net_init(struct net *net) ...@@ -621,6 +623,9 @@ static int uevent_net_init(struct net *net)
kfree(ue_sk); kfree(ue_sk);
return -ENODEV; return -ENODEV;
} }
net->uevent_sock = ue_sk;
mutex_lock(&uevent_sock_mutex); mutex_lock(&uevent_sock_mutex);
list_add_tail(&ue_sk->list, &uevent_sock_list); list_add_tail(&ue_sk->list, &uevent_sock_list);
mutex_unlock(&uevent_sock_mutex); mutex_unlock(&uevent_sock_mutex);
...@@ -629,17 +634,9 @@ static int uevent_net_init(struct net *net) ...@@ -629,17 +634,9 @@ static int uevent_net_init(struct net *net)
static void uevent_net_exit(struct net *net) static void uevent_net_exit(struct net *net)
{ {
struct uevent_sock *ue_sk; struct uevent_sock *ue_sk = net->uevent_sock;
mutex_lock(&uevent_sock_mutex); mutex_lock(&uevent_sock_mutex);
list_for_each_entry(ue_sk, &uevent_sock_list, list) {
if (sock_net(ue_sk->sk) == net)
goto found;
}
mutex_unlock(&uevent_sock_mutex);
return;
found:
list_del(&ue_sk->list); list_del(&ue_sk->list);
mutex_unlock(&uevent_sock_mutex); mutex_unlock(&uevent_sock_mutex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册