aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPaul Moore <paul.moore@hp.com>2008-01-29 08:37:57 -0500
committerJames Morris <jmorris@namei.org>2008-01-29 16:17:18 -0500
commit1c3fad936acaf87b75055b95be781437e97d787f (patch)
tree43fe24b08a605db020c0a93fb5ceec1e7744822d /net
parentb64397e0b40e75b619aeef9a1fa21f79f801a3e8 (diff)
NetLabel: Consolidate the LSM domain mapping/hashing locks
Currently we use two separate spinlocks to protect both the hash/mapping table and the default entry. This could be considered a bit foolish because it adds complexity without offering any real performance advantage. This patch removes the dedicated default spinlock and protects the default entry with the hash/mapping table spinlock. Signed-off-by: Paul Moore <paul.moore@hp.com> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'net')
-rw-r--r--net/netlabel/netlabel_domainhash.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/net/netlabel/netlabel_domainhash.c b/net/netlabel/netlabel_domainhash.c
index 1f8f7ace790e..9a8ea0195c4f 100644
--- a/net/netlabel/netlabel_domainhash.c
+++ b/net/netlabel/netlabel_domainhash.c
@@ -54,9 +54,6 @@ struct netlbl_domhsh_tbl {
54 * hash table should be okay */ 54 * hash table should be okay */
55static DEFINE_SPINLOCK(netlbl_domhsh_lock); 55static DEFINE_SPINLOCK(netlbl_domhsh_lock);
56static struct netlbl_domhsh_tbl *netlbl_domhsh = NULL; 56static struct netlbl_domhsh_tbl *netlbl_domhsh = NULL;
57
58/* Default domain mapping */
59static DEFINE_SPINLOCK(netlbl_domhsh_def_lock);
60static struct netlbl_dom_map *netlbl_domhsh_def = NULL; 57static struct netlbl_dom_map *netlbl_domhsh_def = NULL;
61 58
62/* 59/*
@@ -239,24 +236,22 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
239 INIT_RCU_HEAD(&entry->rcu); 236 INIT_RCU_HEAD(&entry->rcu);
240 237
241 rcu_read_lock(); 238 rcu_read_lock();
239 spin_lock(&netlbl_domhsh_lock);
242 if (entry->domain != NULL) { 240 if (entry->domain != NULL) {
243 bkt = netlbl_domhsh_hash(entry->domain); 241 bkt = netlbl_domhsh_hash(entry->domain);
244 spin_lock(&netlbl_domhsh_lock);
245 if (netlbl_domhsh_search(entry->domain) == NULL) 242 if (netlbl_domhsh_search(entry->domain) == NULL)
246 list_add_tail_rcu(&entry->list, 243 list_add_tail_rcu(&entry->list,
247 &rcu_dereference(netlbl_domhsh)->tbl[bkt]); 244 &rcu_dereference(netlbl_domhsh)->tbl[bkt]);
248 else 245 else
249 ret_val = -EEXIST; 246 ret_val = -EEXIST;
250 spin_unlock(&netlbl_domhsh_lock);
251 } else { 247 } else {
252 INIT_LIST_HEAD(&entry->list); 248 INIT_LIST_HEAD(&entry->list);
253 spin_lock(&netlbl_domhsh_def_lock);
254 if (rcu_dereference(netlbl_domhsh_def) == NULL) 249 if (rcu_dereference(netlbl_domhsh_def) == NULL)
255 rcu_assign_pointer(netlbl_domhsh_def, entry); 250 rcu_assign_pointer(netlbl_domhsh_def, entry);
256 else 251 else
257 ret_val = -EEXIST; 252 ret_val = -EEXIST;
258 spin_unlock(&netlbl_domhsh_def_lock);
259 } 253 }
254 spin_unlock(&netlbl_domhsh_lock);
260 audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_ADD, audit_info); 255 audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_ADD, audit_info);
261 if (audit_buf != NULL) { 256 if (audit_buf != NULL) {
262 audit_log_format(audit_buf, 257 audit_log_format(audit_buf,
@@ -337,23 +332,16 @@ int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info)
337 entry->domain); 332 entry->domain);
338 break; 333 break;
339 } 334 }
340 if (entry != rcu_dereference(netlbl_domhsh_def)) { 335 spin_lock(&netlbl_domhsh_lock);
341 spin_lock(&netlbl_domhsh_lock); 336 if (entry->valid) {
342 if (entry->valid) { 337 entry->valid = 0;
343 entry->valid = 0; 338 if (entry != rcu_dereference(netlbl_domhsh_def))
344 list_del_rcu(&entry->list); 339 list_del_rcu(&entry->list);
345 ret_val = 0; 340 else
346 }
347 spin_unlock(&netlbl_domhsh_lock);
348 } else {
349 spin_lock(&netlbl_domhsh_def_lock);
350 if (entry->valid) {
351 entry->valid = 0;
352 rcu_assign_pointer(netlbl_domhsh_def, NULL); 341 rcu_assign_pointer(netlbl_domhsh_def, NULL);
353 ret_val = 0; 342 ret_val = 0;
354 }
355 spin_unlock(&netlbl_domhsh_def_lock);
356 } 343 }
344 spin_unlock(&netlbl_domhsh_lock);
357 345
358 audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_DEL, audit_info); 346 audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_DEL, audit_info);
359 if (audit_buf != NULL) { 347 if (audit_buf != NULL) {