Commit b7461116 authored by James Morris's avatar James Morris Committed by David S. Miller

[IPSEC]: Add family argument to compile_policy.

parent 3cbcab99
...@@ -223,7 +223,7 @@ struct xfrm_mgr ...@@ -223,7 +223,7 @@ struct xfrm_mgr
char *id; char *id;
int (*notify)(struct xfrm_state *x, int event); int (*notify)(struct xfrm_state *x, int event);
int (*acquire)(struct xfrm_state *x, struct xfrm_tmpl *, struct xfrm_policy *xp, int dir); int (*acquire)(struct xfrm_state *x, struct xfrm_tmpl *, struct xfrm_policy *xp, int dir);
struct xfrm_policy *(*compile_policy)(int opt, u8 *data, int len, int *dir); struct xfrm_policy *(*compile_policy)(u16 family, int opt, u8 *data, int len, int *dir);
}; };
extern int xfrm_register_km(struct xfrm_mgr *km); extern int xfrm_register_km(struct xfrm_mgr *km);
......
...@@ -680,7 +680,7 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 *optval, int optlen) ...@@ -680,7 +680,7 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 *optval, int optlen)
err = -EINVAL; err = -EINVAL;
read_lock(&xfrm_km_lock); read_lock(&xfrm_km_lock);
list_for_each_entry(km, &xfrm_km_list, list) { list_for_each_entry(km, &xfrm_km_list, list) {
pol = km->compile_policy(optname, data, optlen, &err); pol = km->compile_policy(sk->family, optname, data, optlen, &err);
if (err >= 0) if (err >= 0)
break; break;
} }
......
...@@ -538,6 +538,21 @@ static int verify_newpolicy_info(struct xfrm_userpolicy_info *p) ...@@ -538,6 +538,21 @@ static int verify_newpolicy_info(struct xfrm_userpolicy_info *p)
return -EINVAL; return -EINVAL;
}; };
switch (p->family) {
case AF_INET:
break;
case AF_INET6:
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
break;
#else
return -EAFNOSUPPORT;
#endif
default:
return -EINVAL;
};
return verify_policy_dir(p->dir); return verify_policy_dir(p->dir);
} }
...@@ -1057,7 +1072,8 @@ static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt, ...@@ -1057,7 +1072,8 @@ static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt,
/* User gives us xfrm_user_policy_info followed by an array of 0 /* User gives us xfrm_user_policy_info followed by an array of 0
* or more templates. * or more templates.
*/ */
struct xfrm_policy *xfrm_compile_policy(int opt, u8 *data, int len, int *dir) struct xfrm_policy *xfrm_compile_policy(u16 family, int opt,
u8 *data, int len, int *dir)
{ {
struct xfrm_userpolicy_info *p = (struct xfrm_userpolicy_info *)data; struct xfrm_userpolicy_info *p = (struct xfrm_userpolicy_info *)data;
struct xfrm_user_tmpl *ut = (struct xfrm_user_tmpl *) (p + 1); struct xfrm_user_tmpl *ut = (struct xfrm_user_tmpl *) (p + 1);
......
...@@ -2420,7 +2420,8 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct ...@@ -2420,7 +2420,8 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL); return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL);
} }
static struct xfrm_policy *pfkey_compile_policy(int opt, u8 *data, int len, int *dir) static struct xfrm_policy *pfkey_compile_policy(u16 family, int opt,
u8 *data, int len, int *dir)
{ {
struct xfrm_policy *xp; struct xfrm_policy *xp;
struct sadb_x_policy *pol = (struct sadb_x_policy*)data; struct sadb_x_policy *pol = (struct sadb_x_policy*)data;
...@@ -2451,6 +2452,7 @@ static struct xfrm_policy *pfkey_compile_policy(int opt, u8 *data, int len, int ...@@ -2451,6 +2452,7 @@ static struct xfrm_policy *pfkey_compile_policy(int opt, u8 *data, int len, int
xp->lft.hard_byte_limit = XFRM_INF; xp->lft.hard_byte_limit = XFRM_INF;
xp->lft.soft_packet_limit = XFRM_INF; xp->lft.soft_packet_limit = XFRM_INF;
xp->lft.hard_packet_limit = XFRM_INF; xp->lft.hard_packet_limit = XFRM_INF;
xp->family = family;
xp->xfrm_nr = 0; xp->xfrm_nr = 0;
if (pol->sadb_x_policy_type == IPSEC_POLICY_IPSEC && if (pol->sadb_x_policy_type == IPSEC_POLICY_IPSEC &&
......
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