Commit bd45c539 authored by Florian Westphal's avatar Florian Westphal Committed by David S. Miller

xfrm_policy: make xfrm_bundle_lookup return xfrm dst object

This allows to remove flow cache object embedded in struct xfrm_dst.
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 86dc8ee0
...@@ -1996,15 +1996,13 @@ static struct xfrm_dst *xfrm_create_dummy_bundle(struct net *net, ...@@ -1996,15 +1996,13 @@ static struct xfrm_dst *xfrm_create_dummy_bundle(struct net *net,
goto out; goto out;
} }
static struct flow_cache_object * static struct xfrm_dst *
xfrm_bundle_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir, struct xfrm_flo *xflo) xfrm_bundle_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir, struct xfrm_flo *xflo)
{ {
struct xfrm_policy *pols[XFRM_POLICY_TYPE_MAX]; struct xfrm_policy *pols[XFRM_POLICY_TYPE_MAX];
struct xfrm_dst *xdst, *new_xdst;
int num_pols = 0, num_xfrms = 0, err; int num_pols = 0, num_xfrms = 0, err;
struct xfrm_dst *xdst;
/* Check if the policies from old bundle are usable */
xdst = NULL;
/* Resolve policies to use if we couldn't get them from /* Resolve policies to use if we couldn't get them from
* previous cache entry */ * previous cache entry */
num_pols = 1; num_pols = 1;
...@@ -2018,19 +2016,19 @@ xfrm_bundle_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir, ...@@ -2018,19 +2016,19 @@ xfrm_bundle_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir,
if (num_xfrms <= 0) if (num_xfrms <= 0)
goto make_dummy_bundle; goto make_dummy_bundle;
new_xdst = xfrm_resolve_and_create_bundle(pols, num_pols, fl, family, xdst = xfrm_resolve_and_create_bundle(pols, num_pols, fl, family,
xflo->dst_orig); xflo->dst_orig);
if (IS_ERR(new_xdst)) { if (IS_ERR(xdst)) {
err = PTR_ERR(new_xdst); err = PTR_ERR(xdst);
if (err != -EAGAIN) if (err != -EAGAIN)
goto error; goto error;
goto make_dummy_bundle; goto make_dummy_bundle;
} else if (new_xdst == NULL) { } else if (xdst == NULL) {
num_xfrms = 0; num_xfrms = 0;
goto make_dummy_bundle; goto make_dummy_bundle;
} }
return &new_xdst->flo; return xdst;
make_dummy_bundle: make_dummy_bundle:
/* We found policies, but there's no bundles to instantiate: /* We found policies, but there's no bundles to instantiate:
...@@ -2046,7 +2044,7 @@ xfrm_bundle_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir, ...@@ -2046,7 +2044,7 @@ xfrm_bundle_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir,
memcpy(xdst->pols, pols, sizeof(struct xfrm_policy *) * num_pols); memcpy(xdst->pols, pols, sizeof(struct xfrm_policy *) * num_pols);
dst_hold(&xdst->u.dst); dst_hold(&xdst->u.dst);
return &xdst->flo; return xdst;
inc_error: inc_error:
XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTPOLERROR); XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTPOLERROR);
...@@ -2082,7 +2080,6 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig, ...@@ -2082,7 +2080,6 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
const struct sock *sk, int flags) const struct sock *sk, int flags)
{ {
struct xfrm_policy *pols[XFRM_POLICY_TYPE_MAX]; struct xfrm_policy *pols[XFRM_POLICY_TYPE_MAX];
struct flow_cache_object *flo;
struct xfrm_dst *xdst; struct xfrm_dst *xdst;
struct dst_entry *dst, *route; struct dst_entry *dst, *route;
u16 family = dst_orig->ops->family; u16 family = dst_orig->ops->family;
...@@ -2137,14 +2134,13 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig, ...@@ -2137,14 +2134,13 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
!net->xfrm.policy_count[XFRM_POLICY_OUT]) !net->xfrm.policy_count[XFRM_POLICY_OUT])
goto nopol; goto nopol;
flo = xfrm_bundle_lookup(net, fl, family, dir, &xflo); xdst = xfrm_bundle_lookup(net, fl, family, dir, &xflo);
if (flo == NULL) if (xdst == NULL)
goto nopol; goto nopol;
if (IS_ERR(flo)) { if (IS_ERR(xdst)) {
err = PTR_ERR(flo); err = PTR_ERR(xdst);
goto dropdst; goto dropdst;
} }
xdst = container_of(flo, struct xfrm_dst, flo);
num_pols = xdst->num_pols; num_pols = xdst->num_pols;
num_xfrms = xdst->num_xfrms; num_xfrms = xdst->num_xfrms;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment