| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * NetLabel Domain Hash Table | 
|  | 3 | * | 
|  | 4 | * This file manages the domain hash table that NetLabel uses to determine | 
|  | 5 | * which network labeling protocol to use for a given domain.  The NetLabel | 
|  | 6 | * system manages static and dynamic label mappings for network protocols such | 
|  | 7 | * as CIPSO and RIPSO. | 
|  | 8 | * | 
|  | 9 | * Author: Paul Moore <paul.moore@hp.com> | 
|  | 10 | * | 
|  | 11 | */ | 
|  | 12 |  | 
|  | 13 | /* | 
| Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 14 | * (c) Copyright Hewlett-Packard Development Company, L.P., 2006, 2008 | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 15 | * | 
|  | 16 | * This program is free software;  you can redistribute it and/or modify | 
|  | 17 | * it under the terms of the GNU General Public License as published by | 
|  | 18 | * the Free Software Foundation; either version 2 of the License, or | 
|  | 19 | * (at your option) any later version. | 
|  | 20 | * | 
|  | 21 | * This program is distributed in the hope that it will be useful, | 
|  | 22 | * but WITHOUT ANY WARRANTY;  without even the implied warranty of | 
|  | 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See | 
|  | 24 | * the GNU General Public License for more details. | 
|  | 25 | * | 
|  | 26 | * You should have received a copy of the GNU General Public License | 
|  | 27 | * along with this program;  if not, write to the Free Software | 
|  | 28 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 
|  | 29 | * | 
|  | 30 | */ | 
|  | 31 |  | 
|  | 32 | #include <linux/types.h> | 
| Franck Bui-Huu | 8252474 | 2008-05-12 21:21:05 +0200 | [diff] [blame] | 33 | #include <linux/rculist.h> | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 34 | #include <linux/skbuff.h> | 
|  | 35 | #include <linux/spinlock.h> | 
|  | 36 | #include <linux/string.h> | 
| Paul Moore | 32f50cd | 2006-09-28 14:51:47 -0700 | [diff] [blame] | 37 | #include <linux/audit.h> | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 38 | #include <net/netlabel.h> | 
|  | 39 | #include <net/cipso_ipv4.h> | 
|  | 40 | #include <asm/bug.h> | 
|  | 41 |  | 
|  | 42 | #include "netlabel_mgmt.h" | 
| Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 43 | #include "netlabel_addrlist.h" | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 44 | #include "netlabel_domainhash.h" | 
| Paul Moore | 32f50cd | 2006-09-28 14:51:47 -0700 | [diff] [blame] | 45 | #include "netlabel_user.h" | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 46 |  | 
|  | 47 | struct netlbl_domhsh_tbl { | 
|  | 48 | struct list_head *tbl; | 
|  | 49 | u32 size; | 
|  | 50 | }; | 
|  | 51 |  | 
|  | 52 | /* Domain hash table */ | 
|  | 53 | /* XXX - updates should be so rare that having one spinlock for the entire | 
|  | 54 | * hash table should be okay */ | 
| Adrian Bunk | 8ce11e6 | 2006-08-07 21:50:48 -0700 | [diff] [blame] | 55 | static DEFINE_SPINLOCK(netlbl_domhsh_lock); | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 56 | static struct netlbl_domhsh_tbl *netlbl_domhsh = NULL; | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 57 | static struct netlbl_dom_map *netlbl_domhsh_def = NULL; | 
|  | 58 |  | 
|  | 59 | /* | 
|  | 60 | * Domain Hash Table Helper Functions | 
|  | 61 | */ | 
|  | 62 |  | 
|  | 63 | /** | 
|  | 64 | * netlbl_domhsh_free_entry - Frees a domain hash table entry | 
|  | 65 | * @entry: the entry's RCU field | 
|  | 66 | * | 
|  | 67 | * Description: | 
|  | 68 | * This function is designed to be used as a callback to the call_rcu() | 
|  | 69 | * function so that the memory allocated to a hash table entry can be released | 
|  | 70 | * safely. | 
|  | 71 | * | 
|  | 72 | */ | 
|  | 73 | static void netlbl_domhsh_free_entry(struct rcu_head *entry) | 
|  | 74 | { | 
|  | 75 | struct netlbl_dom_map *ptr; | 
| Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 76 | struct netlbl_af4list *iter4; | 
|  | 77 | struct netlbl_af4list *tmp4; | 
|  | 78 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 
|  | 79 | struct netlbl_af6list *iter6; | 
|  | 80 | struct netlbl_af6list *tmp6; | 
|  | 81 | #endif /* IPv6 */ | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 82 |  | 
|  | 83 | ptr = container_of(entry, struct netlbl_dom_map, rcu); | 
| Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 84 | if (ptr->type == NETLBL_NLTYPE_ADDRSELECT) { | 
|  | 85 | netlbl_af4list_foreach_safe(iter4, tmp4, | 
|  | 86 | &ptr->type_def.addrsel->list4) { | 
|  | 87 | netlbl_af4list_remove_entry(iter4); | 
|  | 88 | kfree(netlbl_domhsh_addr4_entry(iter4)); | 
|  | 89 | } | 
|  | 90 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 
|  | 91 | netlbl_af6list_foreach_safe(iter6, tmp6, | 
|  | 92 | &ptr->type_def.addrsel->list6) { | 
|  | 93 | netlbl_af6list_remove_entry(iter6); | 
|  | 94 | kfree(netlbl_domhsh_addr6_entry(iter6)); | 
|  | 95 | } | 
|  | 96 | #endif /* IPv6 */ | 
|  | 97 | } | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 98 | kfree(ptr->domain); | 
|  | 99 | kfree(ptr); | 
|  | 100 | } | 
|  | 101 |  | 
|  | 102 | /** | 
|  | 103 | * netlbl_domhsh_hash - Hashing function for the domain hash table | 
|  | 104 | * @domain: the domain name to hash | 
|  | 105 | * | 
|  | 106 | * Description: | 
|  | 107 | * This is the hashing function for the domain hash table, it returns the | 
|  | 108 | * correct bucket number for the domain.  The caller is responsibile for | 
|  | 109 | * calling the rcu_read_[un]lock() functions. | 
|  | 110 | * | 
|  | 111 | */ | 
|  | 112 | static u32 netlbl_domhsh_hash(const char *key) | 
|  | 113 | { | 
|  | 114 | u32 iter; | 
|  | 115 | u32 val; | 
|  | 116 | u32 len; | 
|  | 117 |  | 
|  | 118 | /* This is taken (with slight modification) from | 
|  | 119 | * security/selinux/ss/symtab.c:symhash() */ | 
|  | 120 |  | 
|  | 121 | for (iter = 0, val = 0, len = strlen(key); iter < len; iter++) | 
|  | 122 | val = (val << 4 | (val >> (8 * sizeof(u32) - 4))) ^ key[iter]; | 
|  | 123 | return val & (rcu_dereference(netlbl_domhsh)->size - 1); | 
|  | 124 | } | 
|  | 125 |  | 
|  | 126 | /** | 
|  | 127 | * netlbl_domhsh_search - Search for a domain entry | 
|  | 128 | * @domain: the domain | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 129 | * | 
|  | 130 | * Description: | 
|  | 131 | * Searches the domain hash table and returns a pointer to the hash table | 
| Paul Moore | b64397e | 2008-01-29 08:37:54 -0500 | [diff] [blame] | 132 | * entry if found, otherwise NULL is returned.  The caller is responsibile for | 
|  | 133 | * the rcu hash table locks (i.e. the caller much call rcu_read_[un]lock()). | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 134 | * | 
|  | 135 | */ | 
| Paul Moore | b64397e | 2008-01-29 08:37:54 -0500 | [diff] [blame] | 136 | static struct netlbl_dom_map *netlbl_domhsh_search(const char *domain) | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 137 | { | 
|  | 138 | u32 bkt; | 
| Paul Moore | 5619670 | 2008-10-10 10:16:29 -0400 | [diff] [blame] | 139 | struct list_head *bkt_list; | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 140 | struct netlbl_dom_map *iter; | 
|  | 141 |  | 
|  | 142 | if (domain != NULL) { | 
|  | 143 | bkt = netlbl_domhsh_hash(domain); | 
| Paul Moore | 5619670 | 2008-10-10 10:16:29 -0400 | [diff] [blame] | 144 | bkt_list = &rcu_dereference(netlbl_domhsh)->tbl[bkt]; | 
|  | 145 | list_for_each_entry_rcu(iter, bkt_list, list) | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 146 | if (iter->valid && strcmp(iter->domain, domain) == 0) | 
|  | 147 | return iter; | 
|  | 148 | } | 
|  | 149 |  | 
| Paul Moore | b64397e | 2008-01-29 08:37:54 -0500 | [diff] [blame] | 150 | return NULL; | 
|  | 151 | } | 
|  | 152 |  | 
|  | 153 | /** | 
|  | 154 | * netlbl_domhsh_search_def - Search for a domain entry | 
|  | 155 | * @domain: the domain | 
|  | 156 | * @def: return default if no match is found | 
|  | 157 | * | 
|  | 158 | * Description: | 
|  | 159 | * Searches the domain hash table and returns a pointer to the hash table | 
|  | 160 | * entry if an exact match is found, if an exact match is not present in the | 
|  | 161 | * hash table then the default entry is returned if valid otherwise NULL is | 
|  | 162 | * returned.  The caller is responsibile for the rcu hash table locks | 
|  | 163 | * (i.e. the caller much call rcu_read_[un]lock()). | 
|  | 164 | * | 
|  | 165 | */ | 
|  | 166 | static struct netlbl_dom_map *netlbl_domhsh_search_def(const char *domain) | 
|  | 167 | { | 
|  | 168 | struct netlbl_dom_map *entry; | 
|  | 169 |  | 
|  | 170 | entry = netlbl_domhsh_search(domain); | 
|  | 171 | if (entry == NULL) { | 
|  | 172 | entry = rcu_dereference(netlbl_domhsh_def); | 
| Pavel Emelyanov | 4c3a0a2 | 2008-02-12 22:15:14 -0800 | [diff] [blame] | 173 | if (entry != NULL && !entry->valid) | 
|  | 174 | entry = NULL; | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 175 | } | 
|  | 176 |  | 
| Pavel Emelyanov | 4c3a0a2 | 2008-02-12 22:15:14 -0800 | [diff] [blame] | 177 | return entry; | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 178 | } | 
|  | 179 |  | 
| Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 180 | /** | 
|  | 181 | * netlbl_domhsh_audit_add - Generate an audit entry for an add event | 
|  | 182 | * @entry: the entry being added | 
|  | 183 | * @addr4: the IPv4 address information | 
|  | 184 | * @addr6: the IPv6 address information | 
|  | 185 | * @result: the result code | 
|  | 186 | * @audit_info: NetLabel audit information | 
|  | 187 | * | 
|  | 188 | * Description: | 
|  | 189 | * Generate an audit record for adding a new NetLabel/LSM mapping entry with | 
|  | 190 | * the given information.  Caller is responsibile for holding the necessary | 
|  | 191 | * locks. | 
|  | 192 | * | 
|  | 193 | */ | 
|  | 194 | static void netlbl_domhsh_audit_add(struct netlbl_dom_map *entry, | 
|  | 195 | struct netlbl_af4list *addr4, | 
|  | 196 | struct netlbl_af6list *addr6, | 
|  | 197 | int result, | 
|  | 198 | struct netlbl_audit *audit_info) | 
|  | 199 | { | 
|  | 200 | struct audit_buffer *audit_buf; | 
|  | 201 | struct cipso_v4_doi *cipsov4 = NULL; | 
|  | 202 | u32 type; | 
|  | 203 |  | 
|  | 204 | audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_ADD, audit_info); | 
|  | 205 | if (audit_buf != NULL) { | 
|  | 206 | audit_log_format(audit_buf, " nlbl_domain=%s", | 
|  | 207 | entry->domain ? entry->domain : "(default)"); | 
|  | 208 | if (addr4 != NULL) { | 
|  | 209 | struct netlbl_domaddr4_map *map4; | 
|  | 210 | map4 = netlbl_domhsh_addr4_entry(addr4); | 
|  | 211 | type = map4->type; | 
|  | 212 | cipsov4 = map4->type_def.cipsov4; | 
|  | 213 | netlbl_af4list_audit_addr(audit_buf, 0, NULL, | 
|  | 214 | addr4->addr, addr4->mask); | 
|  | 215 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 
|  | 216 | } else if (addr6 != NULL) { | 
|  | 217 | struct netlbl_domaddr6_map *map6; | 
|  | 218 | map6 = netlbl_domhsh_addr6_entry(addr6); | 
|  | 219 | type = map6->type; | 
|  | 220 | netlbl_af6list_audit_addr(audit_buf, 0, NULL, | 
|  | 221 | &addr6->addr, &addr6->mask); | 
|  | 222 | #endif /* IPv6 */ | 
|  | 223 | } else { | 
|  | 224 | type = entry->type; | 
|  | 225 | cipsov4 = entry->type_def.cipsov4; | 
|  | 226 | } | 
|  | 227 | switch (type) { | 
|  | 228 | case NETLBL_NLTYPE_UNLABELED: | 
|  | 229 | audit_log_format(audit_buf, " nlbl_protocol=unlbl"); | 
|  | 230 | break; | 
|  | 231 | case NETLBL_NLTYPE_CIPSOV4: | 
|  | 232 | BUG_ON(cipsov4 == NULL); | 
|  | 233 | audit_log_format(audit_buf, | 
|  | 234 | " nlbl_protocol=cipsov4 cipso_doi=%u", | 
|  | 235 | cipsov4->doi); | 
|  | 236 | break; | 
|  | 237 | } | 
|  | 238 | audit_log_format(audit_buf, " res=%u", result == 0 ? 1 : 0); | 
|  | 239 | audit_log_end(audit_buf); | 
|  | 240 | } | 
|  | 241 | } | 
|  | 242 |  | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 243 | /* | 
|  | 244 | * Domain Hash Table Functions | 
|  | 245 | */ | 
|  | 246 |  | 
|  | 247 | /** | 
|  | 248 | * netlbl_domhsh_init - Init for the domain hash | 
|  | 249 | * @size: the number of bits to use for the hash buckets | 
|  | 250 | * | 
|  | 251 | * Description: | 
|  | 252 | * Initializes the domain hash table, should be called only by | 
|  | 253 | * netlbl_user_init() during initialization.  Returns zero on success, non-zero | 
|  | 254 | * values on error. | 
|  | 255 | * | 
|  | 256 | */ | 
| Pavel Emelyanov | 05705e4 | 2008-02-17 22:33:57 -0800 | [diff] [blame] | 257 | int __init netlbl_domhsh_init(u32 size) | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 258 | { | 
|  | 259 | u32 iter; | 
|  | 260 | struct netlbl_domhsh_tbl *hsh_tbl; | 
|  | 261 |  | 
|  | 262 | if (size == 0) | 
|  | 263 | return -EINVAL; | 
|  | 264 |  | 
|  | 265 | hsh_tbl = kmalloc(sizeof(*hsh_tbl), GFP_KERNEL); | 
|  | 266 | if (hsh_tbl == NULL) | 
|  | 267 | return -ENOMEM; | 
|  | 268 | hsh_tbl->size = 1 << size; | 
|  | 269 | hsh_tbl->tbl = kcalloc(hsh_tbl->size, | 
|  | 270 | sizeof(struct list_head), | 
|  | 271 | GFP_KERNEL); | 
|  | 272 | if (hsh_tbl->tbl == NULL) { | 
|  | 273 | kfree(hsh_tbl); | 
|  | 274 | return -ENOMEM; | 
|  | 275 | } | 
|  | 276 | for (iter = 0; iter < hsh_tbl->size; iter++) | 
|  | 277 | INIT_LIST_HEAD(&hsh_tbl->tbl[iter]); | 
|  | 278 |  | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 279 | spin_lock(&netlbl_domhsh_lock); | 
|  | 280 | rcu_assign_pointer(netlbl_domhsh, hsh_tbl); | 
|  | 281 | spin_unlock(&netlbl_domhsh_lock); | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 282 |  | 
|  | 283 | return 0; | 
|  | 284 | } | 
|  | 285 |  | 
|  | 286 | /** | 
|  | 287 | * netlbl_domhsh_add - Adds a entry to the domain hash table | 
|  | 288 | * @entry: the entry to add | 
| Paul Moore | 95d4e6b | 2006-09-29 17:05:05 -0700 | [diff] [blame] | 289 | * @audit_info: NetLabel audit information | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 290 | * | 
|  | 291 | * Description: | 
|  | 292 | * Adds a new entry to the domain hash table and handles any updates to the | 
|  | 293 | * lower level protocol handler (i.e. CIPSO).  Returns zero on success, | 
|  | 294 | * negative on failure. | 
|  | 295 | * | 
|  | 296 | */ | 
| Paul Moore | 95d4e6b | 2006-09-29 17:05:05 -0700 | [diff] [blame] | 297 | int netlbl_domhsh_add(struct netlbl_dom_map *entry, | 
|  | 298 | struct netlbl_audit *audit_info) | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 299 | { | 
| Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 300 | int ret_val = 0; | 
|  | 301 | struct netlbl_dom_map *entry_old; | 
|  | 302 | struct netlbl_af4list *iter4; | 
|  | 303 | struct netlbl_af4list *tmp4; | 
|  | 304 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 
|  | 305 | struct netlbl_af6list *iter6; | 
|  | 306 | struct netlbl_af6list *tmp6; | 
|  | 307 | #endif /* IPv6 */ | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 308 |  | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 309 | rcu_read_lock(); | 
| Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 310 |  | 
| Paul Moore | 1c3fad9 | 2008-01-29 08:37:57 -0500 | [diff] [blame] | 311 | spin_lock(&netlbl_domhsh_lock); | 
| Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 312 | if (entry->domain != NULL) | 
|  | 313 | entry_old = netlbl_domhsh_search(entry->domain); | 
|  | 314 | else | 
|  | 315 | entry_old = netlbl_domhsh_search_def(entry->domain); | 
|  | 316 | if (entry_old == NULL) { | 
|  | 317 | entry->valid = 1; | 
| Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 318 |  | 
|  | 319 | if (entry->domain != NULL) { | 
|  | 320 | u32 bkt = netlbl_domhsh_hash(entry->domain); | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 321 | list_add_tail_rcu(&entry->list, | 
| Paul Moore | 3482fd9 | 2007-08-07 17:53:10 -0700 | [diff] [blame] | 322 | &rcu_dereference(netlbl_domhsh)->tbl[bkt]); | 
| Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 323 | } else { | 
|  | 324 | INIT_LIST_HEAD(&entry->list); | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 325 | rcu_assign_pointer(netlbl_domhsh_def, entry); | 
| Paul Moore | de64688 | 2006-11-17 17:38:55 -0500 | [diff] [blame] | 326 | } | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 327 |  | 
| Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 328 | if (entry->type == NETLBL_NLTYPE_ADDRSELECT) { | 
|  | 329 | netlbl_af4list_foreach_rcu(iter4, | 
|  | 330 | &entry->type_def.addrsel->list4) | 
|  | 331 | netlbl_domhsh_audit_add(entry, iter4, NULL, | 
|  | 332 | ret_val, audit_info); | 
|  | 333 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 
|  | 334 | netlbl_af6list_foreach_rcu(iter6, | 
|  | 335 | &entry->type_def.addrsel->list6) | 
|  | 336 | netlbl_domhsh_audit_add(entry, NULL, iter6, | 
|  | 337 | ret_val, audit_info); | 
|  | 338 | #endif /* IPv6 */ | 
|  | 339 | } else | 
|  | 340 | netlbl_domhsh_audit_add(entry, NULL, NULL, | 
|  | 341 | ret_val, audit_info); | 
|  | 342 | } else if (entry_old->type == NETLBL_NLTYPE_ADDRSELECT && | 
|  | 343 | entry->type == NETLBL_NLTYPE_ADDRSELECT) { | 
|  | 344 | struct list_head *old_list4; | 
|  | 345 | struct list_head *old_list6; | 
|  | 346 |  | 
|  | 347 | old_list4 = &entry_old->type_def.addrsel->list4; | 
|  | 348 | old_list6 = &entry_old->type_def.addrsel->list6; | 
|  | 349 |  | 
|  | 350 | /* we only allow the addition of address selectors if all of | 
|  | 351 | * the selectors do not exist in the existing domain map */ | 
|  | 352 | netlbl_af4list_foreach_rcu(iter4, | 
|  | 353 | &entry->type_def.addrsel->list4) | 
|  | 354 | if (netlbl_af4list_search_exact(iter4->addr, | 
|  | 355 | iter4->mask, | 
|  | 356 | old_list4)) { | 
|  | 357 | ret_val = -EEXIST; | 
|  | 358 | goto add_return; | 
|  | 359 | } | 
|  | 360 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 
|  | 361 | netlbl_af6list_foreach_rcu(iter6, | 
|  | 362 | &entry->type_def.addrsel->list6) | 
|  | 363 | if (netlbl_af6list_search_exact(&iter6->addr, | 
|  | 364 | &iter6->mask, | 
|  | 365 | old_list6)) { | 
|  | 366 | ret_val = -EEXIST; | 
|  | 367 | goto add_return; | 
|  | 368 | } | 
|  | 369 | #endif /* IPv6 */ | 
|  | 370 |  | 
|  | 371 | netlbl_af4list_foreach_safe(iter4, tmp4, | 
|  | 372 | &entry->type_def.addrsel->list4) { | 
|  | 373 | netlbl_af4list_remove_entry(iter4); | 
|  | 374 | iter4->valid = 1; | 
|  | 375 | ret_val = netlbl_af4list_add(iter4, old_list4); | 
|  | 376 | netlbl_domhsh_audit_add(entry_old, iter4, NULL, | 
|  | 377 | ret_val, audit_info); | 
|  | 378 | if (ret_val != 0) | 
|  | 379 | goto add_return; | 
|  | 380 | } | 
|  | 381 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 
|  | 382 | netlbl_af6list_foreach_safe(iter6, tmp6, | 
|  | 383 | &entry->type_def.addrsel->list6) { | 
|  | 384 | netlbl_af6list_remove_entry(iter6); | 
|  | 385 | iter6->valid = 1; | 
|  | 386 | ret_val = netlbl_af6list_add(iter6, old_list6); | 
|  | 387 | netlbl_domhsh_audit_add(entry_old, NULL, iter6, | 
|  | 388 | ret_val, audit_info); | 
|  | 389 | if (ret_val != 0) | 
|  | 390 | goto add_return; | 
|  | 391 | } | 
|  | 392 | #endif /* IPv6 */ | 
|  | 393 | } else | 
|  | 394 | ret_val = -EINVAL; | 
|  | 395 |  | 
|  | 396 | add_return: | 
|  | 397 | spin_unlock(&netlbl_domhsh_lock); | 
|  | 398 | rcu_read_unlock(); | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 399 | return ret_val; | 
|  | 400 | } | 
|  | 401 |  | 
|  | 402 | /** | 
|  | 403 | * netlbl_domhsh_add_default - Adds the default entry to the domain hash table | 
|  | 404 | * @entry: the entry to add | 
| Paul Moore | 95d4e6b | 2006-09-29 17:05:05 -0700 | [diff] [blame] | 405 | * @audit_info: NetLabel audit information | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 406 | * | 
|  | 407 | * Description: | 
|  | 408 | * Adds a new default entry to the domain hash table and handles any updates | 
|  | 409 | * to the lower level protocol handler (i.e. CIPSO).  Returns zero on success, | 
|  | 410 | * negative on failure. | 
|  | 411 | * | 
|  | 412 | */ | 
| Paul Moore | 95d4e6b | 2006-09-29 17:05:05 -0700 | [diff] [blame] | 413 | int netlbl_domhsh_add_default(struct netlbl_dom_map *entry, | 
|  | 414 | struct netlbl_audit *audit_info) | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 415 | { | 
| Paul Moore | 95d4e6b | 2006-09-29 17:05:05 -0700 | [diff] [blame] | 416 | return netlbl_domhsh_add(entry, audit_info); | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 417 | } | 
|  | 418 |  | 
|  | 419 | /** | 
| Paul Moore | b1edeb1 | 2008-10-10 10:16:31 -0400 | [diff] [blame] | 420 | * netlbl_domhsh_remove_entry - Removes a given entry from the domain table | 
|  | 421 | * @entry: the entry to remove | 
|  | 422 | * @audit_info: NetLabel audit information | 
|  | 423 | * | 
|  | 424 | * Description: | 
|  | 425 | * Removes an entry from the domain hash table and handles any updates to the | 
|  | 426 | * lower level protocol handler (i.e. CIPSO).  Caller is responsible for | 
|  | 427 | * ensuring that the RCU read lock is held.  Returns zero on success, negative | 
|  | 428 | * on failure. | 
|  | 429 | * | 
|  | 430 | */ | 
|  | 431 | int netlbl_domhsh_remove_entry(struct netlbl_dom_map *entry, | 
|  | 432 | struct netlbl_audit *audit_info) | 
|  | 433 | { | 
|  | 434 | int ret_val = 0; | 
|  | 435 | struct audit_buffer *audit_buf; | 
|  | 436 |  | 
|  | 437 | if (entry == NULL) | 
|  | 438 | return -ENOENT; | 
|  | 439 |  | 
|  | 440 | spin_lock(&netlbl_domhsh_lock); | 
|  | 441 | if (entry->valid) { | 
|  | 442 | entry->valid = 0; | 
|  | 443 | if (entry != rcu_dereference(netlbl_domhsh_def)) | 
|  | 444 | list_del_rcu(&entry->list); | 
|  | 445 | else | 
|  | 446 | rcu_assign_pointer(netlbl_domhsh_def, NULL); | 
|  | 447 | } else | 
|  | 448 | ret_val = -ENOENT; | 
|  | 449 | spin_unlock(&netlbl_domhsh_lock); | 
|  | 450 |  | 
|  | 451 | audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_DEL, audit_info); | 
|  | 452 | if (audit_buf != NULL) { | 
|  | 453 | audit_log_format(audit_buf, | 
|  | 454 | " nlbl_domain=%s res=%u", | 
|  | 455 | entry->domain ? entry->domain : "(default)", | 
|  | 456 | ret_val == 0 ? 1 : 0); | 
|  | 457 | audit_log_end(audit_buf); | 
|  | 458 | } | 
|  | 459 |  | 
|  | 460 | if (ret_val == 0) { | 
| Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 461 | struct netlbl_af4list *iter4; | 
|  | 462 | struct netlbl_domaddr4_map *map4; | 
|  | 463 |  | 
| Paul Moore | b1edeb1 | 2008-10-10 10:16:31 -0400 | [diff] [blame] | 464 | switch (entry->type) { | 
| Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 465 | case NETLBL_NLTYPE_ADDRSELECT: | 
|  | 466 | netlbl_af4list_foreach_rcu(iter4, | 
|  | 467 | &entry->type_def.addrsel->list4) { | 
|  | 468 | map4 = netlbl_domhsh_addr4_entry(iter4); | 
|  | 469 | cipso_v4_doi_putdef(map4->type_def.cipsov4); | 
|  | 470 | } | 
|  | 471 | /* no need to check the IPv6 list since we currently | 
|  | 472 | * support only unlabeled protocols for IPv6 */ | 
|  | 473 | break; | 
| Paul Moore | b1edeb1 | 2008-10-10 10:16:31 -0400 | [diff] [blame] | 474 | case NETLBL_NLTYPE_CIPSOV4: | 
|  | 475 | cipso_v4_doi_putdef(entry->type_def.cipsov4); | 
|  | 476 | break; | 
|  | 477 | } | 
|  | 478 | call_rcu(&entry->rcu, netlbl_domhsh_free_entry); | 
|  | 479 | } | 
|  | 480 |  | 
|  | 481 | return ret_val; | 
|  | 482 | } | 
|  | 483 |  | 
|  | 484 | /** | 
| Paul Moore | 6c2e8ac | 2008-12-31 12:54:11 -0500 | [diff] [blame] | 485 | * netlbl_domhsh_remove_af4 - Removes an address selector entry | 
|  | 486 | * @domain: the domain | 
|  | 487 | * @addr: IPv4 address | 
|  | 488 | * @mask: IPv4 address mask | 
|  | 489 | * @audit_info: NetLabel audit information | 
|  | 490 | * | 
|  | 491 | * Description: | 
|  | 492 | * Removes an individual address selector from a domain mapping and potentially | 
|  | 493 | * the entire mapping if it is empty.  Returns zero on success, negative values | 
|  | 494 | * on failure. | 
|  | 495 | * | 
|  | 496 | */ | 
|  | 497 | int netlbl_domhsh_remove_af4(const char *domain, | 
|  | 498 | const struct in_addr *addr, | 
|  | 499 | const struct in_addr *mask, | 
|  | 500 | struct netlbl_audit *audit_info) | 
|  | 501 | { | 
|  | 502 | struct netlbl_dom_map *entry_map; | 
|  | 503 | struct netlbl_af4list *entry_addr; | 
|  | 504 | struct netlbl_af4list *iter4; | 
|  | 505 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 
|  | 506 | struct netlbl_af6list *iter6; | 
|  | 507 | #endif /* IPv6 */ | 
|  | 508 | struct netlbl_domaddr4_map *entry; | 
|  | 509 |  | 
|  | 510 | rcu_read_lock(); | 
|  | 511 |  | 
|  | 512 | if (domain) | 
|  | 513 | entry_map = netlbl_domhsh_search(domain); | 
|  | 514 | else | 
|  | 515 | entry_map = netlbl_domhsh_search_def(domain); | 
|  | 516 | if (entry_map == NULL || entry_map->type != NETLBL_NLTYPE_ADDRSELECT) | 
|  | 517 | goto remove_af4_failure; | 
|  | 518 |  | 
|  | 519 | spin_lock(&netlbl_domhsh_lock); | 
|  | 520 | entry_addr = netlbl_af4list_remove(addr->s_addr, mask->s_addr, | 
|  | 521 | &entry_map->type_def.addrsel->list4); | 
|  | 522 | spin_unlock(&netlbl_domhsh_lock); | 
|  | 523 |  | 
|  | 524 | if (entry_addr == NULL) | 
|  | 525 | goto remove_af4_failure; | 
|  | 526 | netlbl_af4list_foreach_rcu(iter4, &entry_map->type_def.addrsel->list4) | 
|  | 527 | goto remove_af4_single_addr; | 
|  | 528 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 
|  | 529 | netlbl_af6list_foreach_rcu(iter6, &entry_map->type_def.addrsel->list6) | 
|  | 530 | goto remove_af4_single_addr; | 
|  | 531 | #endif /* IPv6 */ | 
|  | 532 | /* the domain mapping is empty so remove it from the mapping table */ | 
|  | 533 | netlbl_domhsh_remove_entry(entry_map, audit_info); | 
|  | 534 |  | 
|  | 535 | remove_af4_single_addr: | 
|  | 536 | rcu_read_unlock(); | 
|  | 537 | /* yick, we can't use call_rcu here because we don't have a rcu head | 
|  | 538 | * pointer but hopefully this should be a rare case so the pause | 
|  | 539 | * shouldn't be a problem */ | 
|  | 540 | synchronize_rcu(); | 
|  | 541 | entry = netlbl_domhsh_addr4_entry(entry_addr); | 
|  | 542 | cipso_v4_doi_putdef(entry->type_def.cipsov4); | 
|  | 543 | kfree(entry); | 
|  | 544 | return 0; | 
|  | 545 |  | 
|  | 546 | remove_af4_failure: | 
|  | 547 | rcu_read_unlock(); | 
|  | 548 | return -ENOENT; | 
|  | 549 | } | 
|  | 550 |  | 
|  | 551 | /** | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 552 | * netlbl_domhsh_remove - Removes an entry from the domain hash table | 
|  | 553 | * @domain: the domain to remove | 
| Paul Moore | 95d4e6b | 2006-09-29 17:05:05 -0700 | [diff] [blame] | 554 | * @audit_info: NetLabel audit information | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 555 | * | 
|  | 556 | * Description: | 
|  | 557 | * Removes an entry from the domain hash table and handles any updates to the | 
|  | 558 | * lower level protocol handler (i.e. CIPSO).  Returns zero on success, | 
|  | 559 | * negative on failure. | 
|  | 560 | * | 
|  | 561 | */ | 
| Paul Moore | 95d4e6b | 2006-09-29 17:05:05 -0700 | [diff] [blame] | 562 | int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info) | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 563 | { | 
| Paul Moore | b1edeb1 | 2008-10-10 10:16:31 -0400 | [diff] [blame] | 564 | int ret_val; | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 565 | struct netlbl_dom_map *entry; | 
|  | 566 |  | 
|  | 567 | rcu_read_lock(); | 
| Paul Moore | b64397e | 2008-01-29 08:37:54 -0500 | [diff] [blame] | 568 | if (domain) | 
|  | 569 | entry = netlbl_domhsh_search(domain); | 
|  | 570 | else | 
|  | 571 | entry = netlbl_domhsh_search_def(domain); | 
| Paul Moore | b1edeb1 | 2008-10-10 10:16:31 -0400 | [diff] [blame] | 572 | ret_val = netlbl_domhsh_remove_entry(entry, audit_info); | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 573 | rcu_read_unlock(); | 
| Paul Moore | b1edeb1 | 2008-10-10 10:16:31 -0400 | [diff] [blame] | 574 |  | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 575 | return ret_val; | 
|  | 576 | } | 
|  | 577 |  | 
|  | 578 | /** | 
|  | 579 | * netlbl_domhsh_remove_default - Removes the default entry from the table | 
| Paul Moore | 95d4e6b | 2006-09-29 17:05:05 -0700 | [diff] [blame] | 580 | * @audit_info: NetLabel audit information | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 581 | * | 
|  | 582 | * Description: | 
|  | 583 | * Removes/resets the default entry for the domain hash table and handles any | 
|  | 584 | * updates to the lower level protocol handler (i.e. CIPSO).  Returns zero on | 
|  | 585 | * success, non-zero on failure. | 
|  | 586 | * | 
|  | 587 | */ | 
| Paul Moore | 95d4e6b | 2006-09-29 17:05:05 -0700 | [diff] [blame] | 588 | int netlbl_domhsh_remove_default(struct netlbl_audit *audit_info) | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 589 | { | 
| Paul Moore | 95d4e6b | 2006-09-29 17:05:05 -0700 | [diff] [blame] | 590 | return netlbl_domhsh_remove(NULL, audit_info); | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 591 | } | 
|  | 592 |  | 
|  | 593 | /** | 
|  | 594 | * netlbl_domhsh_getentry - Get an entry from the domain hash table | 
|  | 595 | * @domain: the domain name to search for | 
|  | 596 | * | 
|  | 597 | * Description: | 
|  | 598 | * Look through the domain hash table searching for an entry to match @domain, | 
|  | 599 | * return a pointer to a copy of the entry or NULL.  The caller is responsibile | 
|  | 600 | * for ensuring that rcu_read_[un]lock() is called. | 
|  | 601 | * | 
|  | 602 | */ | 
|  | 603 | struct netlbl_dom_map *netlbl_domhsh_getentry(const char *domain) | 
|  | 604 | { | 
| Paul Moore | b64397e | 2008-01-29 08:37:54 -0500 | [diff] [blame] | 605 | return netlbl_domhsh_search_def(domain); | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 606 | } | 
|  | 607 |  | 
|  | 608 | /** | 
| Paul Moore | 63c4168 | 2008-10-10 10:16:32 -0400 | [diff] [blame] | 609 | * netlbl_domhsh_getentry_af4 - Get an entry from the domain hash table | 
|  | 610 | * @domain: the domain name to search for | 
|  | 611 | * @addr: the IP address to search for | 
|  | 612 | * | 
|  | 613 | * Description: | 
|  | 614 | * Look through the domain hash table searching for an entry to match @domain | 
|  | 615 | * and @addr, return a pointer to a copy of the entry or NULL.  The caller is | 
|  | 616 | * responsible for ensuring that rcu_read_[un]lock() is called. | 
|  | 617 | * | 
|  | 618 | */ | 
|  | 619 | struct netlbl_domaddr4_map *netlbl_domhsh_getentry_af4(const char *domain, | 
|  | 620 | __be32 addr) | 
|  | 621 | { | 
|  | 622 | struct netlbl_dom_map *dom_iter; | 
|  | 623 | struct netlbl_af4list *addr_iter; | 
|  | 624 |  | 
|  | 625 | dom_iter = netlbl_domhsh_search_def(domain); | 
|  | 626 | if (dom_iter == NULL) | 
|  | 627 | return NULL; | 
|  | 628 | if (dom_iter->type != NETLBL_NLTYPE_ADDRSELECT) | 
|  | 629 | return NULL; | 
|  | 630 |  | 
|  | 631 | addr_iter = netlbl_af4list_search(addr, | 
|  | 632 | &dom_iter->type_def.addrsel->list4); | 
|  | 633 | if (addr_iter == NULL) | 
|  | 634 | return NULL; | 
|  | 635 |  | 
|  | 636 | return netlbl_domhsh_addr4_entry(addr_iter); | 
|  | 637 | } | 
|  | 638 |  | 
|  | 639 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 
|  | 640 | /** | 
|  | 641 | * netlbl_domhsh_getentry_af6 - Get an entry from the domain hash table | 
|  | 642 | * @domain: the domain name to search for | 
|  | 643 | * @addr: the IP address to search for | 
|  | 644 | * | 
|  | 645 | * Description: | 
|  | 646 | * Look through the domain hash table searching for an entry to match @domain | 
|  | 647 | * and @addr, return a pointer to a copy of the entry or NULL.  The caller is | 
|  | 648 | * responsible for ensuring that rcu_read_[un]lock() is called. | 
|  | 649 | * | 
|  | 650 | */ | 
|  | 651 | struct netlbl_domaddr6_map *netlbl_domhsh_getentry_af6(const char *domain, | 
|  | 652 | const struct in6_addr *addr) | 
|  | 653 | { | 
|  | 654 | struct netlbl_dom_map *dom_iter; | 
|  | 655 | struct netlbl_af6list *addr_iter; | 
|  | 656 |  | 
|  | 657 | dom_iter = netlbl_domhsh_search_def(domain); | 
|  | 658 | if (dom_iter == NULL) | 
|  | 659 | return NULL; | 
|  | 660 | if (dom_iter->type != NETLBL_NLTYPE_ADDRSELECT) | 
|  | 661 | return NULL; | 
|  | 662 |  | 
|  | 663 | addr_iter = netlbl_af6list_search(addr, | 
|  | 664 | &dom_iter->type_def.addrsel->list6); | 
|  | 665 | if (addr_iter == NULL) | 
|  | 666 | return NULL; | 
|  | 667 |  | 
|  | 668 | return netlbl_domhsh_addr6_entry(addr_iter); | 
|  | 669 | } | 
|  | 670 | #endif /* IPv6 */ | 
|  | 671 |  | 
|  | 672 | /** | 
| Paul Moore | fcd4828 | 2006-09-25 15:56:09 -0700 | [diff] [blame] | 673 | * netlbl_domhsh_walk - Iterate through the domain mapping hash table | 
|  | 674 | * @skip_bkt: the number of buckets to skip at the start | 
|  | 675 | * @skip_chain: the number of entries to skip in the first iterated bucket | 
|  | 676 | * @callback: callback for each entry | 
|  | 677 | * @cb_arg: argument for the callback function | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 678 | * | 
|  | 679 | * Description: | 
| Paul Moore | fcd4828 | 2006-09-25 15:56:09 -0700 | [diff] [blame] | 680 | * Interate over the domain mapping hash table, skipping the first @skip_bkt | 
|  | 681 | * buckets and @skip_chain entries.  For each entry in the table call | 
|  | 682 | * @callback, if @callback returns a negative value stop 'walking' through the | 
|  | 683 | * table and return.  Updates the values in @skip_bkt and @skip_chain on | 
| André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 684 | * return.  Returns zero on success, negative values on failure. | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 685 | * | 
|  | 686 | */ | 
| Paul Moore | fcd4828 | 2006-09-25 15:56:09 -0700 | [diff] [blame] | 687 | int netlbl_domhsh_walk(u32 *skip_bkt, | 
|  | 688 | u32 *skip_chain, | 
|  | 689 | int (*callback) (struct netlbl_dom_map *entry, void *arg), | 
|  | 690 | void *cb_arg) | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 691 | { | 
| Paul Moore | fcd4828 | 2006-09-25 15:56:09 -0700 | [diff] [blame] | 692 | int ret_val = -ENOENT; | 
|  | 693 | u32 iter_bkt; | 
| Paul Moore | 5619670 | 2008-10-10 10:16:29 -0400 | [diff] [blame] | 694 | struct list_head *iter_list; | 
| Paul Moore | fcd4828 | 2006-09-25 15:56:09 -0700 | [diff] [blame] | 695 | struct netlbl_dom_map *iter_entry; | 
|  | 696 | u32 chain_cnt = 0; | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 697 |  | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 698 | rcu_read_lock(); | 
| Paul Moore | fcd4828 | 2006-09-25 15:56:09 -0700 | [diff] [blame] | 699 | for (iter_bkt = *skip_bkt; | 
|  | 700 | iter_bkt < rcu_dereference(netlbl_domhsh)->size; | 
|  | 701 | iter_bkt++, chain_cnt = 0) { | 
| Paul Moore | 5619670 | 2008-10-10 10:16:29 -0400 | [diff] [blame] | 702 | iter_list = &rcu_dereference(netlbl_domhsh)->tbl[iter_bkt]; | 
|  | 703 | list_for_each_entry_rcu(iter_entry, iter_list, list) | 
| Paul Moore | fcd4828 | 2006-09-25 15:56:09 -0700 | [diff] [blame] | 704 | if (iter_entry->valid) { | 
|  | 705 | if (chain_cnt++ < *skip_chain) | 
|  | 706 | continue; | 
|  | 707 | ret_val = callback(iter_entry, cb_arg); | 
|  | 708 | if (ret_val < 0) { | 
|  | 709 | chain_cnt--; | 
|  | 710 | goto walk_return; | 
|  | 711 | } | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 712 | } | 
| Paul Moore | fcd4828 | 2006-09-25 15:56:09 -0700 | [diff] [blame] | 713 | } | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 714 |  | 
| Paul Moore | fcd4828 | 2006-09-25 15:56:09 -0700 | [diff] [blame] | 715 | walk_return: | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 716 | rcu_read_unlock(); | 
| Paul Moore | fcd4828 | 2006-09-25 15:56:09 -0700 | [diff] [blame] | 717 | *skip_bkt = iter_bkt; | 
|  | 718 | *skip_chain = chain_cnt; | 
|  | 719 | return ret_val; | 
| Paul Moore | d15c345 | 2006-08-03 16:48:37 -0700 | [diff] [blame] | 720 | } |