Lines Matching +full:entry +full:- +full:address

1 // SPDX-License-Identifier: GPL-2.0-or-later
9 * Author: Paul Moore <paul@paul-moore.com>
13 * (c) Copyright Hewlett-Packard Development Company, L.P., 2006 - 2008
54 * LSM. The hash table is used to lookup the network interface entry
55 * (struct netlbl_unlhsh_iface) and then the interface entry is used to
56 * lookup an IP address match from an ordered list. If a network interface
57 * match can not be found in the hash table then the default entry
58 * (netlbl_unlhsh_def) is used. The IP address entry list
126 .len = IFNAMSIZ - 1 },
135 * netlbl_unlhsh_free_iface - Frees an interface entry from the hash table
136 * @entry: the entry's RCU field
140 * function so that memory allocated to a hash table interface entry can be
142 * the IPv4 and IPv6 address lists contained as part of an interface entry. It
143 * is up to the rest of the code to make sure an interface entry is only freed
144 * once it's address lists are empty.
147 static void netlbl_unlhsh_free_iface(struct rcu_head *entry) in netlbl_unlhsh_free_iface() argument
157 iface = container_of(entry, struct netlbl_unlhsh_iface, rcu); in netlbl_unlhsh_free_iface()
162 netlbl_af4list_foreach_safe(iter4, tmp4, &iface->addr4_list) { in netlbl_unlhsh_free_iface()
167 netlbl_af6list_foreach_safe(iter6, tmp6, &iface->addr6_list) { in netlbl_unlhsh_free_iface()
176 * netlbl_unlhsh_hash - Hashing function for the hash table
188 return ifindex & (netlbl_unlhsh_rcu_deref(netlbl_unlhsh)->size - 1); in netlbl_unlhsh_hash()
192 * netlbl_unlhsh_search_iface - Search for a matching interface entry
197 * interface entry which matches @ifindex, otherwise NULL is returned. The
209 bkt_list = &netlbl_unlhsh_rcu_deref(netlbl_unlhsh)->tbl[bkt]; in netlbl_unlhsh_search_iface()
212 if (iter->valid && iter->ifindex == ifindex) in netlbl_unlhsh_search_iface()
219 * netlbl_unlhsh_add_addr4 - Add a new IPv4 address entry to the hash table
220 * @iface: the associated interface entry
221 * @addr: IPv4 address in network byte order
222 * @mask: IPv4 address mask in network byte order
223 * @secid: LSM secid value for entry
226 * Add a new address entry into the unlabeled connection hash table using the
227 * interface entry specified by @iface. On success zero is returned, otherwise
237 struct netlbl_unlhsh_addr4 *entry; in netlbl_unlhsh_add_addr4() local
239 entry = kzalloc(sizeof(*entry), GFP_ATOMIC); in netlbl_unlhsh_add_addr4()
240 if (entry == NULL) in netlbl_unlhsh_add_addr4()
241 return -ENOMEM; in netlbl_unlhsh_add_addr4()
243 entry->list.addr = addr->s_addr & mask->s_addr; in netlbl_unlhsh_add_addr4()
244 entry->list.mask = mask->s_addr; in netlbl_unlhsh_add_addr4()
245 entry->list.valid = 1; in netlbl_unlhsh_add_addr4()
246 entry->secid = secid; in netlbl_unlhsh_add_addr4()
249 ret_val = netlbl_af4list_add(&entry->list, &iface->addr4_list); in netlbl_unlhsh_add_addr4()
253 kfree(entry); in netlbl_unlhsh_add_addr4()
259 * netlbl_unlhsh_add_addr6 - Add a new IPv6 address entry to the hash table
260 * @iface: the associated interface entry
261 * @addr: IPv6 address in network byte order
262 * @mask: IPv6 address mask in network byte order
263 * @secid: LSM secid value for entry
266 * Add a new address entry into the unlabeled connection hash table using the
267 * interface entry specified by @iface. On success zero is returned, otherwise
277 struct netlbl_unlhsh_addr6 *entry; in netlbl_unlhsh_add_addr6() local
279 entry = kzalloc(sizeof(*entry), GFP_ATOMIC); in netlbl_unlhsh_add_addr6()
280 if (entry == NULL) in netlbl_unlhsh_add_addr6()
281 return -ENOMEM; in netlbl_unlhsh_add_addr6()
283 entry->list.addr = *addr; in netlbl_unlhsh_add_addr6()
284 entry->list.addr.s6_addr32[0] &= mask->s6_addr32[0]; in netlbl_unlhsh_add_addr6()
285 entry->list.addr.s6_addr32[1] &= mask->s6_addr32[1]; in netlbl_unlhsh_add_addr6()
286 entry->list.addr.s6_addr32[2] &= mask->s6_addr32[2]; in netlbl_unlhsh_add_addr6()
287 entry->list.addr.s6_addr32[3] &= mask->s6_addr32[3]; in netlbl_unlhsh_add_addr6()
288 entry->list.mask = *mask; in netlbl_unlhsh_add_addr6()
289 entry->list.valid = 1; in netlbl_unlhsh_add_addr6()
290 entry->secid = secid; in netlbl_unlhsh_add_addr6()
293 ret_val = netlbl_af6list_add(&entry->list, &iface->addr6_list); in netlbl_unlhsh_add_addr6()
297 kfree(entry); in netlbl_unlhsh_add_addr6()
303 * netlbl_unlhsh_add_iface - Adds a new interface entry to the hash table
307 * Add a new, empty, interface entry into the unlabeled connection hash table.
308 * On success a pointer to the new interface entry is returned, on failure NULL
321 iface->ifindex = ifindex; in netlbl_unlhsh_add_iface()
322 INIT_LIST_HEAD(&iface->addr4_list); in netlbl_unlhsh_add_iface()
323 INIT_LIST_HEAD(&iface->addr6_list); in netlbl_unlhsh_add_iface()
324 iface->valid = 1; in netlbl_unlhsh_add_iface()
331 list_add_tail_rcu(&iface->list, in netlbl_unlhsh_add_iface()
332 &netlbl_unlhsh_rcu_deref(netlbl_unlhsh)->tbl[bkt]); in netlbl_unlhsh_add_iface()
334 INIT_LIST_HEAD(&iface->list); in netlbl_unlhsh_add_iface()
350 * netlbl_unlhsh_add - Adds a new entry to the unlabeled connection hash table
353 * @addr: IP address in network byte order
354 * @mask: address mask in network byte order
355 * @addr_len: length of address/mask (4 for IPv4, 16 for IPv6)
356 * @secid: LSM secid value for the entry
360 * Adds a new entry to the unlabeled connection hash table. Returns zero on
381 return -EINVAL; in netlbl_unlhsh_add()
387 ret_val = -ENODEV; in netlbl_unlhsh_add()
390 ifindex = dev->ifindex; in netlbl_unlhsh_add()
399 ret_val = -ENOMEM; in netlbl_unlhsh_add()
414 addr4->s_addr, in netlbl_unlhsh_add()
415 mask4->s_addr); in netlbl_unlhsh_add()
432 ret_val = -EINVAL; in netlbl_unlhsh_add()
451 * netlbl_unlhsh_remove_addr4 - Remove an IPv4 address entry
453 * @iface: interface entry
454 * @addr: IP address
455 * @mask: IP address mask
459 * Remove an IP address entry from the unlabeled connection hash table.
470 struct netlbl_unlhsh_addr4 *entry; in netlbl_unlhsh_remove_addr4() local
476 list_entry = netlbl_af4list_remove(addr->s_addr, mask->s_addr, in netlbl_unlhsh_remove_addr4()
477 &iface->addr4_list); in netlbl_unlhsh_remove_addr4()
480 entry = netlbl_unlhsh_addr4_entry(list_entry); in netlbl_unlhsh_remove_addr4()
482 entry = NULL; in netlbl_unlhsh_remove_addr4()
487 dev = dev_get_by_index(net, iface->ifindex); in netlbl_unlhsh_remove_addr4()
489 (dev != NULL ? dev->name : NULL), in netlbl_unlhsh_remove_addr4()
490 addr->s_addr, mask->s_addr); in netlbl_unlhsh_remove_addr4()
492 if (entry != NULL && in netlbl_unlhsh_remove_addr4()
493 security_secid_to_secctx(entry->secid, &ctx) >= 0) { in netlbl_unlhsh_remove_addr4()
497 audit_log_format(audit_buf, " res=%u", entry != NULL ? 1 : 0); in netlbl_unlhsh_remove_addr4()
501 if (entry == NULL) in netlbl_unlhsh_remove_addr4()
502 return -ENOENT; in netlbl_unlhsh_remove_addr4()
504 kfree_rcu(entry, rcu); in netlbl_unlhsh_remove_addr4()
510 * netlbl_unlhsh_remove_addr6 - Remove an IPv6 address entry
512 * @iface: interface entry
513 * @addr: IP address
514 * @mask: IP address mask
518 * Remove an IP address entry from the unlabeled connection hash table.
529 struct netlbl_unlhsh_addr6 *entry; in netlbl_unlhsh_remove_addr6() local
535 list_entry = netlbl_af6list_remove(addr, mask, &iface->addr6_list); in netlbl_unlhsh_remove_addr6()
538 entry = netlbl_unlhsh_addr6_entry(list_entry); in netlbl_unlhsh_remove_addr6()
540 entry = NULL; in netlbl_unlhsh_remove_addr6()
545 dev = dev_get_by_index(net, iface->ifindex); in netlbl_unlhsh_remove_addr6()
547 (dev != NULL ? dev->name : NULL), in netlbl_unlhsh_remove_addr6()
550 if (entry != NULL && in netlbl_unlhsh_remove_addr6()
551 security_secid_to_secctx(entry->secid, &ctx) >= 0) { in netlbl_unlhsh_remove_addr6()
555 audit_log_format(audit_buf, " res=%u", entry != NULL ? 1 : 0); in netlbl_unlhsh_remove_addr6()
559 if (entry == NULL) in netlbl_unlhsh_remove_addr6()
560 return -ENOENT; in netlbl_unlhsh_remove_addr6()
562 kfree_rcu(entry, rcu); in netlbl_unlhsh_remove_addr6()
568 * netlbl_unlhsh_condremove_iface - Remove an interface entry
569 * @iface: the interface entry
572 * Remove an interface entry from the unlabeled connection hash table if it is
573 * empty. An interface entry is considered to be empty if there are no
574 * address entries assigned to it.
585 netlbl_af4list_foreach_rcu(iter4, &iface->addr4_list) in netlbl_unlhsh_condremove_iface()
588 netlbl_af6list_foreach_rcu(iter6, &iface->addr6_list) in netlbl_unlhsh_condremove_iface()
591 iface->valid = 0; in netlbl_unlhsh_condremove_iface()
592 if (iface->ifindex > 0) in netlbl_unlhsh_condremove_iface()
593 list_del_rcu(&iface->list); in netlbl_unlhsh_condremove_iface()
598 call_rcu(&iface->rcu, netlbl_unlhsh_free_iface); in netlbl_unlhsh_condremove_iface()
606 * netlbl_unlhsh_remove - Remove an entry from the unlabeled hash table
609 * @addr: IP address in network byte order
610 * @mask: address mask in network byte order
611 * @addr_len: length of address/mask (4 for IPv4, 16 for IPv6)
615 * Removes and existing entry from the unlabeled connection hash table.
632 return -EINVAL; in netlbl_unlhsh_remove()
638 ret_val = -ENODEV; in netlbl_unlhsh_remove()
641 iface = netlbl_unlhsh_search_iface(dev->ifindex); in netlbl_unlhsh_remove()
645 ret_val = -ENOENT; in netlbl_unlhsh_remove()
662 ret_val = -EINVAL; in netlbl_unlhsh_remove()
679 * netlbl_unlhsh_netdev_handler - Network device notification handler
699 /* XXX - should this be a check for NETDEV_DOWN or _UNREGISTER? */ in netlbl_unlhsh_netdev_handler()
702 iface = netlbl_unlhsh_search_iface(dev->ifindex); in netlbl_unlhsh_netdev_handler()
703 if (iface != NULL && iface->valid) { in netlbl_unlhsh_netdev_handler()
704 iface->valid = 0; in netlbl_unlhsh_netdev_handler()
705 list_del_rcu(&iface->list); in netlbl_unlhsh_netdev_handler()
712 call_rcu(&iface->rcu, netlbl_unlhsh_free_iface); in netlbl_unlhsh_netdev_handler()
718 * netlbl_unlabel_acceptflg_set - Set the unlabeled accept flag
744 * netlbl_unlabel_addrinfo_get - Get the IPv4/6 address information
746 * @addr: the IP address
747 * @mask: the IP address mask
748 * @len: the address length
751 * Examine the Generic NETLINK message and extract the IP address information.
762 if (info->attrs[NLBL_UNLABEL_A_IPV4ADDR] && in netlbl_unlabel_addrinfo_get()
763 info->attrs[NLBL_UNLABEL_A_IPV4MASK]) { in netlbl_unlabel_addrinfo_get()
764 addr_len = nla_len(info->attrs[NLBL_UNLABEL_A_IPV4ADDR]); in netlbl_unlabel_addrinfo_get()
766 addr_len != nla_len(info->attrs[NLBL_UNLABEL_A_IPV4MASK])) in netlbl_unlabel_addrinfo_get()
767 return -EINVAL; in netlbl_unlabel_addrinfo_get()
769 *addr = nla_data(info->attrs[NLBL_UNLABEL_A_IPV4ADDR]); in netlbl_unlabel_addrinfo_get()
770 *mask = nla_data(info->attrs[NLBL_UNLABEL_A_IPV4MASK]); in netlbl_unlabel_addrinfo_get()
772 } else if (info->attrs[NLBL_UNLABEL_A_IPV6ADDR]) { in netlbl_unlabel_addrinfo_get()
773 addr_len = nla_len(info->attrs[NLBL_UNLABEL_A_IPV6ADDR]); in netlbl_unlabel_addrinfo_get()
775 addr_len != nla_len(info->attrs[NLBL_UNLABEL_A_IPV6MASK])) in netlbl_unlabel_addrinfo_get()
776 return -EINVAL; in netlbl_unlabel_addrinfo_get()
778 *addr = nla_data(info->attrs[NLBL_UNLABEL_A_IPV6ADDR]); in netlbl_unlabel_addrinfo_get()
779 *mask = nla_data(info->attrs[NLBL_UNLABEL_A_IPV6MASK]); in netlbl_unlabel_addrinfo_get()
783 return -EINVAL; in netlbl_unlabel_addrinfo_get()
791 * netlbl_unlabel_accept - Handle an ACCEPT message
805 if (info->attrs[NLBL_UNLABEL_A_ACPTFLG]) { in netlbl_unlabel_accept()
806 value = nla_get_u8(info->attrs[NLBL_UNLABEL_A_ACPTFLG]); in netlbl_unlabel_accept()
814 return -EINVAL; in netlbl_unlabel_accept()
818 * netlbl_unlabel_list - Handle a LIST message
829 int ret_val = -EINVAL; in netlbl_unlabel_list()
839 ret_val = -ENOMEM; in netlbl_unlabel_list()
858 * netlbl_unlabel_staticadd - Handle a STATICADD message
864 * connection entry to the hash table. Returns zero on success, negative
880 * single entry. However, allow users to create two entries, one each in netlbl_unlabel_staticadd()
883 if (!info->attrs[NLBL_UNLABEL_A_SECCTX] || in netlbl_unlabel_staticadd()
884 !info->attrs[NLBL_UNLABEL_A_IFACE] || in netlbl_unlabel_staticadd()
885 !((!info->attrs[NLBL_UNLABEL_A_IPV4ADDR] || in netlbl_unlabel_staticadd()
886 !info->attrs[NLBL_UNLABEL_A_IPV4MASK]) ^ in netlbl_unlabel_staticadd()
887 (!info->attrs[NLBL_UNLABEL_A_IPV6ADDR] || in netlbl_unlabel_staticadd()
888 !info->attrs[NLBL_UNLABEL_A_IPV6MASK]))) in netlbl_unlabel_staticadd()
889 return -EINVAL; in netlbl_unlabel_staticadd()
896 dev_name = nla_data(info->attrs[NLBL_UNLABEL_A_IFACE]); in netlbl_unlabel_staticadd()
898 nla_data(info->attrs[NLBL_UNLABEL_A_SECCTX]), in netlbl_unlabel_staticadd()
899 nla_len(info->attrs[NLBL_UNLABEL_A_SECCTX]), in netlbl_unlabel_staticadd()
910 * netlbl_unlabel_staticadddef - Handle a STATICADDDEF message
916 * unlabeled connection entry. Returns zero on success, negative values on
931 * single entry. However, allow users to create two entries, one each in netlbl_unlabel_staticadddef()
934 if (!info->attrs[NLBL_UNLABEL_A_SECCTX] || in netlbl_unlabel_staticadddef()
935 !((!info->attrs[NLBL_UNLABEL_A_IPV4ADDR] || in netlbl_unlabel_staticadddef()
936 !info->attrs[NLBL_UNLABEL_A_IPV4MASK]) ^ in netlbl_unlabel_staticadddef()
937 (!info->attrs[NLBL_UNLABEL_A_IPV6ADDR] || in netlbl_unlabel_staticadddef()
938 !info->attrs[NLBL_UNLABEL_A_IPV6MASK]))) in netlbl_unlabel_staticadddef()
939 return -EINVAL; in netlbl_unlabel_staticadddef()
947 nla_data(info->attrs[NLBL_UNLABEL_A_SECCTX]), in netlbl_unlabel_staticadddef()
948 nla_len(info->attrs[NLBL_UNLABEL_A_SECCTX]), in netlbl_unlabel_staticadddef()
959 * netlbl_unlabel_staticremove - Handle a STATICREMOVE message
965 * unlabeled connection entry. Returns zero on success, negative values on
980 * IPv4 and IPv6 in the same entry. */ in netlbl_unlabel_staticremove()
981 if (!info->attrs[NLBL_UNLABEL_A_IFACE] || in netlbl_unlabel_staticremove()
982 !((!info->attrs[NLBL_UNLABEL_A_IPV4ADDR] || in netlbl_unlabel_staticremove()
983 !info->attrs[NLBL_UNLABEL_A_IPV4MASK]) ^ in netlbl_unlabel_staticremove()
984 (!info->attrs[NLBL_UNLABEL_A_IPV6ADDR] || in netlbl_unlabel_staticremove()
985 !info->attrs[NLBL_UNLABEL_A_IPV6MASK]))) in netlbl_unlabel_staticremove()
986 return -EINVAL; in netlbl_unlabel_staticremove()
993 dev_name = nla_data(info->attrs[NLBL_UNLABEL_A_IFACE]); in netlbl_unlabel_staticremove()
1001 * netlbl_unlabel_staticremovedef - Handle a STATICREMOVEDEF message
1007 * unlabeled connection entry. Returns zero on success, negative values on
1021 * IPv4 and IPv6 in the same entry. */ in netlbl_unlabel_staticremovedef()
1022 if (!((!info->attrs[NLBL_UNLABEL_A_IPV4ADDR] || in netlbl_unlabel_staticremovedef()
1023 !info->attrs[NLBL_UNLABEL_A_IPV4MASK]) ^ in netlbl_unlabel_staticremovedef()
1024 (!info->attrs[NLBL_UNLABEL_A_IPV6ADDR] || in netlbl_unlabel_staticremovedef()
1025 !info->attrs[NLBL_UNLABEL_A_IPV6MASK]))) in netlbl_unlabel_staticremovedef()
1026 return -EINVAL; in netlbl_unlabel_staticremovedef()
1041 * netlbl_unlabel_staticlist_gen - Generate messages for STATICLIST[DEF]
1043 * @iface: the interface entry
1044 * @addr4: the IPv4 address entry
1045 * @addr6: the IPv6 address entry
1051 * can be specified, not both, the other unspecified entry should be set to
1062 int ret_val = -ENOMEM; in netlbl_unlabel_staticlist_gen()
1069 data = genlmsg_put(cb_arg->skb, NETLINK_CB(cb_arg->nl_cb->skb).portid, in netlbl_unlabel_staticlist_gen()
1070 cb_arg->seq, &netlbl_unlabel_gnl_family, in netlbl_unlabel_staticlist_gen()
1075 if (iface->ifindex > 0) { in netlbl_unlabel_staticlist_gen()
1076 dev = dev_get_by_index(&init_net, iface->ifindex); in netlbl_unlabel_staticlist_gen()
1078 ret_val = -ENODEV; in netlbl_unlabel_staticlist_gen()
1081 ret_val = nla_put_string(cb_arg->skb, in netlbl_unlabel_staticlist_gen()
1082 NLBL_UNLABEL_A_IFACE, dev->name); in netlbl_unlabel_staticlist_gen()
1091 addr_struct.s_addr = addr4->list.addr; in netlbl_unlabel_staticlist_gen()
1092 ret_val = nla_put_in_addr(cb_arg->skb, in netlbl_unlabel_staticlist_gen()
1098 addr_struct.s_addr = addr4->list.mask; in netlbl_unlabel_staticlist_gen()
1099 ret_val = nla_put_in_addr(cb_arg->skb, in netlbl_unlabel_staticlist_gen()
1105 secid = addr4->secid; in netlbl_unlabel_staticlist_gen()
1107 ret_val = nla_put_in6_addr(cb_arg->skb, in netlbl_unlabel_staticlist_gen()
1109 &addr6->list.addr); in netlbl_unlabel_staticlist_gen()
1113 ret_val = nla_put_in6_addr(cb_arg->skb, in netlbl_unlabel_staticlist_gen()
1115 &addr6->list.mask); in netlbl_unlabel_staticlist_gen()
1119 secid = addr6->secid; in netlbl_unlabel_staticlist_gen()
1125 ret_val = nla_put(cb_arg->skb, in netlbl_unlabel_staticlist_gen()
1133 cb_arg->seq++; in netlbl_unlabel_staticlist_gen()
1134 genlmsg_end(cb_arg->skb, data); in netlbl_unlabel_staticlist_gen()
1138 genlmsg_cancel(cb_arg->skb, data); in netlbl_unlabel_staticlist_gen()
1143 * netlbl_unlabel_staticlist - Handle a STATICLIST message
1157 u32 skip_bkt = cb->args[0]; in netlbl_unlabel_staticlist()
1158 u32 skip_chain = cb->args[1]; in netlbl_unlabel_staticlist()
1159 u32 skip_addr4 = cb->args[2]; in netlbl_unlabel_staticlist()
1165 u32 skip_addr6 = cb->args[3]; in netlbl_unlabel_staticlist()
1171 cb_arg.seq = cb->nlh->nlmsg_seq; in netlbl_unlabel_staticlist()
1175 iter_bkt < rcu_dereference(netlbl_unlhsh)->size; in netlbl_unlabel_staticlist()
1177 iter_list = &rcu_dereference(netlbl_unlhsh)->tbl[iter_bkt]; in netlbl_unlabel_staticlist()
1179 if (!iface->valid || in netlbl_unlabel_staticlist()
1183 &iface->addr4_list) { in netlbl_unlabel_staticlist()
1192 iter_addr4--; in netlbl_unlabel_staticlist()
1193 iter_chain--; in netlbl_unlabel_staticlist()
1201 &iface->addr6_list) { in netlbl_unlabel_staticlist()
1210 iter_addr6--; in netlbl_unlabel_staticlist()
1211 iter_chain--; in netlbl_unlabel_staticlist()
1225 cb->args[0] = iter_bkt; in netlbl_unlabel_staticlist()
1226 cb->args[1] = iter_chain; in netlbl_unlabel_staticlist()
1227 cb->args[2] = iter_addr4; in netlbl_unlabel_staticlist()
1228 cb->args[3] = iter_addr6; in netlbl_unlabel_staticlist()
1229 return skb->len; in netlbl_unlabel_staticlist()
1233 * netlbl_unlabel_staticlistdef - Handle a STATICLISTDEF message
1239 * unlabeled connection entry in a form suitable for use in a kernel generated
1256 cb_arg.seq = cb->nlh->nlmsg_seq; in netlbl_unlabel_staticlistdef()
1260 if (iface == NULL || !iface->valid) in netlbl_unlabel_staticlistdef()
1263 netlbl_af4list_foreach_rcu(addr4, &iface->addr4_list) { in netlbl_unlabel_staticlistdef()
1264 if (iter_addr4++ < cb->args[0]) in netlbl_unlabel_staticlistdef()
1271 iter_addr4--; in netlbl_unlabel_staticlistdef()
1276 netlbl_af6list_foreach_rcu(addr6, &iface->addr6_list) { in netlbl_unlabel_staticlistdef()
1277 if (iter_addr6++ < cb->args[1]) in netlbl_unlabel_staticlistdef()
1284 iter_addr6--; in netlbl_unlabel_staticlistdef()
1292 cb->args[0] = iter_addr4; in netlbl_unlabel_staticlistdef()
1293 cb->args[1] = iter_addr6; in netlbl_unlabel_staticlistdef()
1294 return skb->len; in netlbl_unlabel_staticlistdef()
1377 * netlbl_unlabel_genl_init - Register the Unlabeled NetLabel component
1398 * netlbl_unlabel_init - Initialize the unlabeled connection hash table
1405 * non-zero values on error.
1414 return -EINVAL; in netlbl_unlabel_init()
1418 return -ENOMEM; in netlbl_unlabel_init()
1419 hsh_tbl->size = 1 << size; in netlbl_unlabel_init()
1420 hsh_tbl->tbl = kcalloc(hsh_tbl->size, in netlbl_unlabel_init()
1423 if (hsh_tbl->tbl == NULL) { in netlbl_unlabel_init()
1425 return -ENOMEM; in netlbl_unlabel_init()
1427 for (iter = 0; iter < hsh_tbl->size; iter++) in netlbl_unlabel_init()
1428 INIT_LIST_HEAD(&hsh_tbl->tbl[iter]); in netlbl_unlabel_init()
1440 * netlbl_unlabel_getattr - Get the security attributes for an unlabled packet
1457 iface = netlbl_unlhsh_search_iface(skb->skb_iif); in netlbl_unlabel_getattr()
1460 if (iface == NULL || !iface->valid) in netlbl_unlabel_getattr()
1466 * receiving ip_hdr(skb)->version = 4. in netlbl_unlabel_getattr()
1468 if (family == PF_INET6 && ip_hdr(skb)->version == 4) in netlbl_unlabel_getattr()
1478 addr4 = netlbl_af4list_search(hdr4->saddr, in netlbl_unlabel_getattr()
1479 &iface->addr4_list); in netlbl_unlabel_getattr()
1482 secattr->attr.secid = netlbl_unlhsh_addr4_entry(addr4)->secid; in netlbl_unlabel_getattr()
1491 addr6 = netlbl_af6list_search(&hdr6->saddr, in netlbl_unlabel_getattr()
1492 &iface->addr6_list); in netlbl_unlabel_getattr()
1495 secattr->attr.secid = netlbl_unlhsh_addr6_entry(addr6)->secid; in netlbl_unlabel_getattr()
1504 secattr->flags |= NETLBL_SECATTR_SECID; in netlbl_unlabel_getattr()
1505 secattr->type = NETLBL_NLTYPE_UNLABELED; in netlbl_unlabel_getattr()
1511 return -ENOMSG; in netlbl_unlabel_getattr()
1512 secattr->type = NETLBL_NLTYPE_UNLABELED; in netlbl_unlabel_getattr()
1517 * netlbl_unlabel_defconf - Set the default config to allow unlabeled packets
1527 struct netlbl_dom_map *entry; in netlbl_unlabel_defconf() local
1537 entry = kzalloc(sizeof(*entry), GFP_KERNEL); in netlbl_unlabel_defconf()
1538 if (entry == NULL) in netlbl_unlabel_defconf()
1539 return -ENOMEM; in netlbl_unlabel_defconf()
1540 entry->family = AF_UNSPEC; in netlbl_unlabel_defconf()
1541 entry->def.type = NETLBL_NLTYPE_UNLABELED; in netlbl_unlabel_defconf()
1542 ret_val = netlbl_domhsh_add_default(entry, &audit_info); in netlbl_unlabel_defconf()