Lines Matching refs: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)
74 ptr = container_of(entry, struct netlbl_dom_map, rcu);
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;
177 entry = netlbl_domhsh_search(domain, family);
178 if (entry != NULL)
179 return entry;
181 entry = netlbl_domhsh_rcu_deref(netlbl_domhsh_def_ipv4);
182 if (entry != NULL && entry->valid)
183 return entry;
186 entry = netlbl_domhsh_rcu_deref(netlbl_domhsh_def_ipv6);
187 if (entry != NULL && entry->valid)
188 return entry;
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,
222 entry->domain ? entry->domain : "(default)");
240 type = entry->def.type;
241 cipsov4 = entry->def.cipso;
242 calipso = entry->def.calipso;
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)
283 if (entry == NULL)
286 if (entry->family != AF_INET && entry->family != AF_INET6 &&
287 (entry->family != AF_UNSPEC ||
288 entry->def.type != NETLBL_NLTYPE_UNLABELED))
291 switch (entry->def.type) {
293 if (entry->def.cipso != NULL || entry->def.calipso != NULL ||
294 entry->def.addrsel != NULL)
298 if (entry->family != AF_INET ||
299 entry->def.cipso == NULL)
303 if (entry->family != AF_INET6 ||
304 entry->def.calipso == NULL)
308 netlbl_af4list_foreach(iter4, &entry->def.addrsel->list4) {
324 netlbl_af6list_foreach(iter6, &entry->def.addrsel->list6) {
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,
417 ret_val = netlbl_domhsh_validate(entry);
427 if (entry->domain != NULL)
428 entry_old = netlbl_domhsh_search(entry->domain, entry->family);
430 entry_old = netlbl_domhsh_search_def(entry->domain,
431 entry->family);
433 entry->valid = 1;
435 if (entry->domain != NULL) {
436 u32 bkt = netlbl_domhsh_hash(entry->domain);
437 list_add_tail_rcu(&entry->list,
440 INIT_LIST_HEAD(&entry->list);
441 switch (entry->family) {
444 entry);
448 entry);
451 if (entry->def.type !=
464 entry->family = AF_INET;
466 entry);
478 if (entry->def.type == NETLBL_NLTYPE_ADDRSELECT) {
480 &entry->def.addrsel->list4)
481 netlbl_domhsh_audit_add(entry, iter4, NULL,
485 &entry->def.addrsel->list6)
486 netlbl_domhsh_audit_add(entry, NULL, iter6,
490 netlbl_domhsh_audit_add(entry, NULL, NULL,
493 entry->def.type == NETLBL_NLTYPE_ADDRSELECT) {
502 netlbl_af4list_foreach_rcu(iter4, &entry->def.addrsel->list4)
510 netlbl_af6list_foreach_rcu(iter6, &entry->def.addrsel->list6)
520 &entry->def.addrsel->list4) {
531 &entry->def.addrsel->list6) {
541 /* cleanup the new entry since we've moved everything over */
542 netlbl_domhsh_free_entry(&entry->rcu);
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,
566 return netlbl_domhsh_add(entry, audit_info);
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,
593 if (entry == NULL)
597 if (entry->valid) {
598 entry->valid = 0;
599 if (entry == rcu_dereference(netlbl_domhsh_def_ipv4))
601 else if (entry == rcu_dereference(netlbl_domhsh_def_ipv6))
604 list_del_rcu(&entry->list);
616 entry->domain ? entry->domain : "(default)");
620 switch (entry->def.type) {
622 netlbl_af4list_foreach_rcu(iter4, &entry->def.addrsel->list4) {
627 netlbl_af6list_foreach_rcu(iter6, &entry->def.addrsel->list6) {
634 cipso_v4_doi_putdef(entry->def.cipso);
638 calipso_doi_putdef(entry->def.calipso);
642 call_rcu(&entry->rcu, netlbl_domhsh_free_entry);
648 * netlbl_domhsh_remove_af4 - Removes an address selector entry
671 struct netlbl_domaddr4_map *entry;
705 entry = netlbl_domhsh_addr4_entry(entry_addr);
706 cipso_v4_doi_putdef(entry->def.cipso);
707 kfree(entry);
717 * netlbl_domhsh_remove_af6 - Removes an address selector entry
738 struct netlbl_domaddr6_map *entry;
770 entry = netlbl_domhsh_addr6_entry(entry_addr);
771 calipso_doi_putdef(entry->def.calipso);
772 kfree(entry);
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;
804 entry = netlbl_domhsh_search(domain, AF_INET);
806 entry = netlbl_domhsh_search_def(domain, AF_INET);
807 ret_val = netlbl_domhsh_remove_entry(entry, audit_info);
815 entry = netlbl_domhsh_search(domain, AF_INET6);
817 entry = netlbl_domhsh_search_def(domain, AF_INET6);
818 ret_val2 = netlbl_domhsh_remove_entry(entry, audit_info);
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),