30 #include <linux/types.h>
32 #include <linux/list.h>
33 #include <linux/slab.h>
36 #include <linux/in6.h>
38 #include <linux/ipv6.h>
45 #define SEL_NETPORT_HASH_SIZE 256
46 #define SEL_NETPORT_HASH_BKT_LIMIT 16
79 static unsigned int sel_netport_hashfn(
u16 pnum)
99 idx = sel_netport_hashfn(pnum);
100 list_for_each_entry_rcu(port, &sel_netport_hash[idx].
list, list)
101 if (port->
psec.port == pnum && port->
psec.protocol == protocol)
121 idx = sel_netport_hashfn(port->psec.port);
122 list_add_rcu(&port->list, &sel_netport_hash[idx].list);
127 sel_netport_hash[idx].list.prev,
128 lockdep_is_held(&sel_netport_lock)),
130 list_del_rcu(&tail->
list);
133 sel_netport_hash[
idx].size++;
148 static int sel_netport_sid_slow(
u8 protocol,
u16 pnum,
u32 *
sid)
154 spin_lock_bh(&sel_netport_lock);
155 port = sel_netport_find(protocol, pnum);
157 *sid = port->
psec.sid;
158 spin_unlock_bh(&sel_netport_lock);
168 new->psec.port = pnum;
170 new->psec.sid = *
sid;
171 sel_netport_insert(
new);
174 spin_unlock_bh(&sel_netport_lock);
177 "SELinux: failure in sel_netport_sid_slow(),"
178 " unable to determine network port label\n");
202 port = sel_netport_find(protocol, pnum);
204 *sid = port->
psec.sid;
210 return sel_netport_sid_slow(protocol, pnum, sid);
220 static void sel_netport_flush(
void)
225 spin_lock_bh(&sel_netport_lock);
228 &sel_netport_hash[idx].list, list) {
229 list_del_rcu(&port->
list);
232 sel_netport_hash[
idx].size = 0;
234 spin_unlock_bh(&sel_netport_lock);
237 static int sel_netport_avc_callback(
u32 event)
246 static __init int sel_netport_init(
void)
255 INIT_LIST_HEAD(&sel_netport_hash[iter].list);
256 sel_netport_hash[iter].size = 0;
261 panic(
"avc_add_callback() failed, error %d\n", ret);