aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Brauner <christian.brauner@ubuntu.com>2018-03-19 08:17:30 -0400
committerDavid S. Miller <davem@davemloft.net>2018-03-22 11:16:42 -0400
commit94e5e3087a67c765be98592b36d8d187566478d5 (patch)
tree3d2b8468bfa74e705a29702bb90ff2b9172e8a0b
parentaa65f636540539e2e1fd77bdcd8fc7060d19d47b (diff)
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: Christian Brauner <christian.brauner@ubuntu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/net_namespace.h4
-rw-r--r--lib/kobject_uevent.c17
2 files changed, 10 insertions, 11 deletions
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 71abc8d79178..09e30bdc7876 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -40,7 +40,7 @@ struct net_device;
40struct sock; 40struct sock;
41struct ctl_table_header; 41struct ctl_table_header;
42struct net_generic; 42struct net_generic;
43struct sock; 43struct uevent_sock;
44struct netns_ipvs; 44struct netns_ipvs;
45 45
46 46
@@ -83,6 +83,8 @@ struct net {
83 struct sock *rtnl; /* rtnetlink socket */ 83 struct sock *rtnl; /* rtnetlink socket */
84 struct sock *genl_sock; 84 struct sock *genl_sock;
85 85
86 struct uevent_sock *uevent_sock; /* uevent socket */
87
86 struct list_head dev_base_head; 88 struct list_head dev_base_head;
87 struct hlist_head *dev_name_head; 89 struct hlist_head *dev_name_head;
88 struct hlist_head *dev_index_head; 90 struct hlist_head *dev_index_head;
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 9539d7ab3ea8..54cfbaeb3a4e 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -32,11 +32,13 @@ u64 uevent_seqnum;
32#ifdef CONFIG_UEVENT_HELPER 32#ifdef CONFIG_UEVENT_HELPER
33char uevent_helper[UEVENT_HELPER_PATH_LEN] = CONFIG_UEVENT_HELPER_PATH; 33char uevent_helper[UEVENT_HELPER_PATH_LEN] = CONFIG_UEVENT_HELPER_PATH;
34#endif 34#endif
35#ifdef CONFIG_NET 35
36struct uevent_sock { 36struct uevent_sock {
37 struct list_head list; 37 struct list_head list;
38 struct sock *sk; 38 struct sock *sk;
39}; 39};
40
41#ifdef CONFIG_NET
40static LIST_HEAD(uevent_sock_list); 42static LIST_HEAD(uevent_sock_list);
41#endif 43#endif
42 44
@@ -621,6 +623,9 @@ static int uevent_net_init(struct net *net)
621 kfree(ue_sk); 623 kfree(ue_sk);
622 return -ENODEV; 624 return -ENODEV;
623 } 625 }
626
627 net->uevent_sock = ue_sk;
628
624 mutex_lock(&uevent_sock_mutex); 629 mutex_lock(&uevent_sock_mutex);
625 list_add_tail(&ue_sk->list, &uevent_sock_list); 630 list_add_tail(&ue_sk->list, &uevent_sock_list);
626 mutex_unlock(&uevent_sock_mutex); 631 mutex_unlock(&uevent_sock_mutex);
@@ -629,17 +634,9 @@ static int uevent_net_init(struct net *net)
629 634
630static void uevent_net_exit(struct net *net) 635static void uevent_net_exit(struct net *net)
631{ 636{
632 struct uevent_sock *ue_sk; 637 struct uevent_sock *ue_sk = net->uevent_sock;
633 638
634 mutex_lock(&uevent_sock_mutex); 639 mutex_lock(&uevent_sock_mutex);
635 list_for_each_entry(ue_sk, &uevent_sock_list, list) {
636 if (sock_net(ue_sk->sk) == net)
637 goto found;
638 }
639 mutex_unlock(&uevent_sock_mutex);
640 return;
641
642found:
643 list_del(&ue_sk->list); 640 list_del(&ue_sk->list);
644 mutex_unlock(&uevent_sock_mutex); 641 mutex_unlock(&uevent_sock_mutex);
645 642