aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/xfrm/xfrm_state.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 2fd57f8f77c1..e25ff62ab2a6 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -2022,8 +2022,9 @@ int xfrm_init_state(struct xfrm_state *x)
2022 x->inner_mode = inner_mode; 2022 x->inner_mode = inner_mode;
2023 } else { 2023 } else {
2024 struct xfrm_mode *inner_mode_iaf; 2024 struct xfrm_mode *inner_mode_iaf;
2025 int iafamily = AF_INET;
2025 2026
2026 inner_mode = xfrm_get_mode(x->props.mode, AF_INET); 2027 inner_mode = xfrm_get_mode(x->props.mode, x->props.family);
2027 if (inner_mode == NULL) 2028 if (inner_mode == NULL)
2028 goto error; 2029 goto error;
2029 2030
@@ -2031,22 +2032,17 @@ int xfrm_init_state(struct xfrm_state *x)
2031 xfrm_put_mode(inner_mode); 2032 xfrm_put_mode(inner_mode);
2032 goto error; 2033 goto error;
2033 } 2034 }
2035 x->inner_mode = inner_mode;
2034 2036
2035 inner_mode_iaf = xfrm_get_mode(x->props.mode, AF_INET6); 2037 if (x->props.family == AF_INET)
2036 if (inner_mode_iaf == NULL) 2038 iafamily = AF_INET6;
2037 goto error;
2038 2039
2039 if (!(inner_mode_iaf->flags & XFRM_MODE_FLAG_TUNNEL)) { 2040 inner_mode_iaf = xfrm_get_mode(x->props.mode, iafamily);
2040 xfrm_put_mode(inner_mode_iaf); 2041 if (inner_mode_iaf) {
2041 goto error; 2042 if (inner_mode_iaf->flags & XFRM_MODE_FLAG_TUNNEL)
2042 } 2043 x->inner_mode_iaf = inner_mode_iaf;
2043 2044 else
2044 if (x->props.family == AF_INET) { 2045 xfrm_put_mode(inner_mode_iaf);
2045 x->inner_mode = inner_mode;
2046 x->inner_mode_iaf = inner_mode_iaf;
2047 } else {
2048 x->inner_mode = inner_mode_iaf;
2049 x->inner_mode_iaf = inner_mode;
2050 } 2046 }
2051 } 2047 }
2052 2048