lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <151094328094.20009.1172105574765830336.stgit@localhost.localdomain>
Date:   Fri, 17 Nov 2017 21:28:00 +0300
From:   Kirill Tkhai <ktkhai@...tuozzo.com>
To:     davem@...emloft.net, vyasevic@...hat.com,
        kstewart@...uxfoundation.org, pombredanne@...b.com,
        vyasevich@...il.com, mark.rutland@....com,
        gregkh@...uxfoundation.org, adobriyan@...il.com, fw@...len.de,
        nicolas.dichtel@...nd.com, xiyou.wangcong@...il.com,
        roman.kapl@...go.com, paul@...l-moore.com, dsahern@...il.com,
        daniel@...earbox.net, lucien.xin@...il.com,
        mschiffer@...verse-factory.net, rshearma@...cade.com,
        linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
        ktkhai@...tuozzo.com, ebiederm@...ssion.com, avagin@...tuozzo.com,
        gorcunov@...tuozzo.com, eric.dumazet@...il.com,
        stephen@...workplumber.org, ktkhai@...tuozzo.com
Subject: [PATCH RFC 05/25] net: Add primitives to update heads of
 pernet_list sublists

Currently we have first_device, and device and subsys
sublists. Next patches introduce one more sublist.
So, move the functionality, which will be repeating,
to the primitives.

Signed-off-by: Kirill Tkhai <ktkhai@...tuozzo.com>
---
 net/core/net_namespace.c |   19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index a8ea580885d9..1d9712973695 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -939,6 +939,18 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
 
 static DEFINE_IDA(net_generic_ids);
 
+#define update_first_on_add(first, delim, added) 	\
+	do {						\
+		if (first == delim)			\
+			first = added;			\
+	} while (0)
+
+#define update_first_on_del(first, to_delete)		\
+	do {						\
+		if (first == to_delete)			\
+			first = (to_delete)->next;	\
+	} while (0)
+
 static int register_pernet_operations(struct list_head *list,
 				      struct pernet_operations *ops)
 {
@@ -1045,8 +1057,8 @@ int register_pernet_device(struct pernet_operations *ops)
 	int error;
 	down_write(&net_sem);
 	error = register_pernet_operations(&pernet_list, ops);
-	if (!error && (first_device == &pernet_list))
-		first_device = &ops->list;
+	if (!error)
+		update_first_on_add(first_device, &pernet_list, &ops->list);
 	up_write(&net_sem);
 	return error;
 }
@@ -1064,8 +1076,7 @@ EXPORT_SYMBOL_GPL(register_pernet_device);
 void unregister_pernet_device(struct pernet_operations *ops)
 {
 	down_write(&net_sem);
-	if (&ops->list == first_device)
-		first_device = first_device->next;
+	update_first_on_del(first_device, &ops->list);
 	unregister_pernet_operations(ops);
 	up_write(&net_sem);
 }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ