Commit e76726c2 authored by Tom Lendacky's avatar Tom Lendacky Committed by David S. Miller

[IPSEC]: Add IPV6_{IPSEC,XFRM}_POLICY socket option support.

parent c667ab2c
...@@ -180,5 +180,8 @@ struct in6_flowlabel_req ...@@ -180,5 +180,8 @@ struct in6_flowlabel_req
#define IPV6_FLOWLABEL_MGR 32 #define IPV6_FLOWLABEL_MGR 32
#define IPV6_FLOWINFO_SEND 33 #define IPV6_FLOWINFO_SEND 33
#define IPV6_IPSEC_POLICY 34
#define IPV6_XFRM_POLICY 35
#endif #endif
...@@ -1086,10 +1086,26 @@ struct xfrm_policy *xfrm_compile_policy(u16 family, int opt, ...@@ -1086,10 +1086,26 @@ struct xfrm_policy *xfrm_compile_policy(u16 family, int opt,
struct xfrm_policy *xp; struct xfrm_policy *xp;
int nr; int nr;
switch (family) {
case AF_INET:
if (opt != IP_XFRM_POLICY) { if (opt != IP_XFRM_POLICY) {
*dir = -EOPNOTSUPP; *dir = -EOPNOTSUPP;
return NULL; return NULL;
} }
break;
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
case AF_INET6:
if (opt != IPV6_XFRM_POLICY) {
*dir = -EOPNOTSUPP;
return NULL;
}
break;
#endif
default:
*dir = -EINVAL;
return NULL;
}
*dir = -EINVAL; *dir = -EINVAL;
if (len < sizeof(*p) || if (len < sizeof(*p) ||
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include <net/inet_common.h> #include <net/inet_common.h>
#include <net/tcp.h> #include <net/tcp.h>
#include <net/udp.h> #include <net/udp.h>
#include <net/xfrm.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -404,6 +405,10 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, char *optval, ...@@ -404,6 +405,10 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, char *optval,
case IPV6_FLOWLABEL_MGR: case IPV6_FLOWLABEL_MGR:
retv = ipv6_flowlabel_opt(sk, optval, optlen); retv = ipv6_flowlabel_opt(sk, optval, optlen);
break; break;
case IPV6_IPSEC_POLICY:
case IPV6_XFRM_POLICY:
retv = xfrm_user_policy(sk, optname, optval, optlen);
break;
#ifdef CONFIG_NETFILTER #ifdef CONFIG_NETFILTER
default: default:
......
...@@ -2416,10 +2416,25 @@ static struct xfrm_policy *pfkey_compile_policy(u16 family, int opt, ...@@ -2416,10 +2416,25 @@ static struct xfrm_policy *pfkey_compile_policy(u16 family, int opt,
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;
switch (family) {
case AF_INET:
if (opt != IP_IPSEC_POLICY) { if (opt != IP_IPSEC_POLICY) {
*dir = -EOPNOTSUPP; *dir = -EOPNOTSUPP;
return NULL; return NULL;
} }
break;
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
case AF_INET6:
if (opt != IPV6_IPSEC_POLICY) {
*dir = -EOPNOTSUPP;
return NULL;
}
break;
#endif
default:
*dir = -EINVAL;
return NULL;
}
*dir = -EINVAL; *dir = -EINVAL;
......
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