Linux 2.6.17-rc6
[linux-2.6/next.git] / security / selinux / include / xfrm.h
blobc10f1fc415026257cdec73e7a1bd99eefb8b876d
1 /*
2 * SELinux support for the XFRM LSM hooks
4 * Author : Trent Jaeger, <jaegert@us.ibm.com>
5 */
6 #ifndef _SELINUX_XFRM_H_
7 #define _SELINUX_XFRM_H_
9 int selinux_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx);
10 int selinux_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new);
11 void selinux_xfrm_policy_free(struct xfrm_policy *xp);
12 int selinux_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
13 void selinux_xfrm_state_free(struct xfrm_state *x);
14 int selinux_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir);
17 * Extract the security blob from the sock (it's actually on the socket)
19 static inline struct inode_security_struct *get_sock_isec(struct sock *sk)
21 if (!sk->sk_socket)
22 return NULL;
24 return SOCK_INODE(sk->sk_socket)->i_security;
28 static inline u32 selinux_no_sk_sid(struct flowi *fl)
30 /* NOTE: no sock occurs on ICMP reply, forwards, ... */
31 /* icmp_reply: authorize as kernel packet */
32 if (fl && fl->proto == IPPROTO_ICMP) {
33 return SECINITSID_KERNEL;
36 return SECINITSID_ANY_SOCKET;
39 #ifdef CONFIG_SECURITY_NETWORK_XFRM
40 int selinux_xfrm_sock_rcv_skb(u32 sid, struct sk_buff *skb);
41 int selinux_xfrm_postroute_last(u32 isec_sid, struct sk_buff *skb);
42 u32 selinux_socket_getpeer_stream(struct sock *sk);
43 u32 selinux_socket_getpeer_dgram(struct sk_buff *skb);
44 #else
45 static inline int selinux_xfrm_sock_rcv_skb(u32 isec_sid, struct sk_buff *skb)
47 return 0;
50 static inline int selinux_xfrm_postroute_last(u32 isec_sid, struct sk_buff *skb)
52 return NF_ACCEPT;
55 static inline int selinux_socket_getpeer_stream(struct sock *sk)
57 return SECSID_NULL;
60 static inline int selinux_socket_getpeer_dgram(struct sk_buff *skb)
62 return SECSID_NULL;
64 #endif
66 #endif /* _SELINUX_XFRM_H_ */