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
382 return -EINVAL; in netlbl_unlhsh_add()
388 ret_val = -ENODEV; in netlbl_unlhsh_add()
391 ifindex = dev->ifindex; in netlbl_unlhsh_add()
400 ret_val = -ENOMEM; in netlbl_unlhsh_add()
415 addr4->s_addr, in netlbl_unlhsh_add()
416 mask4->s_addr); in netlbl_unlhsh_add()
433 ret_val = -EINVAL; in netlbl_unlhsh_add()
454 * netlbl_unlhsh_remove_addr4 - Remove an IPv4 address entry
456 * @iface: interface entry
457 * @addr: IP address
458 * @mask: IP address mask
462 * Remove an IP address entry from the unlabeled connection hash table.
473 struct netlbl_unlhsh_addr4 *entry; in netlbl_unlhsh_remove_addr4() local
480 list_entry = netlbl_af4list_remove(addr->s_addr, mask->s_addr, in netlbl_unlhsh_remove_addr4()
481 &iface->addr4_list); in netlbl_unlhsh_remove_addr4()
484 entry = netlbl_unlhsh_addr4_entry(list_entry); in netlbl_unlhsh_remove_addr4()
486 entry = NULL; in netlbl_unlhsh_remove_addr4()
491 dev = dev_get_by_index(net, iface->ifindex); in netlbl_unlhsh_remove_addr4()
493 (dev != NULL ? dev->name : NULL), in netlbl_unlhsh_remove_addr4()
494 addr->s_addr, mask->s_addr); in netlbl_unlhsh_remove_addr4()
496 if (entry != NULL && in netlbl_unlhsh_remove_addr4()
497 security_secid_to_secctx(entry->secid, in netlbl_unlhsh_remove_addr4()
502 audit_log_format(audit_buf, " res=%u", entry != NULL ? 1 : 0); in netlbl_unlhsh_remove_addr4()
506 if (entry == NULL) in netlbl_unlhsh_remove_addr4()
507 return -ENOENT; in netlbl_unlhsh_remove_addr4()
509 kfree_rcu(entry, rcu); in netlbl_unlhsh_remove_addr4()
515 * netlbl_unlhsh_remove_addr6 - Remove an IPv6 address entry
517 * @iface: interface entry
518 * @addr: IP address
519 * @mask: IP address mask
523 * Remove an IP address entry from the unlabeled connection hash table.
534 struct netlbl_unlhsh_addr6 *entry; in netlbl_unlhsh_remove_addr6() local
541 list_entry = netlbl_af6list_remove(addr, mask, &iface->addr6_list); in netlbl_unlhsh_remove_addr6()
544 entry = netlbl_unlhsh_addr6_entry(list_entry); in netlbl_unlhsh_remove_addr6()
546 entry = NULL; in netlbl_unlhsh_remove_addr6()
551 dev = dev_get_by_index(net, iface->ifindex); in netlbl_unlhsh_remove_addr6()
553 (dev != NULL ? dev->name : NULL), in netlbl_unlhsh_remove_addr6()
556 if (entry != NULL && in netlbl_unlhsh_remove_addr6()
557 security_secid_to_secctx(entry->secid, in netlbl_unlhsh_remove_addr6()
562 audit_log_format(audit_buf, " res=%u", entry != NULL ? 1 : 0); in netlbl_unlhsh_remove_addr6()
566 if (entry == NULL) in netlbl_unlhsh_remove_addr6()
567 return -ENOENT; in netlbl_unlhsh_remove_addr6()
569 kfree_rcu(entry, rcu); in netlbl_unlhsh_remove_addr6()
575 * netlbl_unlhsh_condremove_iface - Remove an interface entry
576 * @iface: the interface entry
579 * Remove an interface entry from the unlabeled connection hash table if it is
580 * empty. An interface entry is considered to be empty if there are no
581 * address entries assigned to it.
592 netlbl_af4list_foreach_rcu(iter4, &iface->addr4_list) in netlbl_unlhsh_condremove_iface()
595 netlbl_af6list_foreach_rcu(iter6, &iface->addr6_list) in netlbl_unlhsh_condremove_iface()
598 iface->valid = 0; in netlbl_unlhsh_condremove_iface()
599 if (iface->ifindex > 0) in netlbl_unlhsh_condremove_iface()
600 list_del_rcu(&iface->list); in netlbl_unlhsh_condremove_iface()
605 call_rcu(&iface->rcu, netlbl_unlhsh_free_iface); in netlbl_unlhsh_condremove_iface()
613 * netlbl_unlhsh_remove - Remove an entry from the unlabeled hash table
616 * @addr: IP address in network byte order
617 * @mask: address mask in network byte order
618 * @addr_len: length of address/mask (4 for IPv4, 16 for IPv6)
622 * Removes and existing entry from the unlabeled connection hash table.
639 return -EINVAL; in netlbl_unlhsh_remove()
645 ret_val = -ENODEV; in netlbl_unlhsh_remove()
648 iface = netlbl_unlhsh_search_iface(dev->ifindex); in netlbl_unlhsh_remove()
652 ret_val = -ENOENT; in netlbl_unlhsh_remove()
669 ret_val = -EINVAL; in netlbl_unlhsh_remove()
686 * netlbl_unlhsh_netdev_handler - Network device notification handler
706 /* XXX - should this be a check for NETDEV_DOWN or _UNREGISTER? */ in netlbl_unlhsh_netdev_handler()
709 iface = netlbl_unlhsh_search_iface(dev->ifindex); in netlbl_unlhsh_netdev_handler()
710 if (iface != NULL && iface->valid) { in netlbl_unlhsh_netdev_handler()
711 iface->valid = 0; in netlbl_unlhsh_netdev_handler()
712 list_del_rcu(&iface->list); in netlbl_unlhsh_netdev_handler()
719 call_rcu(&iface->rcu, netlbl_unlhsh_free_iface); in netlbl_unlhsh_netdev_handler()
725 * netlbl_unlabel_acceptflg_set - Set the unlabeled accept flag
751 * netlbl_unlabel_addrinfo_get - Get the IPv4/6 address information
753 * @addr: the IP address
754 * @mask: the IP address mask
755 * @len: the address length
758 * Examine the Generic NETLINK message and extract the IP address information.
769 if (info->attrs[NLBL_UNLABEL_A_IPV4ADDR] && in netlbl_unlabel_addrinfo_get()
770 info->attrs[NLBL_UNLABEL_A_IPV4MASK]) { in netlbl_unlabel_addrinfo_get()
771 addr_len = nla_len(info->attrs[NLBL_UNLABEL_A_IPV4ADDR]); in netlbl_unlabel_addrinfo_get()
773 addr_len != nla_len(info->attrs[NLBL_UNLABEL_A_IPV4MASK])) in netlbl_unlabel_addrinfo_get()
774 return -EINVAL; in netlbl_unlabel_addrinfo_get()
776 *addr = nla_data(info->attrs[NLBL_UNLABEL_A_IPV4ADDR]); in netlbl_unlabel_addrinfo_get()
777 *mask = nla_data(info->attrs[NLBL_UNLABEL_A_IPV4MASK]); in netlbl_unlabel_addrinfo_get()
779 } else if (info->attrs[NLBL_UNLABEL_A_IPV6ADDR]) { in netlbl_unlabel_addrinfo_get()
780 addr_len = nla_len(info->attrs[NLBL_UNLABEL_A_IPV6ADDR]); in netlbl_unlabel_addrinfo_get()
782 addr_len != nla_len(info->attrs[NLBL_UNLABEL_A_IPV6MASK])) in netlbl_unlabel_addrinfo_get()
783 return -EINVAL; in netlbl_unlabel_addrinfo_get()
785 *addr = nla_data(info->attrs[NLBL_UNLABEL_A_IPV6ADDR]); in netlbl_unlabel_addrinfo_get()
786 *mask = nla_data(info->attrs[NLBL_UNLABEL_A_IPV6MASK]); in netlbl_unlabel_addrinfo_get()
790 return -EINVAL; in netlbl_unlabel_addrinfo_get()
798 * netlbl_unlabel_accept - Handle an ACCEPT message
812 if (info->attrs[NLBL_UNLABEL_A_ACPTFLG]) { in netlbl_unlabel_accept()
813 value = nla_get_u8(info->attrs[NLBL_UNLABEL_A_ACPTFLG]); in netlbl_unlabel_accept()
821 return -EINVAL; in netlbl_unlabel_accept()
825 * netlbl_unlabel_list - Handle a LIST message
836 int ret_val = -EINVAL; in netlbl_unlabel_list()
846 ret_val = -ENOMEM; in netlbl_unlabel_list()
865 * netlbl_unlabel_staticadd - Handle a STATICADD message
871 * connection entry to the hash table. Returns zero on success, negative
887 * single entry. However, allow users to create two entries, one each in netlbl_unlabel_staticadd()
890 if (!info->attrs[NLBL_UNLABEL_A_SECCTX] || in netlbl_unlabel_staticadd()
891 !info->attrs[NLBL_UNLABEL_A_IFACE] || in netlbl_unlabel_staticadd()
892 !((!info->attrs[NLBL_UNLABEL_A_IPV4ADDR] || in netlbl_unlabel_staticadd()
893 !info->attrs[NLBL_UNLABEL_A_IPV4MASK]) ^ in netlbl_unlabel_staticadd()
894 (!info->attrs[NLBL_UNLABEL_A_IPV6ADDR] || in netlbl_unlabel_staticadd()
895 !info->attrs[NLBL_UNLABEL_A_IPV6MASK]))) in netlbl_unlabel_staticadd()
896 return -EINVAL; in netlbl_unlabel_staticadd()
903 dev_name = nla_data(info->attrs[NLBL_UNLABEL_A_IFACE]); in netlbl_unlabel_staticadd()
905 nla_data(info->attrs[NLBL_UNLABEL_A_SECCTX]), in netlbl_unlabel_staticadd()
906 nla_len(info->attrs[NLBL_UNLABEL_A_SECCTX]), in netlbl_unlabel_staticadd()
917 * netlbl_unlabel_staticadddef - Handle a STATICADDDEF message
923 * unlabeled connection entry. Returns zero on success, negative values on
938 * single entry. However, allow users to create two entries, one each in netlbl_unlabel_staticadddef()
941 if (!info->attrs[NLBL_UNLABEL_A_SECCTX] || in netlbl_unlabel_staticadddef()
942 !((!info->attrs[NLBL_UNLABEL_A_IPV4ADDR] || in netlbl_unlabel_staticadddef()
943 !info->attrs[NLBL_UNLABEL_A_IPV4MASK]) ^ in netlbl_unlabel_staticadddef()
944 (!info->attrs[NLBL_UNLABEL_A_IPV6ADDR] || in netlbl_unlabel_staticadddef()
945 !info->attrs[NLBL_UNLABEL_A_IPV6MASK]))) in netlbl_unlabel_staticadddef()
946 return -EINVAL; in netlbl_unlabel_staticadddef()
954 nla_data(info->attrs[NLBL_UNLABEL_A_SECCTX]), in netlbl_unlabel_staticadddef()
955 nla_len(info->attrs[NLBL_UNLABEL_A_SECCTX]), in netlbl_unlabel_staticadddef()
966 * netlbl_unlabel_staticremove - Handle a STATICREMOVE message
972 * unlabeled connection entry. Returns zero on success, negative values on
987 * IPv4 and IPv6 in the same entry. */ in netlbl_unlabel_staticremove()
988 if (!info->attrs[NLBL_UNLABEL_A_IFACE] || in netlbl_unlabel_staticremove()
989 !((!info->attrs[NLBL_UNLABEL_A_IPV4ADDR] || in netlbl_unlabel_staticremove()
990 !info->attrs[NLBL_UNLABEL_A_IPV4MASK]) ^ in netlbl_unlabel_staticremove()
991 (!info->attrs[NLBL_UNLABEL_A_IPV6ADDR] || in netlbl_unlabel_staticremove()
992 !info->attrs[NLBL_UNLABEL_A_IPV6MASK]))) in netlbl_unlabel_staticremove()
993 return -EINVAL; in netlbl_unlabel_staticremove()
1000 dev_name = nla_data(info->attrs[NLBL_UNLABEL_A_IFACE]); in netlbl_unlabel_staticremove()
1008 * netlbl_unlabel_staticremovedef - Handle a STATICREMOVEDEF message
1014 * unlabeled connection entry. Returns zero on success, negative values on
1028 * IPv4 and IPv6 in the same entry. */ in netlbl_unlabel_staticremovedef()
1029 if (!((!info->attrs[NLBL_UNLABEL_A_IPV4ADDR] || in netlbl_unlabel_staticremovedef()
1030 !info->attrs[NLBL_UNLABEL_A_IPV4MASK]) ^ in netlbl_unlabel_staticremovedef()
1031 (!info->attrs[NLBL_UNLABEL_A_IPV6ADDR] || in netlbl_unlabel_staticremovedef()
1032 !info->attrs[NLBL_UNLABEL_A_IPV6MASK]))) in netlbl_unlabel_staticremovedef()
1033 return -EINVAL; in netlbl_unlabel_staticremovedef()
1048 * netlbl_unlabel_staticlist_gen - Generate messages for STATICLIST[DEF]
1050 * @iface: the interface entry
1051 * @addr4: the IPv4 address entry
1052 * @addr6: the IPv6 address entry
1058 * can be specified, not both, the other unspecified entry should be set to
1069 int ret_val = -ENOMEM; in netlbl_unlabel_staticlist_gen()
1077 data = genlmsg_put(cb_arg->skb, NETLINK_CB(cb_arg->nl_cb->skb).portid, in netlbl_unlabel_staticlist_gen()
1078 cb_arg->seq, &netlbl_unlabel_gnl_family, in netlbl_unlabel_staticlist_gen()
1083 if (iface->ifindex > 0) { in netlbl_unlabel_staticlist_gen()
1084 dev = dev_get_by_index(&init_net, iface->ifindex); in netlbl_unlabel_staticlist_gen()
1086 ret_val = -ENODEV; in netlbl_unlabel_staticlist_gen()
1089 ret_val = nla_put_string(cb_arg->skb, in netlbl_unlabel_staticlist_gen()
1090 NLBL_UNLABEL_A_IFACE, dev->name); in netlbl_unlabel_staticlist_gen()
1099 addr_struct.s_addr = addr4->list.addr; in netlbl_unlabel_staticlist_gen()
1100 ret_val = nla_put_in_addr(cb_arg->skb, in netlbl_unlabel_staticlist_gen()
1106 addr_struct.s_addr = addr4->list.mask; in netlbl_unlabel_staticlist_gen()
1107 ret_val = nla_put_in_addr(cb_arg->skb, in netlbl_unlabel_staticlist_gen()
1113 secid = addr4->secid; in netlbl_unlabel_staticlist_gen()
1115 ret_val = nla_put_in6_addr(cb_arg->skb, in netlbl_unlabel_staticlist_gen()
1117 &addr6->list.addr); in netlbl_unlabel_staticlist_gen()
1121 ret_val = nla_put_in6_addr(cb_arg->skb, in netlbl_unlabel_staticlist_gen()
1123 &addr6->list.mask); in netlbl_unlabel_staticlist_gen()
1127 secid = addr6->secid; in netlbl_unlabel_staticlist_gen()
1133 ret_val = nla_put(cb_arg->skb, in netlbl_unlabel_staticlist_gen()
1141 cb_arg->seq++; in netlbl_unlabel_staticlist_gen()
1142 genlmsg_end(cb_arg->skb, data); in netlbl_unlabel_staticlist_gen()
1146 genlmsg_cancel(cb_arg->skb, data); in netlbl_unlabel_staticlist_gen()
1151 * netlbl_unlabel_staticlist - Handle a STATICLIST message
1165 u32 skip_bkt = cb->args[0]; in netlbl_unlabel_staticlist()
1166 u32 skip_chain = cb->args[1]; in netlbl_unlabel_staticlist()
1167 u32 skip_addr4 = cb->args[2]; in netlbl_unlabel_staticlist()
1173 u32 skip_addr6 = cb->args[3]; in netlbl_unlabel_staticlist()
1179 cb_arg.seq = cb->nlh->nlmsg_seq; in netlbl_unlabel_staticlist()
1183 iter_bkt < rcu_dereference(netlbl_unlhsh)->size; in netlbl_unlabel_staticlist()
1185 iter_list = &rcu_dereference(netlbl_unlhsh)->tbl[iter_bkt]; in netlbl_unlabel_staticlist()
1187 if (!iface->valid || in netlbl_unlabel_staticlist()
1191 &iface->addr4_list) { in netlbl_unlabel_staticlist()
1200 iter_addr4--; in netlbl_unlabel_staticlist()
1201 iter_chain--; in netlbl_unlabel_staticlist()
1209 &iface->addr6_list) { in netlbl_unlabel_staticlist()
1218 iter_addr6--; in netlbl_unlabel_staticlist()
1219 iter_chain--; in netlbl_unlabel_staticlist()
1233 cb->args[0] = iter_bkt; in netlbl_unlabel_staticlist()
1234 cb->args[1] = iter_chain; in netlbl_unlabel_staticlist()
1235 cb->args[2] = iter_addr4; in netlbl_unlabel_staticlist()
1236 cb->args[3] = iter_addr6; in netlbl_unlabel_staticlist()
1237 return skb->len; in netlbl_unlabel_staticlist()
1241 * netlbl_unlabel_staticlistdef - Handle a STATICLISTDEF message
1247 * unlabeled connection entry in a form suitable for use in a kernel generated
1264 cb_arg.seq = cb->nlh->nlmsg_seq; in netlbl_unlabel_staticlistdef()
1268 if (iface == NULL || !iface->valid) in netlbl_unlabel_staticlistdef()
1271 netlbl_af4list_foreach_rcu(addr4, &iface->addr4_list) { in netlbl_unlabel_staticlistdef()
1272 if (iter_addr4++ < cb->args[0]) in netlbl_unlabel_staticlistdef()
1279 iter_addr4--; in netlbl_unlabel_staticlistdef()
1284 netlbl_af6list_foreach_rcu(addr6, &iface->addr6_list) { in netlbl_unlabel_staticlistdef()
1285 if (iter_addr6++ < cb->args[1]) in netlbl_unlabel_staticlistdef()
1292 iter_addr6--; in netlbl_unlabel_staticlistdef()
1300 cb->args[0] = iter_addr4; in netlbl_unlabel_staticlistdef()
1301 cb->args[1] = iter_addr6; in netlbl_unlabel_staticlistdef()
1302 return skb->len; in netlbl_unlabel_staticlistdef()
1385 * netlbl_unlabel_genl_init - Register the Unlabeled NetLabel component
1406 * netlbl_unlabel_init - Initialize the unlabeled connection hash table
1413 * non-zero values on error.
1422 return -EINVAL; in netlbl_unlabel_init()
1426 return -ENOMEM; in netlbl_unlabel_init()
1427 hsh_tbl->size = 1 << size; in netlbl_unlabel_init()
1428 hsh_tbl->tbl = kcalloc(hsh_tbl->size, in netlbl_unlabel_init()
1431 if (hsh_tbl->tbl == NULL) { in netlbl_unlabel_init()
1433 return -ENOMEM; in netlbl_unlabel_init()
1435 for (iter = 0; iter < hsh_tbl->size; iter++) in netlbl_unlabel_init()
1436 INIT_LIST_HEAD(&hsh_tbl->tbl[iter]); in netlbl_unlabel_init()
1448 * netlbl_unlabel_getattr - Get the security attributes for an unlabled packet
1465 iface = netlbl_unlhsh_search_iface(skb->skb_iif); in netlbl_unlabel_getattr()
1468 if (iface == NULL || !iface->valid) in netlbl_unlabel_getattr()
1474 * receiving ip_hdr(skb)->version = 4. in netlbl_unlabel_getattr()
1476 if (family == PF_INET6 && ip_hdr(skb)->version == 4) in netlbl_unlabel_getattr()
1486 addr4 = netlbl_af4list_search(hdr4->saddr, in netlbl_unlabel_getattr()
1487 &iface->addr4_list); in netlbl_unlabel_getattr()
1490 secattr->attr.secid = netlbl_unlhsh_addr4_entry(addr4)->secid; in netlbl_unlabel_getattr()
1499 addr6 = netlbl_af6list_search(&hdr6->saddr, in netlbl_unlabel_getattr()
1500 &iface->addr6_list); in netlbl_unlabel_getattr()
1503 secattr->attr.secid = netlbl_unlhsh_addr6_entry(addr6)->secid; in netlbl_unlabel_getattr()
1512 secattr->flags |= NETLBL_SECATTR_SECID; in netlbl_unlabel_getattr()
1513 secattr->type = NETLBL_NLTYPE_UNLABELED; in netlbl_unlabel_getattr()
1519 return -ENOMSG; in netlbl_unlabel_getattr()
1520 secattr->type = NETLBL_NLTYPE_UNLABELED; in netlbl_unlabel_getattr()
1525 * netlbl_unlabel_defconf - Set the default config to allow unlabeled packets
1535 struct netlbl_dom_map *entry; in netlbl_unlabel_defconf() local
1545 entry = kzalloc(sizeof(*entry), GFP_KERNEL); in netlbl_unlabel_defconf()
1546 if (entry == NULL) in netlbl_unlabel_defconf()
1547 return -ENOMEM; in netlbl_unlabel_defconf()
1548 entry->family = AF_UNSPEC; in netlbl_unlabel_defconf()
1549 entry->def.type = NETLBL_NLTYPE_UNLABELED; in netlbl_unlabel_defconf()
1550 ret_val = netlbl_domhsh_add_default(entry, &audit_info); in netlbl_unlabel_defconf()