Skip to content

Commit

Permalink
xfrm: Accept XFRM_STATE_AF_UNSPEC SAs on IPv4/IPv6 only hosts
Browse files Browse the repository at this point in the history
Installing SAs using the XFRM_STATE_AF_UNSPEC fails on hosts with
support for one address family only. This patch accepts such SAs, even
if the processing of not supported packets will fail.

Signed-off-by: Martin Willi <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
martinwilli authored and davem330 committed Dec 3, 2008
1 parent 29fa0b3 commit d81d228
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions net/xfrm/xfrm_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -2022,31 +2022,27 @@ int xfrm_init_state(struct xfrm_state *x)
x->inner_mode = inner_mode;
} else {
struct xfrm_mode *inner_mode_iaf;
int iafamily = AF_INET;

inner_mode = xfrm_get_mode(x->props.mode, AF_INET);
inner_mode = xfrm_get_mode(x->props.mode, x->props.family);
if (inner_mode == NULL)
goto error;

if (!(inner_mode->flags & XFRM_MODE_FLAG_TUNNEL)) {
xfrm_put_mode(inner_mode);
goto error;
}
x->inner_mode = inner_mode;

inner_mode_iaf = xfrm_get_mode(x->props.mode, AF_INET6);
if (inner_mode_iaf == NULL)
goto error;
if (x->props.family == AF_INET)
iafamily = AF_INET6;

if (!(inner_mode_iaf->flags & XFRM_MODE_FLAG_TUNNEL)) {
xfrm_put_mode(inner_mode_iaf);
goto error;
}

if (x->props.family == AF_INET) {
x->inner_mode = inner_mode;
x->inner_mode_iaf = inner_mode_iaf;
} else {
x->inner_mode = inner_mode_iaf;
x->inner_mode_iaf = inner_mode;
inner_mode_iaf = xfrm_get_mode(x->props.mode, iafamily);
if (inner_mode_iaf) {
if (inner_mode_iaf->flags & XFRM_MODE_FLAG_TUNNEL)
x->inner_mode_iaf = inner_mode_iaf;
else
xfrm_put_mode(inner_mode_iaf);
}
}

Expand Down

0 comments on commit d81d228

Please sign in to comment.