aboutsummaryrefslogtreecommitdiffstats
path: root/net/xfrm
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-11-14 00:37:28 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 17:53:42 -0500
commit66cdb3ca27323a92712d289fc5edc7841d74a139 (patch)
tree443c864e4cab413743c3ca755a50f8a5d0ec300d /net/xfrm
parentf04e7e8d7f175c05bbde3ae748bf2541da53721d (diff)
[IPSEC]: Move flow construction into xfrm_dst_lookup
This patch moves the flow construction from the callers of xfrm_dst_lookup into that function. It also changes xfrm_dst_lookup so that it takes an xfrm state as its argument instead of explicit addresses. This removes any address-specific logic from the callers of xfrm_dst_lookup which is needed to correctly support inter-family transforms. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/xfrm')
-rw-r--r--net/xfrm/xfrm_policy.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index df5bfa837eb3..085c19d4d1b7 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -13,6 +13,7 @@
13 * 13 *
14 */ 14 */
15 15
16#include <linux/err.h>
16#include <linux/slab.h> 17#include <linux/slab.h>
17#include <linux/kmod.h> 18#include <linux/kmod.h>
18#include <linux/list.h> 19#include <linux/list.h>
@@ -84,21 +85,25 @@ int xfrm_selector_match(struct xfrm_selector *sel, struct flowi *fl,
84 return 0; 85 return 0;
85} 86}
86 87
87int xfrm_dst_lookup(struct xfrm_dst **dst, struct flowi *fl, 88struct dst_entry *xfrm_dst_lookup(struct xfrm_state *x, int tos)
88 unsigned short family)
89{ 89{
90 struct xfrm_policy_afinfo *afinfo = xfrm_policy_get_afinfo(family); 90 xfrm_address_t *saddr = &x->props.saddr;
91 int err = 0; 91 xfrm_address_t *daddr = &x->id.daddr;
92 struct xfrm_policy_afinfo *afinfo;
93 struct dst_entry *dst;
92 94
95 if (x->type->flags & XFRM_TYPE_LOCAL_COADDR)
96 saddr = x->coaddr;
97 if (x->type->flags & XFRM_TYPE_REMOTE_COADDR)
98 daddr = x->coaddr;
99
100 afinfo = xfrm_policy_get_afinfo(x->props.family);
93 if (unlikely(afinfo == NULL)) 101 if (unlikely(afinfo == NULL))
94 return -EAFNOSUPPORT; 102 return ERR_PTR(-EAFNOSUPPORT);
95 103
96 if (likely(afinfo->dst_lookup != NULL)) 104 dst = afinfo->dst_lookup(tos, saddr, daddr);
97 err = afinfo->dst_lookup(dst, fl);
98 else
99 err = -EINVAL;
100 xfrm_policy_put_afinfo(afinfo); 105 xfrm_policy_put_afinfo(afinfo);
101 return err; 106 return dst;
102} 107}
103EXPORT_SYMBOL(xfrm_dst_lookup); 108EXPORT_SYMBOL(xfrm_dst_lookup);
104 109