Commit bba91e9a authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

[IPSEC]: Check encap_type at config time, in user API code.

Here is the patch to check encap_type at the earliest possible
opportunity in xfrm_user/af_key.

This will allow us to assume in esp4 that the encap_type from x->encap
is always valid.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@redhat.com>
parent 0f0bf487
......@@ -1075,6 +1075,15 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct sadb_msg *hdr,
n_type = ext_hdrs[SADB_X_EXT_NAT_T_TYPE-1];
natt->encap_type = n_type->sadb_x_nat_t_type_type;
switch (natt->encap_type) {
case UDP_ENCAP_ESPINUDP:
case UDP_ENCAP_ESPINUDP_NON_IKE:
break;
default:
err = -ENOPROTOOPT;
goto out;
}
if (ext_hdrs[SADB_X_EXT_NAT_T_SPORT-1]) {
struct sadb_x_nat_t_port* n_port =
ext_hdrs[SADB_X_EXT_NAT_T_SPORT-1];
......
......@@ -78,6 +78,15 @@ static int verify_encap_tmpl(struct rtattr **xfrma)
if ((rt->rta_len - sizeof(*rt)) < sizeof(*encap))
return -EINVAL;
encap = RTA_DATA(rt);
switch (encap->encap_type) {
case UDP_ENCAP_ESPINUDP:
case UDP_ENCAP_ESPINUDP_NON_IKE:
break;
default:
return -ENOPROTOOPT;
}
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment