From: "David S. Miller" <davem@davemloft.net>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>
Subject: [RFC v2 PATCH 05/11] ipsec: Create and use new helpers for dst child access.
Date: Tue, 31 Oct 2017 23:10:48 +0900 [thread overview]
Message-ID: <20171031141054.9954-6-davem@davemloft.net> (raw)
In-Reply-To: <20171031141054.9954-1-davem@davemloft.net>
This will make a future change moving the dst->child pointer less
invasive.
Signed-off-by: David S. Miller <davem@davemloft.net>
---
include/net/xfrm.h | 5 +++++
net/xfrm/xfrm_policy.c | 47 +++++++++++++++++++++++------------------------
2 files changed, 28 insertions(+), 24 deletions(-)
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index be599f9bb60d..32267e099638 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -1003,6 +1003,11 @@ static inline struct dst_entry *xfrm_dst_child(const struct dst_entry *dst)
}
#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)
{
xfrm_pols_put(xdst->pols, xdst->num_pols);
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 1ecc8dbce2e2..206ac90ff4f0 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1545,8 +1545,8 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
unsigned long now = jiffies;
struct net_device *dev;
struct xfrm_mode *inner_mode;
- struct dst_entry *dst_prev = NULL;
- struct dst_entry *dst0 = NULL;
+ struct xfrm_dst *xdst_prev = NULL;
+ struct xfrm_dst *xdst0 = NULL;
int i = 0;
int err;
int header_len = 0;
@@ -1572,13 +1572,13 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
goto put_states;
}
- if (!dst_prev)
- dst0 = dst1;
+ if (!xdst_prev)
+ xdst0 = xdst;
else
/* Ref count is taken during xfrm_alloc_dst()
* 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) {
inner_mode = xfrm_ip2inner_mode(xfrm[i],
@@ -1615,8 +1615,8 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
dst1->input = dst_discard;
dst1->output = inner_mode->afinfo->output;
- dst1->next = dst_prev;
- dst_prev = dst1;
+ dst1->next = &xdst_prev->u.dst;
+ xdst_prev = xdst;
header_len += xfrm[i]->props.header_len;
if (xfrm[i]->type->flags & XFRM_TYPE_NON_FRAGMENT)
@@ -1624,40 +1624,39 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
trailer_len += xfrm[i]->props.trailer_len;
}
- dst_prev->child = dst;
- dst0->path = dst;
+ xfrm_dst_set_child(xdst_prev, dst);
+ xdst0->u.dst.path = dst;
err = -ENODEV;
dev = dst->dev;
if (!dev)
goto free_dst;
- xfrm_init_path((struct xfrm_dst *)dst0, dst, nfheader_len);
- xfrm_init_pmtu(dst_prev);
+ xfrm_init_path(xdst0, dst, nfheader_len);
+ xfrm_init_pmtu(&xdst_prev->u.dst);
- for (dst_prev = dst0; dst_prev != dst; dst_prev = xfrm_dst_child(dst_prev)) {
- struct xfrm_dst *xdst = (struct xfrm_dst *)dst_prev;
-
- err = xfrm_fill_dst(xdst, dev, fl);
+ for (xdst_prev = xdst0; xdst_prev != (struct xfrm_dst *)dst;
+ xdst_prev = (struct xfrm_dst *) xfrm_dst_child(&xdst_prev->u.dst)) {
+ err = xfrm_fill_dst(xdst_prev, dev, fl);
if (err)
goto free_dst;
- dst_prev->header_len = header_len;
- dst_prev->trailer_len = trailer_len;
- header_len -= xdst->u.dst.xfrm->props.header_len;
- trailer_len -= xdst->u.dst.xfrm->props.trailer_len;
+ xdst_prev->u.dst.header_len = header_len;
+ xdst_prev->u.dst.trailer_len = trailer_len;
+ header_len -= xdst_prev->u.dst.xfrm->props.header_len;
+ trailer_len -= xdst_prev->u.dst.xfrm->props.trailer_len;
}
out:
- return dst0;
+ return &xdst0->u.dst;
put_states:
for (; i < nx; i++)
xfrm_state_put(xfrm[i]);
free_dst:
- if (dst0)
- dst_release_immediate(dst0);
- dst0 = ERR_PTR(err);
+ if (xdst0)
+ dst_release_immediate(&xdst0->u.dst);
+ xdst0 = ERR_PTR(err);
goto out;
}
@@ -2005,7 +2004,7 @@ static struct xfrm_dst *xfrm_create_dummy_bundle(struct net *net,
dst1->output = xdst_queue_output;
dst_hold(dst);
- dst1->child = dst;
+ xfrm_dst_set_child(xdst, dst);
dst1->path = dst;
xfrm_init_path((struct xfrm_dst *)dst1, dst, 0);
--
2.13.6
next prev parent reply other threads:[~2017-10-31 14:20 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-31 14:10 [RFC v2 PATCH 00/11] net: Significantly shrink the size of routes David S. Miller
2017-10-31 14:10 ` [RFC v2 PATCH 01/11] net: dst->rt_next is unused David S. Miller
2017-10-31 18:36 ` Eric Dumazet
2017-10-31 14:10 ` [RFC v2 PATCH 02/11] decnet: Move dn_next into decnet route structure David S. Miller
2017-10-31 18:36 ` Eric Dumazet
2017-10-31 14:10 ` [RFC v2 PATCH 03/11] ipv6: Move rt6_next from dst_entry into ipv6 " David S. Miller
2017-10-31 18:37 ` Eric Dumazet
2017-10-31 14:10 ` [RFC v2 PATCH 04/11] net: Create and use new helper xfrm_dst_child() David S. Miller
2017-10-31 18:39 ` Eric Dumazet
2017-11-01 2:07 ` David Miller
2017-10-31 14:10 ` David S. Miller [this message]
2017-10-31 18:40 ` [RFC v2 PATCH 05/11] ipsec: Create and use new helpers for dst child access Eric Dumazet
2017-10-31 14:10 ` [RFC v2 PATCH 06/11] xfrm: Move child route linkage into xfrm_dst David S. Miller
2017-10-31 18:42 ` Eric Dumazet
2017-10-31 14:10 ` [RFC v2 PATCH 07/11] ipv6: Move dst->from into struct rt6_info David S. Miller
2017-10-31 18:47 ` Eric Dumazet
2017-10-31 14:10 ` [RFC v2 PATCH 08/11] xfrm: Move dst->path into struct xfrm_dst David S. Miller
2017-10-31 18:49 ` Eric Dumazet
2017-10-31 14:10 ` [RFC v2 PATCH 09/11] net: Rearrange dst_entry layout to avoid useless padding David S. Miller
2017-10-31 18:49 ` Eric Dumazet
2017-10-31 14:10 ` [RFC v2 PATCH 10/11] xfrm: Stop using dst->next in bundle construction David S. Miller
2017-10-31 18:52 ` Eric Dumazet
2017-10-31 14:10 ` [RFC v2 PATCH 11/11] net: Remove dst->next David S. Miller
2017-10-31 18:52 ` Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171031141054.9954-6-davem@davemloft.net \
--to=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).