ipsec: Create and use new helpers for dst child access.
This will make a future change moving the dst->child pointer less invasive. Signed-off-by: David S. Miller <davem@davemloft.net> Reviewed-by: Eric Dumazet <edumazet@google.com>
This commit is contained in:
parent
b92cf4aab8
commit
45b018bedd
@ -1004,6 +1004,11 @@ static inline struct dst_entry *xfrm_dst_child(const struct dst_entry *dst)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_XFRM
|
#ifdef CONFIG_XFRM
|
||||||
|
static inline void xfrm_dst_set_child(struct xfrm_dst *xdst, struct dst_entry *child)
|
||||||
|
{
|
||||||
|
xdst->u.dst.child = child;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void xfrm_dst_destroy(struct xfrm_dst *xdst)
|
static inline void xfrm_dst_destroy(struct xfrm_dst *xdst)
|
||||||
{
|
{
|
||||||
xfrm_pols_put(xdst->pols, xdst->num_pols);
|
xfrm_pols_put(xdst->pols, xdst->num_pols);
|
||||||
|
@ -1546,8 +1546,8 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
|
|||||||
unsigned long now = jiffies;
|
unsigned long now = jiffies;
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
struct xfrm_mode *inner_mode;
|
struct xfrm_mode *inner_mode;
|
||||||
struct dst_entry *dst_prev = NULL;
|
struct xfrm_dst *xdst_prev = NULL;
|
||||||
struct dst_entry *dst0 = NULL;
|
struct xfrm_dst *xdst0 = NULL;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int err;
|
int err;
|
||||||
int header_len = 0;
|
int header_len = 0;
|
||||||
@ -1573,13 +1573,13 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
|
|||||||
goto put_states;
|
goto put_states;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dst_prev)
|
if (!xdst_prev)
|
||||||
dst0 = dst1;
|
xdst0 = xdst;
|
||||||
else
|
else
|
||||||
/* Ref count is taken during xfrm_alloc_dst()
|
/* Ref count is taken during xfrm_alloc_dst()
|
||||||
* No need to do dst_clone() on dst1
|
* No need to do dst_clone() on dst1
|
||||||
*/
|
*/
|
||||||
dst_prev->child = dst1;
|
xfrm_dst_set_child(xdst_prev, &xdst->u.dst);
|
||||||
|
|
||||||
if (xfrm[i]->sel.family == AF_UNSPEC) {
|
if (xfrm[i]->sel.family == AF_UNSPEC) {
|
||||||
inner_mode = xfrm_ip2inner_mode(xfrm[i],
|
inner_mode = xfrm_ip2inner_mode(xfrm[i],
|
||||||
@ -1616,8 +1616,8 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
|
|||||||
dst1->input = dst_discard;
|
dst1->input = dst_discard;
|
||||||
dst1->output = inner_mode->afinfo->output;
|
dst1->output = inner_mode->afinfo->output;
|
||||||
|
|
||||||
dst1->next = dst_prev;
|
dst1->next = &xdst_prev->u.dst;
|
||||||
dst_prev = dst1;
|
xdst_prev = xdst;
|
||||||
|
|
||||||
header_len += xfrm[i]->props.header_len;
|
header_len += xfrm[i]->props.header_len;
|
||||||
if (xfrm[i]->type->flags & XFRM_TYPE_NON_FRAGMENT)
|
if (xfrm[i]->type->flags & XFRM_TYPE_NON_FRAGMENT)
|
||||||
@ -1625,40 +1625,39 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
|
|||||||
trailer_len += xfrm[i]->props.trailer_len;
|
trailer_len += xfrm[i]->props.trailer_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
dst_prev->child = dst;
|
xfrm_dst_set_child(xdst_prev, dst);
|
||||||
dst0->path = dst;
|
xdst0->u.dst.path = dst;
|
||||||
|
|
||||||
err = -ENODEV;
|
err = -ENODEV;
|
||||||
dev = dst->dev;
|
dev = dst->dev;
|
||||||
if (!dev)
|
if (!dev)
|
||||||
goto free_dst;
|
goto free_dst;
|
||||||
|
|
||||||
xfrm_init_path((struct xfrm_dst *)dst0, dst, nfheader_len);
|
xfrm_init_path(xdst0, dst, nfheader_len);
|
||||||
xfrm_init_pmtu(dst_prev);
|
xfrm_init_pmtu(&xdst_prev->u.dst);
|
||||||
|
|
||||||
for (dst_prev = dst0; dst_prev != dst; dst_prev = xfrm_dst_child(dst_prev)) {
|
for (xdst_prev = xdst0; xdst_prev != (struct xfrm_dst *)dst;
|
||||||
struct xfrm_dst *xdst = (struct xfrm_dst *)dst_prev;
|
xdst_prev = (struct xfrm_dst *) xfrm_dst_child(&xdst_prev->u.dst)) {
|
||||||
|
err = xfrm_fill_dst(xdst_prev, dev, fl);
|
||||||
err = xfrm_fill_dst(xdst, dev, fl);
|
|
||||||
if (err)
|
if (err)
|
||||||
goto free_dst;
|
goto free_dst;
|
||||||
|
|
||||||
dst_prev->header_len = header_len;
|
xdst_prev->u.dst.header_len = header_len;
|
||||||
dst_prev->trailer_len = trailer_len;
|
xdst_prev->u.dst.trailer_len = trailer_len;
|
||||||
header_len -= xdst->u.dst.xfrm->props.header_len;
|
header_len -= xdst_prev->u.dst.xfrm->props.header_len;
|
||||||
trailer_len -= xdst->u.dst.xfrm->props.trailer_len;
|
trailer_len -= xdst_prev->u.dst.xfrm->props.trailer_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
return dst0;
|
return &xdst0->u.dst;
|
||||||
|
|
||||||
put_states:
|
put_states:
|
||||||
for (; i < nx; i++)
|
for (; i < nx; i++)
|
||||||
xfrm_state_put(xfrm[i]);
|
xfrm_state_put(xfrm[i]);
|
||||||
free_dst:
|
free_dst:
|
||||||
if (dst0)
|
if (xdst0)
|
||||||
dst_release_immediate(dst0);
|
dst_release_immediate(&xdst0->u.dst);
|
||||||
dst0 = ERR_PTR(err);
|
xdst0 = ERR_PTR(err);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2012,7 +2011,7 @@ static struct xfrm_dst *xfrm_create_dummy_bundle(struct net *net,
|
|||||||
dst1->output = xdst_queue_output;
|
dst1->output = xdst_queue_output;
|
||||||
|
|
||||||
dst_hold(dst);
|
dst_hold(dst);
|
||||||
dst1->child = dst;
|
xfrm_dst_set_child(xdst, dst);
|
||||||
dst1->path = dst;
|
dst1->path = dst;
|
||||||
|
|
||||||
xfrm_init_path((struct xfrm_dst *)dst1, dst, 0);
|
xfrm_init_path((struct xfrm_dst *)dst1, dst, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user