aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/xfrm.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/xfrm.h')
-rw-r--r--include/net/xfrm.h63
1 files changed, 58 insertions, 5 deletions
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index fe881b6e2bd0..d6dae5ae7abe 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -239,7 +239,8 @@ struct xfrm_policy_afinfo {
239 int (*get_saddr)(xfrm_address_t *saddr, xfrm_address_t *daddr); 239 int (*get_saddr)(xfrm_address_t *saddr, xfrm_address_t *daddr);
240 struct dst_entry *(*find_bundle)(struct flowi *fl, struct xfrm_policy *policy); 240 struct dst_entry *(*find_bundle)(struct flowi *fl, struct xfrm_policy *policy);
241 void (*decode_session)(struct sk_buff *skb, 241 void (*decode_session)(struct sk_buff *skb,
242 struct flowi *fl); 242 struct flowi *fl,
243 int reverse);
243 int (*get_tos)(struct flowi *fl); 244 int (*get_tos)(struct flowi *fl);
244 int (*fill_dst)(struct xfrm_dst *xdst, 245 int (*fill_dst)(struct xfrm_dst *xdst,
245 struct net_device *dev); 246 struct net_device *dev);
@@ -844,14 +845,23 @@ xfrm_state_addr_cmp(struct xfrm_tmpl *tmpl, struct xfrm_state *x, unsigned short
844#ifdef CONFIG_XFRM 845#ifdef CONFIG_XFRM
845extern int __xfrm_policy_check(struct sock *, int dir, struct sk_buff *skb, unsigned short family); 846extern int __xfrm_policy_check(struct sock *, int dir, struct sk_buff *skb, unsigned short family);
846 847
847static inline int xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, unsigned short family) 848static inline int __xfrm_policy_check2(struct sock *sk, int dir,
849 struct sk_buff *skb,
850 unsigned int family, int reverse)
848{ 851{
852 int ndir = dir | (reverse ? XFRM_POLICY_MASK + 1 : 0);
853
849 if (sk && sk->sk_policy[XFRM_POLICY_IN]) 854 if (sk && sk->sk_policy[XFRM_POLICY_IN])
850 return __xfrm_policy_check(sk, dir, skb, family); 855 return __xfrm_policy_check(sk, ndir, skb, family);
851 856
852 return (!xfrm_policy_count[dir] && !skb->sp) || 857 return (!xfrm_policy_count[dir] && !skb->sp) ||
853 (skb->dst->flags & DST_NOPOLICY) || 858 (skb->dst->flags & DST_NOPOLICY) ||
854 __xfrm_policy_check(sk, dir, skb, family); 859 __xfrm_policy_check(sk, ndir, skb, family);
860}
861
862static inline int xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, unsigned short family)
863{
864 return __xfrm_policy_check2(sk, dir, skb, family, 0);
855} 865}
856 866
857static inline int xfrm4_policy_check(struct sock *sk, int dir, struct sk_buff *skb) 867static inline int xfrm4_policy_check(struct sock *sk, int dir, struct sk_buff *skb)
@@ -864,7 +874,34 @@ static inline int xfrm6_policy_check(struct sock *sk, int dir, struct sk_buff *s
864 return xfrm_policy_check(sk, dir, skb, AF_INET6); 874 return xfrm_policy_check(sk, dir, skb, AF_INET6);
865} 875}
866 876
867extern int xfrm_decode_session(struct sk_buff *skb, struct flowi *fl, unsigned short family); 877static inline int xfrm4_policy_check_reverse(struct sock *sk, int dir,
878 struct sk_buff *skb)
879{
880 return __xfrm_policy_check2(sk, dir, skb, AF_INET, 1);
881}
882
883static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
884 struct sk_buff *skb)
885{
886 return __xfrm_policy_check2(sk, dir, skb, AF_INET6, 1);
887}
888
889extern int __xfrm_decode_session(struct sk_buff *skb, struct flowi *fl,
890 unsigned int family, int reverse);
891
892static inline int xfrm_decode_session(struct sk_buff *skb, struct flowi *fl,
893 unsigned int family)
894{
895 return __xfrm_decode_session(skb, fl, family, 0);
896}
897
898static inline int xfrm_decode_session_reverse(struct sk_buff *skb,
899 struct flowi *fl,
900 unsigned int family)
901{
902 return __xfrm_decode_session(skb, fl, family, 1);
903}
904
868extern int __xfrm_route_forward(struct sk_buff *skb, unsigned short family); 905extern int __xfrm_route_forward(struct sk_buff *skb, unsigned short family);
869 906
870static inline int xfrm_route_forward(struct sk_buff *skb, unsigned short family) 907static inline int xfrm_route_forward(struct sk_buff *skb, unsigned short family)
@@ -925,6 +962,22 @@ static inline int xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *sk
925{ 962{
926 return 1; 963 return 1;
927} 964}
965static inline int xfrm_decode_session_reverse(struct sk_buff *skb,
966 struct flowi *fl,
967 unsigned int family)
968{
969 return -ENOSYS;
970}
971static inline int xfrm4_policy_check_reverse(struct sock *sk, int dir,
972 struct sk_buff *skb)
973{
974 return 1;
975}
976static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
977 struct sk_buff *skb)
978{
979 return 1;
980}
928#endif 981#endif
929 982
930static __inline__ 983static __inline__