diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2007-10-18 00:35:51 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-10-18 00:35:51 -0400 |
commit | 13996378e6585fb25e582afe7489bf52dde78deb (patch) | |
tree | 4a1eb75c81a5a9d23c68f9818259f3b357dc8265 /net/xfrm | |
parent | ca68145f16359f71cd62b2671aa3e8c58f45ef19 (diff) |
[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: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/xfrm')
-rw-r--r-- | net/xfrm/xfrm_output.c | 4 | ||||
-rw-r--r-- | net/xfrm/xfrm_policy.c | 2 | ||||
-rw-r--r-- | net/xfrm/xfrm_state.c | 18 |
3 files changed, 17 insertions, 7 deletions
diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c index 8bf71ba2345f..f4bfd6c45651 100644 --- a/net/xfrm/xfrm_output.c +++ b/net/xfrm/xfrm_output.c | |||
@@ -63,7 +63,7 @@ int xfrm_output(struct sk_buff *skb) | |||
63 | xfrm_replay_notify(x, XFRM_REPLAY_UPDATE); | 63 | xfrm_replay_notify(x, XFRM_REPLAY_UPDATE); |
64 | } | 64 | } |
65 | 65 | ||
66 | err = x->mode->output(x, skb); | 66 | err = x->outer_mode->output(x, skb); |
67 | if (err) | 67 | if (err) |
68 | goto error; | 68 | goto error; |
69 | 69 | ||
@@ -82,7 +82,7 @@ int xfrm_output(struct sk_buff *skb) | |||
82 | } | 82 | } |
83 | dst = skb->dst; | 83 | dst = skb->dst; |
84 | x = dst->xfrm; | 84 | x = dst->xfrm; |
85 | } while (x && !(x->mode->flags & XFRM_MODE_FLAG_TUNNEL)); | 85 | } while (x && !(x->outer_mode->flags & XFRM_MODE_FLAG_TUNNEL)); |
86 | 86 | ||
87 | err = 0; | 87 | err = 0; |
88 | 88 | ||
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 1d66fb42c9cb..b702bd8a3893 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c | |||
@@ -1941,7 +1941,7 @@ int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *first, | |||
1941 | return 0; | 1941 | return 0; |
1942 | 1942 | ||
1943 | if (strict && fl && | 1943 | if (strict && fl && |
1944 | !(dst->xfrm->mode->flags & XFRM_MODE_FLAG_TUNNEL) && | 1944 | !(dst->xfrm->outer_mode->flags & XFRM_MODE_FLAG_TUNNEL) && |
1945 | !xfrm_state_addr_flow_check(dst->xfrm, fl, family)) | 1945 | !xfrm_state_addr_flow_check(dst->xfrm, fl, family)) |
1946 | return 0; | 1946 | return 0; |
1947 | 1947 | ||
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 48b4a06b3d1a..224b44e31a07 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c | |||
@@ -377,8 +377,10 @@ static void xfrm_state_gc_destroy(struct xfrm_state *x) | |||
377 | kfree(x->calg); | 377 | kfree(x->calg); |
378 | kfree(x->encap); | 378 | kfree(x->encap); |
379 | kfree(x->coaddr); | 379 | kfree(x->coaddr); |
380 | if (x->mode) | 380 | if (x->inner_mode) |
381 | xfrm_put_mode(x->mode); | 381 | xfrm_put_mode(x->inner_mode); |
382 | if (x->outer_mode) | ||
383 | xfrm_put_mode(x->outer_mode); | ||
382 | if (x->type) { | 384 | if (x->type) { |
383 | x->type->destructor(x); | 385 | x->type->destructor(x); |
384 | xfrm_put_type(x->type); | 386 | xfrm_put_type(x->type); |
@@ -1947,6 +1949,14 @@ int xfrm_init_state(struct xfrm_state *x) | |||
1947 | goto error; | 1949 | goto error; |
1948 | 1950 | ||
1949 | err = -EPROTONOSUPPORT; | 1951 | err = -EPROTONOSUPPORT; |
1952 | x->inner_mode = xfrm_get_mode(x->props.mode, x->sel.family); | ||
1953 | if (x->inner_mode == NULL) | ||
1954 | goto error; | ||
1955 | |||
1956 | if (!(x->inner_mode->flags & XFRM_MODE_FLAG_TUNNEL) && | ||
1957 | family != x->sel.family) | ||
1958 | goto error; | ||
1959 | |||
1950 | x->type = xfrm_get_type(x->id.proto, family); | 1960 | x->type = xfrm_get_type(x->id.proto, family); |
1951 | if (x->type == NULL) | 1961 | if (x->type == NULL) |
1952 | goto error; | 1962 | goto error; |
@@ -1955,8 +1965,8 @@ int xfrm_init_state(struct xfrm_state *x) | |||
1955 | if (err) | 1965 | if (err) |
1956 | goto error; | 1966 | goto error; |
1957 | 1967 | ||
1958 | x->mode = xfrm_get_mode(x->props.mode, family); | 1968 | x->outer_mode = xfrm_get_mode(x->props.mode, family); |
1959 | if (x->mode == NULL) | 1969 | if (x->outer_mode == NULL) |
1960 | goto error; | 1970 | goto error; |
1961 | 1971 | ||
1962 | x->km.state = XFRM_STATE_VALID; | 1972 | x->km.state = XFRM_STATE_VALID; |