Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Christian Brauner and committed by
David S. Miller
94e5e308 aa65f636

+10 -11
+3 -1
include/net/net_namespace.h
··· 40 40 struct sock; 41 41 struct ctl_table_header; 42 42 struct net_generic; 43 - struct sock; 43 + struct uevent_sock; 44 44 struct netns_ipvs; 45 45 46 46 ··· 82 82 83 83 struct sock *rtnl; /* rtnetlink socket */ 84 84 struct sock *genl_sock; 85 + 86 + struct uevent_sock *uevent_sock; /* uevent socket */ 85 87 86 88 struct list_head dev_base_head; 87 89 struct hlist_head *dev_name_head;
+7 -10
lib/kobject_uevent.c
··· 32 32 #ifdef CONFIG_UEVENT_HELPER 33 33 char uevent_helper[UEVENT_HELPER_PATH_LEN] = CONFIG_UEVENT_HELPER_PATH; 34 34 #endif 35 - #ifdef CONFIG_NET 35 + 36 36 struct uevent_sock { 37 37 struct list_head list; 38 38 struct sock *sk; 39 39 }; 40 + 41 + #ifdef CONFIG_NET 40 42 static LIST_HEAD(uevent_sock_list); 41 43 #endif 42 44 ··· 623 621 kfree(ue_sk); 624 622 return -ENODEV; 625 623 } 624 + 625 + net->uevent_sock = ue_sk; 626 + 626 627 mutex_lock(&uevent_sock_mutex); 627 628 list_add_tail(&ue_sk->list, &uevent_sock_list); 628 629 mutex_unlock(&uevent_sock_mutex); ··· 634 629 635 630 static void uevent_net_exit(struct net *net) 636 631 { 637 - struct uevent_sock *ue_sk; 632 + struct uevent_sock *ue_sk = net->uevent_sock; 638 633 639 634 mutex_lock(&uevent_sock_mutex); 640 - list_for_each_entry(ue_sk, &uevent_sock_list, list) { 641 - if (sock_net(ue_sk->sk) == net) 642 - goto found; 643 - } 644 - mutex_unlock(&uevent_sock_mutex); 645 - return; 646 - 647 - found: 648 635 list_del(&ue_sk->list); 649 636 mutex_unlock(&uevent_sock_mutex); 650 637