Commit 657e4c34 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David S. Miller

netfilter: split nf_sockopt

Split nf_sockopt into a getsockopt and setsockopt side as they share
very little code.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c34bc10d
...@@ -89,36 +89,32 @@ static struct nf_sockopt_ops *nf_sockopt_find(struct sock *sk, u_int8_t pf, ...@@ -89,36 +89,32 @@ static struct nf_sockopt_ops *nf_sockopt_find(struct sock *sk, u_int8_t pf,
return ops; return ops;
} }
/* Call get/setsockopt() */ int nf_setsockopt(struct sock *sk, u_int8_t pf, int val, char __user *opt,
static int nf_sockopt(struct sock *sk, u_int8_t pf, int val, unsigned int len)
char __user *opt, int *len, int get)
{ {
struct nf_sockopt_ops *ops; struct nf_sockopt_ops *ops;
int ret; int ret;
ops = nf_sockopt_find(sk, pf, val, get); ops = nf_sockopt_find(sk, pf, val, 0);
if (IS_ERR(ops)) if (IS_ERR(ops))
return PTR_ERR(ops); return PTR_ERR(ops);
ret = ops->set(sk, val, opt, len);
if (get)
ret = ops->get(sk, val, opt, len);
else
ret = ops->set(sk, val, opt, *len);
module_put(ops->owner); module_put(ops->owner);
return ret; return ret;
} }
int nf_setsockopt(struct sock *sk, u_int8_t pf, int val, char __user *opt,
unsigned int len)
{
return nf_sockopt(sk, pf, val, opt, &len, 0);
}
EXPORT_SYMBOL(nf_setsockopt); EXPORT_SYMBOL(nf_setsockopt);
int nf_getsockopt(struct sock *sk, u_int8_t pf, int val, char __user *opt, int nf_getsockopt(struct sock *sk, u_int8_t pf, int val, char __user *opt,
int *len) int *len)
{ {
return nf_sockopt(sk, pf, val, opt, len, 1); struct nf_sockopt_ops *ops;
int ret;
ops = nf_sockopt_find(sk, pf, val, 1);
if (IS_ERR(ops))
return PTR_ERR(ops);
ret = ops->get(sk, val, opt, len);
module_put(ops->owner);
return ret;
} }
EXPORT_SYMBOL(nf_getsockopt); EXPORT_SYMBOL(nf_getsockopt);
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