Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 13996378 authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller
Browse files

[IPSEC]: Rename mode to outer_mode and add inner_mode



This patch adds a new field to xfrm states called inner_mode.  The existing
mode object is renamed to outer_mode.

This is the first part of an attempt to fix inter-family transforms.  As it
is we always use the outer family when determining which mode to use.  As a
result we may end up shoving IPv4 packets into netfilter6 and vice versa.

What we really want is to use the inner family for the first part of outbound
processing and the outer family for the second part.  For inbound processing
we'd use the opposite pairing.

I've also added a check to prevent silly combinations such as transport mode
with inter-family transforms.

Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ca68145f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -186,7 +186,8 @@ struct xfrm_state
	/* Reference to data common to all the instances of this
	 * transformer. */
	struct xfrm_type	*type;
	struct xfrm_mode	*mode;
	struct xfrm_mode	*inner_mode;
	struct xfrm_mode	*outer_mode;

	/* Security context */
	struct xfrm_sec_ctx	*security;
+1 −1
Original line number Diff line number Diff line
@@ -2454,7 +2454,7 @@ static int pktgen_output_ipsec(struct sk_buff *skb, struct pktgen_dev *pkt_dev)
	spin_lock(&x->lock);
	iph = ip_hdr(skb);

	err = x->mode->output(x, skb);
	err = x->outer_mode->output(x, skb);
	if (err)
		goto error;
	err = x->type->output(x, skb);
+2 −2
Original line number Diff line number Diff line
@@ -91,10 +91,10 @@ int xfrm4_rcv_encap(struct sk_buff *skb, int nexthdr, __be32 spi,

		xfrm_vec[xfrm_nr++] = x;

		if (x->mode->input(x, skb))
		if (x->outer_mode->input(x, skb))
			goto drop;

		if (x->mode->flags & XFRM_MODE_FLAG_TUNNEL) {
		if (x->outer_mode->flags & XFRM_MODE_FLAG_TUNNEL) {
			decaps = 1;
			break;
		}
+1 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ static inline int xfrm4_output_one(struct sk_buff *skb)
	struct iphdr *iph;
	int err;

	if (x->mode->flags & XFRM_MODE_FLAG_TUNNEL) {
	if (x->outer_mode->flags & XFRM_MODE_FLAG_TUNNEL) {
		err = xfrm4_tunnel_check_size(skb);
		if (err)
			goto error_nolock;
+1 −1
Original line number Diff line number Diff line
@@ -168,7 +168,7 @@ __xfrm4_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
		/* Copy neighbout for reachability confirmation */
		dst_prev->neighbour	= neigh_clone(rt->u.dst.neighbour);
		dst_prev->input		= rt->u.dst.input;
		dst_prev->output = dst_prev->xfrm->mode->afinfo->output;
		dst_prev->output = dst_prev->xfrm->outer_mode->afinfo->output;
		if (rt0->peer)
			atomic_inc(&rt0->peer->refcnt);
		x->u.rt.peer = rt0->peer;
Loading