Skip to content

Commit bd45c53

Browse files
Florian Westphaldavem330
authored andcommitted
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: Florian Westphal <fw@strlen.de> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 86dc8ee commit bd45c53

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

net/xfrm/xfrm_policy.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,15 +1996,13 @@ static struct xfrm_dst *xfrm_create_dummy_bundle(struct net *net,
19961996
goto out;
19971997
}
19981998

1999-
static struct flow_cache_object *
1999+
static struct xfrm_dst *
20002000
xfrm_bundle_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir, struct xfrm_flo *xflo)
20012001
{
20022002
struct xfrm_policy *pols[XFRM_POLICY_TYPE_MAX];
2003-
struct xfrm_dst *xdst, *new_xdst;
20042003
int num_pols = 0, num_xfrms = 0, err;
2004+
struct xfrm_dst *xdst;
20052005

2006-
/* Check if the policies from old bundle are usable */
2007-
xdst = NULL;
20082006
/* Resolve policies to use if we couldn't get them from
20092007
* previous cache entry */
20102008
num_pols = 1;
@@ -2018,19 +2016,19 @@ xfrm_bundle_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir,
20182016
if (num_xfrms <= 0)
20192017
goto make_dummy_bundle;
20202018

2021-
new_xdst = xfrm_resolve_and_create_bundle(pols, num_pols, fl, family,
2019+
xdst = xfrm_resolve_and_create_bundle(pols, num_pols, fl, family,
20222020
xflo->dst_orig);
2023-
if (IS_ERR(new_xdst)) {
2024-
err = PTR_ERR(new_xdst);
2021+
if (IS_ERR(xdst)) {
2022+
err = PTR_ERR(xdst);
20252023
if (err != -EAGAIN)
20262024
goto error;
20272025
goto make_dummy_bundle;
2028-
} else if (new_xdst == NULL) {
2026+
} else if (xdst == NULL) {
20292027
num_xfrms = 0;
20302028
goto make_dummy_bundle;
20312029
}
20322030

2033-
return &new_xdst->flo;
2031+
return xdst;
20342032

20352033
make_dummy_bundle:
20362034
/* 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,
20462044
memcpy(xdst->pols, pols, sizeof(struct xfrm_policy *) * num_pols);
20472045

20482046
dst_hold(&xdst->u.dst);
2049-
return &xdst->flo;
2047+
return xdst;
20502048

20512049
inc_error:
20522050
XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTPOLERROR);
@@ -2082,7 +2080,6 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
20822080
const struct sock *sk, int flags)
20832081
{
20842082
struct xfrm_policy *pols[XFRM_POLICY_TYPE_MAX];
2085-
struct flow_cache_object *flo;
20862083
struct xfrm_dst *xdst;
20872084
struct dst_entry *dst, *route;
20882085
u16 family = dst_orig->ops->family;
@@ -2137,14 +2134,13 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
21372134
!net->xfrm.policy_count[XFRM_POLICY_OUT])
21382135
goto nopol;
21392136

2140-
flo = xfrm_bundle_lookup(net, fl, family, dir, &xflo);
2141-
if (flo == NULL)
2137+
xdst = xfrm_bundle_lookup(net, fl, family, dir, &xflo);
2138+
if (xdst == NULL)
21422139
goto nopol;
2143-
if (IS_ERR(flo)) {
2144-
err = PTR_ERR(flo);
2140+
if (IS_ERR(xdst)) {
2141+
err = PTR_ERR(xdst);
21452142
goto dropdst;
21462143
}
2147-
xdst = container_of(flo, struct xfrm_dst, flo);
21482144

21492145
num_pols = xdst->num_pols;
21502146
num_xfrms = xdst->num_xfrms;

0 commit comments

Comments
 (0)