Commit f2c4802b authored by Denis V. Lunev's avatar Denis V. Lunev Committed by David S. Miller

[NETNS]: Add namespace parameter to ip_options_get(...).

Pass the init_net there for now.
Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0e6bd4a1
...@@ -349,9 +349,9 @@ extern int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb); ...@@ -349,9 +349,9 @@ extern int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb);
extern void ip_options_fragment(struct sk_buff *skb); extern void ip_options_fragment(struct sk_buff *skb);
extern int ip_options_compile(struct net *net, extern int ip_options_compile(struct net *net,
struct ip_options *opt, struct sk_buff *skb); struct ip_options *opt, struct sk_buff *skb);
extern int ip_options_get(struct ip_options **optp, extern int ip_options_get(struct net *net, struct ip_options **optp,
unsigned char *data, int optlen); unsigned char *data, int optlen);
extern int ip_options_get_from_user(struct ip_options **optp, extern int ip_options_get_from_user(struct net *net, struct ip_options **optp,
unsigned char __user *data, int optlen); unsigned char __user *data, int optlen);
extern void ip_options_undo(struct ip_options * opt); extern void ip_options_undo(struct ip_options * opt);
extern void ip_forward_options(struct sk_buff *skb); extern void ip_forward_options(struct sk_buff *skb);
......
...@@ -507,13 +507,13 @@ static struct ip_options *ip_options_get_alloc(const int optlen) ...@@ -507,13 +507,13 @@ static struct ip_options *ip_options_get_alloc(const int optlen)
GFP_KERNEL); GFP_KERNEL);
} }
static int ip_options_get_finish(struct ip_options **optp, static int ip_options_get_finish(struct net *net, struct ip_options **optp,
struct ip_options *opt, int optlen) struct ip_options *opt, int optlen)
{ {
while (optlen & 3) while (optlen & 3)
opt->__data[optlen++] = IPOPT_END; opt->__data[optlen++] = IPOPT_END;
opt->optlen = optlen; opt->optlen = optlen;
if (optlen && ip_options_compile(&init_net, opt, NULL)) { if (optlen && ip_options_compile(net, opt, NULL)) {
kfree(opt); kfree(opt);
return -EINVAL; return -EINVAL;
} }
...@@ -522,7 +522,8 @@ static int ip_options_get_finish(struct ip_options **optp, ...@@ -522,7 +522,8 @@ static int ip_options_get_finish(struct ip_options **optp,
return 0; return 0;
} }
int ip_options_get_from_user(struct ip_options **optp, unsigned char __user *data, int optlen) int ip_options_get_from_user(struct net *net, struct ip_options **optp,
unsigned char __user *data, int optlen)
{ {
struct ip_options *opt = ip_options_get_alloc(optlen); struct ip_options *opt = ip_options_get_alloc(optlen);
...@@ -532,10 +533,11 @@ int ip_options_get_from_user(struct ip_options **optp, unsigned char __user *dat ...@@ -532,10 +533,11 @@ int ip_options_get_from_user(struct ip_options **optp, unsigned char __user *dat
kfree(opt); kfree(opt);
return -EFAULT; return -EFAULT;
} }
return ip_options_get_finish(optp, opt, optlen); return ip_options_get_finish(net, optp, opt, optlen);
} }
int ip_options_get(struct ip_options **optp, unsigned char *data, int optlen) int ip_options_get(struct net *net, struct ip_options **optp,
unsigned char *data, int optlen)
{ {
struct ip_options *opt = ip_options_get_alloc(optlen); struct ip_options *opt = ip_options_get_alloc(optlen);
...@@ -543,7 +545,7 @@ int ip_options_get(struct ip_options **optp, unsigned char *data, int optlen) ...@@ -543,7 +545,7 @@ int ip_options_get(struct ip_options **optp, unsigned char *data, int optlen)
return -ENOMEM; return -ENOMEM;
if (optlen) if (optlen)
memcpy(opt->__data, data, optlen); memcpy(opt->__data, data, optlen);
return ip_options_get_finish(optp, opt, optlen); return ip_options_get_finish(net, optp, opt, optlen);
} }
void ip_forward_options(struct sk_buff *skb) void ip_forward_options(struct sk_buff *skb)
......
...@@ -176,7 +176,7 @@ int ip_cmsg_send(struct msghdr *msg, struct ipcm_cookie *ipc) ...@@ -176,7 +176,7 @@ int ip_cmsg_send(struct msghdr *msg, struct ipcm_cookie *ipc)
switch (cmsg->cmsg_type) { switch (cmsg->cmsg_type) {
case IP_RETOPTS: case IP_RETOPTS:
err = cmsg->cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr)); err = cmsg->cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr));
err = ip_options_get(&ipc->opt, CMSG_DATA(cmsg), err < 40 ? err : 40); err = ip_options_get(&init_net, &ipc->opt, CMSG_DATA(cmsg), err < 40 ? err : 40);
if (err) if (err)
return err; return err;
break; break;
...@@ -449,7 +449,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, ...@@ -449,7 +449,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
struct ip_options * opt = NULL; struct ip_options * opt = NULL;
if (optlen > 40 || optlen < 0) if (optlen > 40 || optlen < 0)
goto e_inval; goto e_inval;
err = ip_options_get_from_user(&opt, optval, optlen); err = ip_options_get_from_user(&init_net, &opt, optval, optlen);
if (err) if (err)
break; break;
if (inet->is_icsk) { if (inet->is_icsk) {
......
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