aboutsummaryrefslogtreecommitdiff
path: root/net/netlabel/netlabel_domainhash.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-26 08:43:05 -0700
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-26 08:43:05 -0700
commitec3b67c11df42362ccda81261d62829042f223f0 (patch)
treeab66bc43d98e38eda7162f76208993b2280f88f3 /net/netlabel/netlabel_domainhash.c
parente868171a94b637158a3930c9adfb448d0df163cd (diff)
parent4be2700fb7b95f2a7cef9324879cafccab8774fc (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (32 commits) [NetLabel]: correct usage of RCU locking [TCP]: fix D-SACK cwnd handling [NET] napi: use non-interruptible sleep in napi_disable [SCTP] net/sctp/auth.c: make 3 functions static [TCP]: Add missing I/O AT code to ipv6 side. [SCTP]: #if 0 sctp_update_copy_cksum() [INET]: Unexport icmpmsg_statistics [NET]: Unexport sock_enable_timestamp(). [TCP]: Make tcp_match_skb_to_sack() static. [IRDA]: Make ircomm_tty static. [NET] fs/proc/proc_net.c: make a struct static [NET] dev_change_name: ignore changes to same name [NET]: Document some simple rules for actions [NET_CLS_ACT]: Use skb_act_clone [NET_CLS_ACT]: Introduce skb_act_clone [TCP]: Fix scatterlist handling in MD5 signature support. [IPSEC]: Fix scatterlist handling in skb_icv_walk(). [IPSEC]: Add missing sg_init_table() calls to ESP. [CRYPTO]: Initialize TCRYPT on-stack scatterlist objects correctly. [CRYPTO]: HMAC needs some more scatterlist fixups. ...
Diffstat (limited to 'net/netlabel/netlabel_domainhash.c')
-rw-r--r--net/netlabel/netlabel_domainhash.c37
1 files changed, 11 insertions, 26 deletions
diff --git a/net/netlabel/netlabel_domainhash.c b/net/netlabel/netlabel_domainhash.c
index b6c844b7e1c..b3675bd7db3 100644
--- a/net/netlabel/netlabel_domainhash.c
+++ b/net/netlabel/netlabel_domainhash.c
@@ -178,11 +178,9 @@ int netlbl_domhsh_init(u32 size)
for (iter = 0; iter < hsh_tbl->size; iter++)
INIT_LIST_HEAD(&hsh_tbl->tbl[iter]);
- rcu_read_lock();
spin_lock(&netlbl_domhsh_lock);
rcu_assign_pointer(netlbl_domhsh, hsh_tbl);
spin_unlock(&netlbl_domhsh_lock);
- rcu_read_unlock();
return 0;
}
@@ -222,7 +220,6 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
entry->valid = 1;
INIT_RCU_HEAD(&entry->rcu);
- ret_val = 0;
rcu_read_lock();
if (entry->domain != NULL) {
bkt = netlbl_domhsh_hash(entry->domain);
@@ -233,7 +230,7 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
else
ret_val = -EEXIST;
spin_unlock(&netlbl_domhsh_lock);
- } else if (entry->domain == NULL) {
+ } else {
INIT_LIST_HEAD(&entry->list);
spin_lock(&netlbl_domhsh_def_lock);
if (rcu_dereference(netlbl_domhsh_def) == NULL)
@@ -241,9 +238,7 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
else
ret_val = -EEXIST;
spin_unlock(&netlbl_domhsh_def_lock);
- } else
- ret_val = -EINVAL;
-
+ }
audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_ADD, audit_info);
if (audit_buf != NULL) {
audit_log_format(audit_buf,
@@ -262,7 +257,6 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
audit_log_format(audit_buf, " res=%u", ret_val == 0 ? 1 : 0);
audit_log_end(audit_buf);
}
-
rcu_read_unlock();
if (ret_val != 0) {
@@ -313,38 +307,30 @@ int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info)
struct audit_buffer *audit_buf;
rcu_read_lock();
- if (domain != NULL)
- entry = netlbl_domhsh_search(domain, 0);
- else
- entry = netlbl_domhsh_search(domain, 1);
+ entry = netlbl_domhsh_search(domain, (domain != NULL ? 0 : 1));
if (entry == NULL)
goto remove_return;
switch (entry->type) {
- case NETLBL_NLTYPE_UNLABELED:
- break;
case NETLBL_NLTYPE_CIPSOV4:
- ret_val = cipso_v4_doi_domhsh_remove(entry->type_def.cipsov4,
- entry->domain);
- if (ret_val != 0)
- goto remove_return;
+ cipso_v4_doi_domhsh_remove(entry->type_def.cipsov4,
+ entry->domain);
break;
}
- ret_val = 0;
if (entry != rcu_dereference(netlbl_domhsh_def)) {
spin_lock(&netlbl_domhsh_lock);
if (entry->valid) {
entry->valid = 0;
list_del_rcu(&entry->list);
- } else
- ret_val = -ENOENT;
+ ret_val = 0;
+ }
spin_unlock(&netlbl_domhsh_lock);
} else {
spin_lock(&netlbl_domhsh_def_lock);
if (entry->valid) {
entry->valid = 0;
rcu_assign_pointer(netlbl_domhsh_def, NULL);
- } else
- ret_val = -ENOENT;
+ ret_val = 0;
+ }
spin_unlock(&netlbl_domhsh_def_lock);
}
@@ -357,11 +343,10 @@ int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info)
audit_log_end(audit_buf);
}
- if (ret_val == 0)
- call_rcu(&entry->rcu, netlbl_domhsh_free_entry);
-
remove_return:
rcu_read_unlock();
+ if (ret_val == 0)
+ call_rcu(&entry->rcu, netlbl_domhsh_free_entry);
return ret_val;
}