Release 4.14 net/netfilter/nf_conntrack_extend.c
/* Structure dynamic extension infrastructure
* Copyright (C) 2004 Rusty Russell IBM Corporation
* Copyright (C) 2007 Netfilter Core Team <coreteam@netfilter.org>
* Copyright (C) 2007 USAGI/WIDE Project <http://www.linux-ipv6.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/rcupdate.h>
#include <linux/slab.h>
#include <linux/skbuff.h>
#include <net/netfilter/nf_conntrack_extend.h>
static struct nf_ct_ext_type __rcu *nf_ct_ext_types[NF_CT_EXT_NUM];
static DEFINE_MUTEX(nf_ct_ext_type_mutex);
#define NF_CT_EXT_PREALLOC 128u
/* conntrack events are on by default */
void nf_ct_ext_destroy(struct nf_conn *ct)
{
unsigned int i;
struct nf_ct_ext_type *t;
for (i = 0; i < NF_CT_EXT_NUM; i++) {
rcu_read_lock();
t = rcu_dereference(nf_ct_ext_types[i]);
/* Here the nf_ct_ext_type might have been unregisterd.
* I.e., it has responsible to cleanup private
* area in all conntracks when it is unregisterd.
*/
if (t && t->destroy)
t->destroy(ct);
rcu_read_unlock();
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yasuyuki Kozakai | 65 | 98.48% | 1 | 50.00% |
Liping Zhang | 1 | 1.52% | 1 | 50.00% |
Total | 66 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL(nf_ct_ext_destroy);
void *nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp)
{
unsigned int newlen, newoff, oldlen, alloc;
struct nf_ct_ext *old, *new;
struct nf_ct_ext_type *t;
/* Conntrack must not be confirmed to avoid races on reallocation. */
WARN_ON(nf_ct_is_confirmed(ct));
old = ct->ext;
if (old) {
if (__nf_ct_ext_exist(old, id))
return NULL;
oldlen = old->len;
} else {
oldlen = sizeof(*new);
}
rcu_read_lock();
t = rcu_dereference(nf_ct_ext_types[id]);
if (!t) {
rcu_read_unlock();
return NULL;
}
newoff = ALIGN(oldlen, t->align);
newlen = newoff + t->len;
rcu_read_unlock();
alloc = max(newlen, NF_CT_EXT_PREALLOC);
new = __krealloc(old, alloc, gfp);
if (!new)
return NULL;
if (!old) {
memset(new->offset, 0, sizeof(new->offset));
ct->ext = new;
} else if (new != old) {
kfree_rcu(old, rcu);
rcu_assign_pointer(ct->ext, new);
}
new->offset[id] = newoff;
new->len = newlen;
memset((void *)new + newoff, 0, newlen - newoff);
return (void *)new + newoff;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yasuyuki Kozakai | 138 | 52.67% | 1 | 7.14% |
Florian Westphal | 73 | 27.86% | 3 | 21.43% |
Changli Gao | 14 | 5.34% | 1 | 7.14% |
Patrick McHardy | 13 | 4.96% | 3 | 21.43% |
Liping Zhang | 11 | 4.20% | 1 | 7.14% |
Pekka J Enberg | 10 | 3.82% | 3 | 21.43% |
Lai Jiangshan | 2 | 0.76% | 1 | 7.14% |
Varsha Rao | 1 | 0.38% | 1 | 7.14% |
Total | 262 | 100.00% | 14 | 100.00% |
EXPORT_SYMBOL(nf_ct_ext_add);
/* This MUST be called in process context. */
int nf_ct_extend_register(const struct nf_ct_ext_type *type)
{
int ret = 0;
mutex_lock(&nf_ct_ext_type_mutex);
if (nf_ct_ext_types[type->id]) {
ret = -EBUSY;
goto out;
}
rcu_assign_pointer(nf_ct_ext_types[type->id], type);
out:
mutex_unlock(&nf_ct_ext_type_mutex);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yasuyuki Kozakai | 62 | 96.88% | 1 | 33.33% |
Eric Dumazet | 1 | 1.56% | 1 | 33.33% |
Florian Westphal | 1 | 1.56% | 1 | 33.33% |
Total | 64 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL_GPL(nf_ct_extend_register);
/* This MUST be called in process context. */
void nf_ct_extend_unregister(const struct nf_ct_ext_type *type)
{
mutex_lock(&nf_ct_ext_type_mutex);
RCU_INIT_POINTER(nf_ct_ext_types[type->id], NULL);
mutex_unlock(&nf_ct_ext_type_mutex);
synchronize_rcu();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yasuyuki Kozakai | 35 | 92.11% | 1 | 25.00% |
Liping Zhang | 1 | 2.63% | 1 | 25.00% |
Stephen Hemminger | 1 | 2.63% | 1 | 25.00% |
Florian Westphal | 1 | 2.63% | 1 | 25.00% |
Total | 38 | 100.00% | 4 | 100.00% |
EXPORT_SYMBOL_GPL(nf_ct_extend_unregister);
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yasuyuki Kozakai | 357 | 72.12% | 1 | 5.00% |
Florian Westphal | 81 | 16.36% | 5 | 25.00% |
Changli Gao | 14 | 2.83% | 1 | 5.00% |
Liping Zhang | 14 | 2.83% | 2 | 10.00% |
Patrick McHardy | 13 | 2.63% | 3 | 15.00% |
Pekka J Enberg | 10 | 2.02% | 3 | 15.00% |
Lai Jiangshan | 2 | 0.40% | 1 | 5.00% |
Eric Dumazet | 1 | 0.20% | 1 | 5.00% |
Stephen Hemminger | 1 | 0.20% | 1 | 5.00% |
Arnd Bergmann | 1 | 0.20% | 1 | 5.00% |
Varsha Rao | 1 | 0.20% | 1 | 5.00% |
Total | 495 | 100.00% | 20 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.