Release 4.11 net/netfilter/nf_sockopt.c
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/netfilter.h>
#include <linux/mutex.h>
#include <net/sock.h>
#include "nf_internals.h"
/* Sockopts only registered and called from user context, so
net locking would be overkill. Also, [gs]etsockopt calls may
sleep. */
static DEFINE_MUTEX(nf_sockopt_mutex);
static LIST_HEAD(nf_sockopts);
/* Do exclusive ranges overlap? */
static inline int overlap(int min1, int max1, int min2, int max2)
{
return max1 > min2 && min1 < max2;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Harald Welte | 28 | 100.00% | 1 | 100.00% |
Total | 28 | 100.00% | 1 | 100.00% |
/* Functions to register sockopt ranges (exclusive). */
int nf_register_sockopt(struct nf_sockopt_ops *reg)
{
struct nf_sockopt_ops *ops;
int ret = 0;
mutex_lock(&nf_sockopt_mutex);
list_for_each_entry(ops, &nf_sockopts, list) {
if (ops->pf == reg->pf
&& (overlap(ops->set_optmin, ops->set_optmax,
reg->set_optmin, reg->set_optmax)
|| overlap(ops->get_optmin, ops->get_optmax,
reg->get_optmin, reg->get_optmax))) {
NFDEBUG("nf_sock overlap: %u-%u/%u-%u v %u-%u/%u-%u\n",
ops->set_optmin, ops->set_optmax,
ops->get_optmin, ops->get_optmax,
reg->set_optmin, reg->set_optmax,
reg->get_optmin, reg->get_optmax);
ret = -EBUSY;
goto out;
}
}
list_add(®->list, &nf_sockopts);
out:
mutex_unlock(&nf_sockopt_mutex);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Harald Welte | 146 | 94.19% | 1 | 25.00% |
Alexey Dobriyan | 6 | 3.87% | 1 | 25.00% |
Pablo Neira Ayuso | 2 | 1.29% | 1 | 25.00% |
Arjan van de Ven | 1 | 0.65% | 1 | 25.00% |
Total | 155 | 100.00% | 4 | 100.00% |
EXPORT_SYMBOL(nf_register_sockopt);
void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
{
mutex_lock(&nf_sockopt_mutex);
list_del(®->list);
mutex_unlock(&nf_sockopt_mutex);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Harald Welte | 28 | 93.33% | 1 | 50.00% |
Arjan van de Ven | 2 | 6.67% | 1 | 50.00% |
Total | 30 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL(nf_unregister_sockopt);
static struct nf_sockopt_ops *nf_sockopt_find(struct sock *sk, u_int8_t pf,
int val, int get)
{
struct nf_sockopt_ops *ops;
mutex_lock(&nf_sockopt_mutex);
list_for_each_entry(ops, &nf_sockopts, list) {
if (ops->pf == pf) {
if (!try_module_get(ops->owner))
goto out_nosup;
if (get) {
if (val >= ops->get_optmin &&
val < ops->get_optmax)
goto out;
} else {
if (val >= ops->set_optmin &&
val < ops->set_optmax)
goto out;
}
module_put(ops->owner);
}
}
out_nosup:
ops = ERR_PTR(-ENOPROTOOPT);
out:
mutex_unlock(&nf_sockopt_mutex);
return ops;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Harald Welte | 83 | 60.58% | 1 | 14.29% |
Pavel Emelyanov | 33 | 24.09% | 1 | 14.29% |
Neil Horman | 13 | 9.49% | 1 | 14.29% |
Alexey Dobriyan | 4 | 2.92% | 1 | 14.29% |
Pablo Neira Ayuso | 2 | 1.46% | 1 | 14.29% |
Arjan van de Ven | 1 | 0.73% | 1 | 14.29% |
Jan Engelhardt | 1 | 0.73% | 1 | 14.29% |
Total | 137 | 100.00% | 7 | 100.00% |
/* Call get/setsockopt() */
static int nf_sockopt(struct sock *sk, u_int8_t pf, int val,
char __user *opt, int *len, int get)
{
struct nf_sockopt_ops *ops;
int ret;
ops = nf_sockopt_find(sk, pf, val, get);
if (IS_ERR(ops))
return PTR_ERR(ops);
if (get)
ret = ops->get(sk, val, opt, len);
else
ret = ops->set(sk, val, opt, *len);
module_put(ops->owner);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Pavel Emelyanov | 78 | 71.56% | 1 | 25.00% |
Harald Welte | 26 | 23.85% | 1 | 25.00% |
Neil Horman | 4 | 3.67% | 1 | 25.00% |
Jan Engelhardt | 1 | 0.92% | 1 | 25.00% |
Total | 109 | 100.00% | 4 | 100.00% |
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);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Harald Welte | 40 | 95.24% | 1 | 33.33% |
Jan Engelhardt | 1 | 2.38% | 1 | 33.33% |
David S. Miller | 1 | 2.38% | 1 | 33.33% |
Total | 42 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL(nf_setsockopt);
int nf_getsockopt(struct sock *sk, u_int8_t pf, int val, char __user *opt,
int *len)
{
return nf_sockopt(sk, pf, val, opt, len, 1);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Harald Welte | 40 | 97.56% | 1 | 50.00% |
Jan Engelhardt | 1 | 2.44% | 1 | 50.00% |
Total | 41 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL(nf_getsockopt);
#ifdef CONFIG_COMPAT
static int compat_nf_sockopt(struct sock *sk, u_int8_t pf, int val,
char __user *opt, int *len, int get)
{
struct nf_sockopt_ops *ops;
int ret;
ops = nf_sockopt_find(sk, pf, val, get);
if (IS_ERR(ops))
return PTR_ERR(ops);
if (get) {
if (ops->compat_get)
ret = ops->compat_get(sk, val, opt, len);
else
ret = ops->get(sk, val, opt, len);
} else {
if (ops->compat_set)
ret = ops->compat_set(sk, val, opt, *len);
else
ret = ops->set(sk, val, opt, *len);
}
module_put(ops->owner);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dmitry Mishin | 131 | 82.91% | 1 | 16.67% |
Pavel Emelyanov | 15 | 9.49% | 1 | 16.67% |
Neil Horman | 7 | 4.43% | 1 | 16.67% |
Patrick McHardy | 3 | 1.90% | 1 | 16.67% |
Jan Engelhardt | 1 | 0.63% | 1 | 16.67% |
Alexey Dobriyan | 1 | 0.63% | 1 | 16.67% |
Total | 158 | 100.00% | 6 | 100.00% |
int compat_nf_setsockopt(struct sock *sk, u_int8_t pf,
int val, char __user *opt, unsigned int len)
{
return compat_nf_sockopt(sk, pf, val, opt, &len, 0);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dmitry Mishin | 40 | 95.24% | 1 | 33.33% |
David S. Miller | 1 | 2.38% | 1 | 33.33% |
Jan Engelhardt | 1 | 2.38% | 1 | 33.33% |
Total | 42 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL(compat_nf_setsockopt);
int compat_nf_getsockopt(struct sock *sk, u_int8_t pf,
int val, char __user *opt, int *len)
{
return compat_nf_sockopt(sk, pf, val, opt, len, 1);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dmitry Mishin | 40 | 97.56% | 1 | 50.00% |
Jan Engelhardt | 1 | 2.44% | 1 | 50.00% |
Total | 41 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL(compat_nf_getsockopt);
#endif
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Harald Welte | 446 | 51.98% | 1 | 10.00% |
Dmitry Mishin | 226 | 26.34% | 1 | 10.00% |
Pavel Emelyanov | 127 | 14.80% | 1 | 10.00% |
Neil Horman | 24 | 2.80% | 1 | 10.00% |
Alexey Dobriyan | 11 | 1.28% | 1 | 10.00% |
Arjan van de Ven | 8 | 0.93% | 1 | 10.00% |
Jan Engelhardt | 7 | 0.82% | 1 | 10.00% |
Pablo Neira Ayuso | 4 | 0.47% | 1 | 10.00% |
Patrick McHardy | 3 | 0.35% | 1 | 10.00% |
David S. Miller | 2 | 0.23% | 1 | 10.00% |
Total | 858 | 100.00% | 10 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.