Lines Matching full:entry

55  * netlbl_domhsh_free_entry - Frees a domain hash table entry
56 * @entry: the entry's RCU field
60 * function so that the memory allocated to a hash table entry can be released
64 static void netlbl_domhsh_free_entry(struct rcu_head *entry) in netlbl_domhsh_free_entry() argument
74 ptr = container_of(entry, struct netlbl_dom_map, rcu); in netlbl_domhsh_free_entry()
125 * netlbl_domhsh_search - Search for a domain entry
131 * entry if found, otherwise NULL is returned. @family may be %AF_UNSPEC
159 * netlbl_domhsh_search_def - Search for a domain entry
165 * entry if an exact match is found, if an exact match is not present in the
166 * hash table then the default entry is returned if valid otherwise NULL is
175 struct netlbl_dom_map *entry; in netlbl_domhsh_search_def() local
177 entry = netlbl_domhsh_search(domain, family); in netlbl_domhsh_search_def()
178 if (entry != NULL) in netlbl_domhsh_search_def()
179 return entry; in netlbl_domhsh_search_def()
181 entry = netlbl_domhsh_rcu_deref(netlbl_domhsh_def_ipv4); in netlbl_domhsh_search_def()
182 if (entry != NULL && entry->valid) in netlbl_domhsh_search_def()
183 return entry; in netlbl_domhsh_search_def()
186 entry = netlbl_domhsh_rcu_deref(netlbl_domhsh_def_ipv6); in netlbl_domhsh_search_def()
187 if (entry != NULL && entry->valid) in netlbl_domhsh_search_def()
188 return entry; in netlbl_domhsh_search_def()
195 * netlbl_domhsh_audit_add - Generate an audit entry for an add event
196 * @entry: the entry being added
203 * Generate an audit record for adding a new NetLabel/LSM mapping entry with
208 static void netlbl_domhsh_audit_add(struct netlbl_dom_map *entry, in netlbl_domhsh_audit_add() argument
222 entry->domain ? entry->domain : "(default)"); in netlbl_domhsh_audit_add()
240 type = entry->def.type; in netlbl_domhsh_audit_add()
241 cipsov4 = entry->def.cipso; in netlbl_domhsh_audit_add()
242 calipso = entry->def.calipso; in netlbl_domhsh_audit_add()
267 * netlbl_domhsh_validate - Validate a new domain mapping entry
268 * @entry: the entry to validate
270 * This function validates the new domain mapping entry to ensure that it is
271 * a valid entry. Returns zero on success, negative values on failure.
274 static int netlbl_domhsh_validate(const struct netlbl_dom_map *entry) in netlbl_domhsh_validate() argument
283 if (entry == NULL) in netlbl_domhsh_validate()
286 if (entry->family != AF_INET && entry->family != AF_INET6 && in netlbl_domhsh_validate()
287 (entry->family != AF_UNSPEC || in netlbl_domhsh_validate()
288 entry->def.type != NETLBL_NLTYPE_UNLABELED)) in netlbl_domhsh_validate()
291 switch (entry->def.type) { in netlbl_domhsh_validate()
293 if (entry->def.cipso != NULL || entry->def.calipso != NULL || in netlbl_domhsh_validate()
294 entry->def.addrsel != NULL) in netlbl_domhsh_validate()
298 if (entry->family != AF_INET || in netlbl_domhsh_validate()
299 entry->def.cipso == NULL) in netlbl_domhsh_validate()
303 if (entry->family != AF_INET6 || in netlbl_domhsh_validate()
304 entry->def.calipso == NULL) in netlbl_domhsh_validate()
308 netlbl_af4list_foreach(iter4, &entry->def.addrsel->list4) { in netlbl_domhsh_validate()
324 netlbl_af6list_foreach(iter6, &entry->def.addrsel->list6) { in netlbl_domhsh_validate()
392 * netlbl_domhsh_add - Adds a entry to the domain hash table
393 * @entry: the entry to add
397 * Adds a new entry to the domain hash table and handles any updates to the
398 * lower level protocol handler (i.e. CIPSO). @entry->family may be set to
399 * %AF_UNSPEC which will add an entry that matches all address families. This
401 * existing entry for any address family with the same domain. Returns zero
405 int netlbl_domhsh_add(struct netlbl_dom_map *entry, in netlbl_domhsh_add() argument
417 ret_val = netlbl_domhsh_validate(entry); in netlbl_domhsh_add()
427 if (entry->domain != NULL) in netlbl_domhsh_add()
428 entry_old = netlbl_domhsh_search(entry->domain, entry->family); in netlbl_domhsh_add()
430 entry_old = netlbl_domhsh_search_def(entry->domain, in netlbl_domhsh_add()
431 entry->family); in netlbl_domhsh_add()
433 entry->valid = 1; in netlbl_domhsh_add()
435 if (entry->domain != NULL) { in netlbl_domhsh_add()
436 u32 bkt = netlbl_domhsh_hash(entry->domain); in netlbl_domhsh_add()
437 list_add_tail_rcu(&entry->list, in netlbl_domhsh_add()
440 INIT_LIST_HEAD(&entry->list); in netlbl_domhsh_add()
441 switch (entry->family) { in netlbl_domhsh_add()
444 entry); in netlbl_domhsh_add()
448 entry); in netlbl_domhsh_add()
451 if (entry->def.type != in netlbl_domhsh_add()
464 entry->family = AF_INET; in netlbl_domhsh_add()
466 entry); in netlbl_domhsh_add()
478 if (entry->def.type == NETLBL_NLTYPE_ADDRSELECT) { in netlbl_domhsh_add()
480 &entry->def.addrsel->list4) in netlbl_domhsh_add()
481 netlbl_domhsh_audit_add(entry, iter4, NULL, in netlbl_domhsh_add()
485 &entry->def.addrsel->list6) in netlbl_domhsh_add()
486 netlbl_domhsh_audit_add(entry, NULL, iter6, in netlbl_domhsh_add()
490 netlbl_domhsh_audit_add(entry, NULL, NULL, in netlbl_domhsh_add()
493 entry->def.type == NETLBL_NLTYPE_ADDRSELECT) { in netlbl_domhsh_add()
502 netlbl_af4list_foreach_rcu(iter4, &entry->def.addrsel->list4) in netlbl_domhsh_add()
510 netlbl_af6list_foreach_rcu(iter6, &entry->def.addrsel->list6) in netlbl_domhsh_add()
520 &entry->def.addrsel->list4) { in netlbl_domhsh_add()
531 &entry->def.addrsel->list6) { in netlbl_domhsh_add()
541 /* cleanup the new entry since we've moved everything over */ in netlbl_domhsh_add()
542 netlbl_domhsh_free_entry(&entry->rcu); in netlbl_domhsh_add()
553 * netlbl_domhsh_add_default - Adds the default entry to the domain hash table
554 * @entry: the entry to add
558 * Adds a new default entry to the domain hash table and handles any updates
563 int netlbl_domhsh_add_default(struct netlbl_dom_map *entry, in netlbl_domhsh_add_default() argument
566 return netlbl_domhsh_add(entry, audit_info); in netlbl_domhsh_add_default()
570 * netlbl_domhsh_remove_entry - Removes a given entry from the domain table
571 * @entry: the entry to remove
575 * Removes an entry from the domain hash table and handles any updates to the
581 int netlbl_domhsh_remove_entry(struct netlbl_dom_map *entry, in netlbl_domhsh_remove_entry() argument
593 if (entry == NULL) in netlbl_domhsh_remove_entry()
597 if (entry->valid) { in netlbl_domhsh_remove_entry()
598 entry->valid = 0; in netlbl_domhsh_remove_entry()
599 if (entry == rcu_dereference(netlbl_domhsh_def_ipv4)) in netlbl_domhsh_remove_entry()
601 else if (entry == rcu_dereference(netlbl_domhsh_def_ipv6)) in netlbl_domhsh_remove_entry()
604 list_del_rcu(&entry->list); in netlbl_domhsh_remove_entry()
616 entry->domain ? entry->domain : "(default)"); in netlbl_domhsh_remove_entry()
620 switch (entry->def.type) { in netlbl_domhsh_remove_entry()
622 netlbl_af4list_foreach_rcu(iter4, &entry->def.addrsel->list4) { in netlbl_domhsh_remove_entry()
627 netlbl_af6list_foreach_rcu(iter6, &entry->def.addrsel->list6) { in netlbl_domhsh_remove_entry()
634 cipso_v4_doi_putdef(entry->def.cipso); in netlbl_domhsh_remove_entry()
638 calipso_doi_putdef(entry->def.calipso); in netlbl_domhsh_remove_entry()
642 call_rcu(&entry->rcu, netlbl_domhsh_free_entry); in netlbl_domhsh_remove_entry()
648 * netlbl_domhsh_remove_af4 - Removes an address selector entry
671 struct netlbl_domaddr4_map *entry; in netlbl_domhsh_remove_af4() local
705 entry = netlbl_domhsh_addr4_entry(entry_addr); in netlbl_domhsh_remove_af4()
706 cipso_v4_doi_putdef(entry->def.cipso); in netlbl_domhsh_remove_af4()
707 kfree(entry); in netlbl_domhsh_remove_af4()
717 * netlbl_domhsh_remove_af6 - Removes an address selector entry
738 struct netlbl_domaddr6_map *entry; in netlbl_domhsh_remove_af6() local
770 entry = netlbl_domhsh_addr6_entry(entry_addr); in netlbl_domhsh_remove_af6()
771 calipso_doi_putdef(entry->def.calipso); in netlbl_domhsh_remove_af6()
772 kfree(entry); in netlbl_domhsh_remove_af6()
782 * netlbl_domhsh_remove - Removes an entry from the domain hash table
788 * Removes an entry from the domain hash table and handles any updates to the
798 struct netlbl_dom_map *entry; in netlbl_domhsh_remove() local
804 entry = netlbl_domhsh_search(domain, AF_INET); in netlbl_domhsh_remove()
806 entry = netlbl_domhsh_search_def(domain, AF_INET); in netlbl_domhsh_remove()
807 ret_val = netlbl_domhsh_remove_entry(entry, audit_info); in netlbl_domhsh_remove()
815 entry = netlbl_domhsh_search(domain, AF_INET6); in netlbl_domhsh_remove()
817 entry = netlbl_domhsh_search_def(domain, AF_INET6); in netlbl_domhsh_remove()
818 ret_val2 = netlbl_domhsh_remove_entry(entry, audit_info); in netlbl_domhsh_remove()
829 * netlbl_domhsh_remove_default - Removes the default entry from the table
834 * Removes/resets the default entry corresponding to @family from the domain
846 * netlbl_domhsh_getentry - Get an entry from the domain hash table
851 * Look through the domain hash table searching for an entry to match @domain,
852 * with address family @family, return a pointer to a copy of the entry or
865 * netlbl_domhsh_getentry_af4 - Get an entry from the domain hash table
870 * Look through the domain hash table searching for an entry to match @domain
871 * and @addr, return a pointer to a copy of the entry or NULL. The caller is
895 * netlbl_domhsh_getentry_af6 - Get an entry from the domain hash table
900 * Look through the domain hash table searching for an entry to match @domain
901 * and @addr, return a pointer to a copy of the entry or NULL. The caller is
928 * @callback: callback for each entry
933 * buckets and @skip_chain entries. For each entry in the table call
941 int (*callback) (struct netlbl_dom_map *entry, void *arg), in netlbl_domhsh_walk()