xfrm.h 2.4 KB
Newer Older
1 2 3 4
/*
 * SELinux support for the XFRM LSM hooks
 *
 * Author : Trent Jaeger, <jaegert@us.ibm.com>
5
 * Updated : Venkat Yekkirala, <vyekkirala@TrustedCS.com>
6 7 8 9
 */
#ifndef _SELINUX_XFRM_H_
#define _SELINUX_XFRM_H_

10 11
#include <net/flow.h>

12
int selinux_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
13 14
			      struct xfrm_user_sec_ctx *uctx,
			      gfp_t gfp);
15 16 17 18
int selinux_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx,
			      struct xfrm_sec_ctx **new_ctxp);
void selinux_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
int selinux_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
19
int selinux_xfrm_state_alloc(struct xfrm_state *x,
20 21 22
			     struct xfrm_user_sec_ctx *uctx);
int selinux_xfrm_state_alloc_acquire(struct xfrm_state *x,
				     struct xfrm_sec_ctx *polsec, u32 secid);
23
void selinux_xfrm_state_free(struct xfrm_state *x);
C
Catherine Zhang 已提交
24
int selinux_xfrm_state_delete(struct xfrm_state *x);
25
int selinux_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
26
int selinux_xfrm_state_pol_flow_match(struct xfrm_state *x,
P
Paul Moore 已提交
27 28
				      struct xfrm_policy *xp,
				      const struct flowi *fl);
29 30

#ifdef CONFIG_SECURITY_NETWORK_XFRM
31 32 33 34 35 36 37
extern atomic_t selinux_xfrm_refcount;

static inline int selinux_xfrm_enabled(void)
{
	return (atomic_read(&selinux_xfrm_refcount) > 0);
}

38 39 40 41
int selinux_xfrm_sock_rcv_skb(u32 sk_sid, struct sk_buff *skb,
			      struct common_audit_data *ad);
int selinux_xfrm_postroute_last(u32 sk_sid, struct sk_buff *skb,
				struct common_audit_data *ad, u8 proto);
42
int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
43
int selinux_xfrm_skb_sid(struct sk_buff *skb, u32 *sid);
44 45 46

static inline void selinux_xfrm_notify_policyload(void)
{
F
fan.du 已提交
47 48
	struct net *net;

49
	atomic_inc(&flow_cache_genid);
F
fan.du 已提交
50 51 52 53
	rtnl_lock();
	for_each_net(net)
		rt_genid_bump_all(net);
	rtnl_unlock();
54
}
55
#else
56 57 58 59 60
static inline int selinux_xfrm_enabled(void)
{
	return 0;
}

61 62
static inline int selinux_xfrm_sock_rcv_skb(u32 sk_sid, struct sk_buff *skb,
					    struct common_audit_data *ad)
63 64 65 66
{
	return 0;
}

67 68 69
static inline int selinux_xfrm_postroute_last(u32 sk_sid, struct sk_buff *skb,
					      struct common_audit_data *ad,
					      u8 proto)
70
{
71
	return 0;
72
}
73

P
Paul Moore 已提交
74 75
static inline int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid,
					      int ckall)
76 77 78 79
{
	*sid = SECSID_NULL;
	return 0;
}
80 81 82 83

static inline void selinux_xfrm_notify_policyload(void)
{
}
84

85
static inline int selinux_xfrm_skb_sid(struct sk_buff *skb, u32 *sid)
86
{
87 88
	*sid = SECSID_NULL;
	return 0;
89
}
90
#endif
91

92
#endif /* _SELINUX_XFRM_H_ */