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/xfrm_state.c | |
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/xfrm_state.c')
-rw-r--r-- | net/xfrm/xfrm_state.c | 18 |
1 files changed, 14 insertions, 4 deletions
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; |