* [NETFILTER 01/22]: x_tables: remove duplicate of xt_prefix
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
@ 2007-03-14 8:50 ` Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 03/22]: nf_conntrack: switch protocol registration/unregistration to mutex Patrick McHardy
` (20 subsequent siblings)
21 siblings, 0 replies; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 8:50 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
[NETFILTER]: x_tables: remove duplicate of xt_prefix
Remove xt_proto_prefix array which duplicates xt_prefix and change all
users of xt_proto_prefix to xt_prefix.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit c9e0a6db3a45a0b71c5e81d4915c9734719ad998
tree d9d9db95b2b6cb407802db9d55dba496854741d4
parent 384510bca7c96113e5dca3bcc7f84a2934d707f1
author Tobias Klauser <tklauser@distanz.ch> Thu, 08 Mar 2007 18:22:29 +0100
committer Patrick McHardy <kaber@trash.net> Tue, 13 Mar 2007 17:01:59 +0100
net/netfilter/x_tables.c | 26 ++++++++++----------------
1 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index ec607a4..0eb2504 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -56,8 +56,8 @@ enum {
};
static const char *xt_prefix[NPROTO] = {
- [AF_INET] = "ip",
- [AF_INET6] = "ip6",
+ [AF_INET] = "ip",
+ [AF_INET6] = "ip6",
[NF_ARP] = "arp",
};
@@ -651,12 +651,6 @@ void *xt_unregister_table(struct xt_tabl
EXPORT_SYMBOL_GPL(xt_unregister_table);
#ifdef CONFIG_PROC_FS
-static char *xt_proto_prefix[NPROTO] = {
- [AF_INET] = "ip",
- [AF_INET6] = "ip6",
- [NF_ARP] = "arp",
-};
-
static struct list_head *xt_get_idx(struct list_head *list, struct seq_file *seq, loff_t pos)
{
struct list_head *head = list->next;
@@ -798,7 +792,7 @@ #endif
#ifdef CONFIG_PROC_FS
- strlcpy(buf, xt_proto_prefix[af], sizeof(buf));
+ strlcpy(buf, xt_prefix[af], sizeof(buf));
strlcat(buf, FORMAT_TABLES, sizeof(buf));
proc = proc_net_fops_create(buf, 0440, &xt_file_ops);
if (!proc)
@@ -806,14 +800,14 @@ #ifdef CONFIG_PROC_FS
proc->data = (void *) ((unsigned long) af | (TABLE << 16));
- strlcpy(buf, xt_proto_prefix[af], sizeof(buf));
+ strlcpy(buf, xt_prefix[af], sizeof(buf));
strlcat(buf, FORMAT_MATCHES, sizeof(buf));
proc = proc_net_fops_create(buf, 0440, &xt_file_ops);
if (!proc)
goto out_remove_tables;
proc->data = (void *) ((unsigned long) af | (MATCH << 16));
- strlcpy(buf, xt_proto_prefix[af], sizeof(buf));
+ strlcpy(buf, xt_prefix[af], sizeof(buf));
strlcat(buf, FORMAT_TARGETS, sizeof(buf));
proc = proc_net_fops_create(buf, 0440, &xt_file_ops);
if (!proc)
@@ -825,12 +819,12 @@ #endif
#ifdef CONFIG_PROC_FS
out_remove_matches:
- strlcpy(buf, xt_proto_prefix[af], sizeof(buf));
+ strlcpy(buf, xt_prefix[af], sizeof(buf));
strlcat(buf, FORMAT_MATCHES, sizeof(buf));
proc_net_remove(buf);
out_remove_tables:
- strlcpy(buf, xt_proto_prefix[af], sizeof(buf));
+ strlcpy(buf, xt_prefix[af], sizeof(buf));
strlcat(buf, FORMAT_TABLES, sizeof(buf));
proc_net_remove(buf);
out:
@@ -844,15 +838,15 @@ void xt_proto_fini(int af)
#ifdef CONFIG_PROC_FS
char buf[XT_FUNCTION_MAXNAMELEN];
- strlcpy(buf, xt_proto_prefix[af], sizeof(buf));
+ strlcpy(buf, xt_prefix[af], sizeof(buf));
strlcat(buf, FORMAT_TABLES, sizeof(buf));
proc_net_remove(buf);
- strlcpy(buf, xt_proto_prefix[af], sizeof(buf));
+ strlcpy(buf, xt_prefix[af], sizeof(buf));
strlcat(buf, FORMAT_TARGETS, sizeof(buf));
proc_net_remove(buf);
- strlcpy(buf, xt_proto_prefix[af], sizeof(buf));
+ strlcpy(buf, xt_prefix[af], sizeof(buf));
strlcat(buf, FORMAT_MATCHES, sizeof(buf));
proc_net_remove(buf);
#endif /*CONFIG_PROC_FS*/
^ permalink raw reply related [flat|nested] 25+ messages in thread* [NETFILTER 03/22]: nf_conntrack: switch protocol registration/unregistration to mutex
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 01/22]: x_tables: remove duplicate of xt_prefix Patrick McHardy
@ 2007-03-14 8:50 ` Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 04/22]: nf_conntrack: remove ugly hack in l4proto registration Patrick McHardy
` (19 subsequent siblings)
21 siblings, 0 replies; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 8:50 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
[NETFILTER]: nf_conntrack: switch protocol registration/unregistration to mutex
The protocol lookups done by nf_conntrack are already protected by RCU,
there is no need to keep taking nf_conntrack_lock for registration
and unregistration. Switch to a mutex.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 69b5f8d51819903743c648e829d247f0d156b889
tree 561177b4d270b5e1f30ed316c8b1535a68e10be1
parent 659738c122a278d4c15cb1b2dbd641b7acf80460
author Patrick McHardy <kaber@trash.net> Thu, 08 Mar 2007 18:23:57 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 14 Mar 2007 09:26:28 +0100
net/netfilter/nf_conntrack_proto.c | 52 ++++++++++++++++--------------------
1 files changed, 23 insertions(+), 29 deletions(-)
diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
index 456155f..e2c4a58 100644
--- a/net/netfilter/nf_conntrack_proto.c
+++ b/net/netfilter/nf_conntrack_proto.c
@@ -32,9 +32,9 @@ struct nf_conntrack_l4proto **nf_ct_prot
struct nf_conntrack_l3proto *nf_ct_l3protos[AF_MAX] __read_mostly;
EXPORT_SYMBOL_GPL(nf_ct_l3protos);
-#ifdef CONFIG_SYSCTL
-static DEFINE_MUTEX(nf_ct_proto_sysctl_mutex);
+static DEFINE_MUTEX(nf_ct_proto_mutex);
+#ifdef CONFIG_SYSCTL
static int
nf_ct_register_sysctl(struct ctl_table_header **header, struct ctl_table *path,
struct ctl_table *table, unsigned int *users)
@@ -164,13 +164,13 @@ static int nf_ct_l3proto_register_sysctl
int err = 0;
#ifdef CONFIG_SYSCTL
- mutex_lock(&nf_ct_proto_sysctl_mutex);
+ mutex_lock(&nf_ct_proto_mutex);
if (l3proto->ctl_table != NULL) {
err = nf_ct_register_sysctl(&l3proto->ctl_table_header,
l3proto->ctl_table_path,
l3proto->ctl_table, NULL);
}
- mutex_unlock(&nf_ct_proto_sysctl_mutex);
+ mutex_unlock(&nf_ct_proto_mutex);
#endif
return err;
}
@@ -178,11 +178,11 @@ #endif
static void nf_ct_l3proto_unregister_sysctl(struct nf_conntrack_l3proto *l3proto)
{
#ifdef CONFIG_SYSCTL
- mutex_lock(&nf_ct_proto_sysctl_mutex);
+ mutex_lock(&nf_ct_proto_mutex);
if (l3proto->ctl_table_header != NULL)
nf_ct_unregister_sysctl(&l3proto->ctl_table_header,
l3proto->ctl_table, NULL);
- mutex_unlock(&nf_ct_proto_sysctl_mutex);
+ mutex_unlock(&nf_ct_proto_mutex);
#endif
}
@@ -195,13 +195,13 @@ int nf_conntrack_l3proto_register(struct
goto out;
}
- write_lock_bh(&nf_conntrack_lock);
+ mutex_lock(&nf_ct_proto_mutex);
if (nf_ct_l3protos[proto->l3proto] != &nf_conntrack_l3proto_generic) {
ret = -EBUSY;
goto out_unlock;
}
rcu_assign_pointer(nf_ct_l3protos[proto->l3proto], proto);
- write_unlock_bh(&nf_conntrack_lock);
+ mutex_unlock(&nf_ct_proto_mutex);
ret = nf_ct_l3proto_register_sysctl(proto);
if (ret < 0)
@@ -209,7 +209,7 @@ int nf_conntrack_l3proto_register(struct
return ret;
out_unlock:
- write_unlock_bh(&nf_conntrack_lock);
+ mutex_unlock(&nf_ct_proto_mutex);
out:
return ret;
}
@@ -219,11 +219,11 @@ void nf_conntrack_l3proto_unregister(str
{
BUG_ON(proto->l3proto >= AF_MAX);
- write_lock_bh(&nf_conntrack_lock);
+ mutex_lock(&nf_ct_proto_mutex);
BUG_ON(nf_ct_l3protos[proto->l3proto] != proto);
rcu_assign_pointer(nf_ct_l3protos[proto->l3proto],
&nf_conntrack_l3proto_generic);
- write_unlock_bh(&nf_conntrack_lock);
+ mutex_unlock(&nf_ct_proto_mutex);
synchronize_rcu();
nf_ct_l3proto_unregister_sysctl(proto);
@@ -238,7 +238,7 @@ static int nf_ct_l4proto_register_sysctl
int err = 0;
#ifdef CONFIG_SYSCTL
- mutex_lock(&nf_ct_proto_sysctl_mutex);
+ mutex_lock(&nf_ct_proto_mutex);
if (l4proto->ctl_table != NULL) {
err = nf_ct_register_sysctl(l4proto->ctl_table_header,
nf_net_netfilter_sysctl_path,
@@ -260,7 +260,7 @@ #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
}
#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
out:
- mutex_unlock(&nf_ct_proto_sysctl_mutex);
+ mutex_unlock(&nf_ct_proto_mutex);
#endif /* CONFIG_SYSCTL */
return err;
}
@@ -268,7 +268,7 @@ #endif /* CONFIG_SYSCTL */
static void nf_ct_l4proto_unregister_sysctl(struct nf_conntrack_l4proto *l4proto)
{
#ifdef CONFIG_SYSCTL
- mutex_lock(&nf_ct_proto_sysctl_mutex);
+ mutex_lock(&nf_ct_proto_mutex);
if (l4proto->ctl_table_header != NULL &&
*l4proto->ctl_table_header != NULL)
nf_ct_unregister_sysctl(l4proto->ctl_table_header,
@@ -279,7 +279,7 @@ #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
nf_ct_unregister_sysctl(&l4proto->ctl_compat_table_header,
l4proto->ctl_compat_table, NULL);
#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
- mutex_unlock(&nf_ct_proto_sysctl_mutex);
+ mutex_unlock(&nf_ct_proto_mutex);
#endif /* CONFIG_SYSCTL */
}
@@ -297,8 +297,8 @@ int nf_conntrack_l4proto_register(struct
if (l4proto == &nf_conntrack_l4proto_generic)
return nf_ct_l4proto_register_sysctl(l4proto);
+ mutex_lock(&nf_ct_proto_mutex);
retry:
- write_lock_bh(&nf_conntrack_lock);
if (nf_ct_protos[l4proto->l3proto]) {
if (nf_ct_protos[l4proto->l3proto][l4proto->l4proto]
!= &nf_conntrack_l4proto_generic) {
@@ -310,28 +310,22 @@ retry:
struct nf_conntrack_l4proto **proto_array;
int i;
- write_unlock_bh(&nf_conntrack_lock);
-
proto_array = (struct nf_conntrack_l4proto **)
kmalloc(MAX_NF_CT_PROTO *
sizeof(struct nf_conntrack_l4proto *),
GFP_KERNEL);
if (proto_array == NULL) {
ret = -ENOMEM;
- goto out;
+ goto out_unlock;
}
for (i = 0; i < MAX_NF_CT_PROTO; i++)
proto_array[i] = &nf_conntrack_l4proto_generic;
- write_lock_bh(&nf_conntrack_lock);
- if (nf_ct_protos[l4proto->l3proto]) {
+ if (nf_ct_protos[l4proto->l3proto])
/* bad timing, but no problem */
- write_unlock_bh(&nf_conntrack_lock);
kfree(proto_array);
- } else {
+ else
nf_ct_protos[l4proto->l3proto] = proto_array;
- write_unlock_bh(&nf_conntrack_lock);
- }
/*
* Just once because array is never freed until unloading
@@ -341,7 +335,7 @@ retry:
}
rcu_assign_pointer(nf_ct_protos[l4proto->l3proto][l4proto->l4proto], l4proto);
- write_unlock_bh(&nf_conntrack_lock);
+ mutex_unlock(&nf_ct_proto_mutex);
ret = nf_ct_l4proto_register_sysctl(l4proto);
if (ret < 0)
@@ -349,7 +343,7 @@ retry:
return ret;
out_unlock:
- write_unlock_bh(&nf_conntrack_lock);
+ mutex_unlock(&nf_ct_proto_mutex);
out:
return ret;
}
@@ -364,11 +358,11 @@ void nf_conntrack_l4proto_unregister(str
return;
}
- write_lock_bh(&nf_conntrack_lock);
+ mutex_lock(&nf_ct_proto_mutex);
BUG_ON(nf_ct_protos[l4proto->l3proto][l4proto->l4proto] != l4proto);
rcu_assign_pointer(nf_ct_protos[l4proto->l3proto][l4proto->l4proto],
&nf_conntrack_l4proto_generic);
- write_unlock_bh(&nf_conntrack_lock);
+ mutex_unlock(&nf_ct_proto_mutex);
synchronize_rcu();
nf_ct_l4proto_unregister_sysctl(l4proto);
^ permalink raw reply related [flat|nested] 25+ messages in thread* [NETFILTER 04/22]: nf_conntrack: remove ugly hack in l4proto registration
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 01/22]: x_tables: remove duplicate of xt_prefix Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 03/22]: nf_conntrack: switch protocol registration/unregistration to mutex Patrick McHardy
@ 2007-03-14 8:50 ` Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 05/22]: nf_conntrack: simplify protocol locking Patrick McHardy
` (18 subsequent siblings)
21 siblings, 0 replies; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 8:50 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
[NETFILTER]: nf_conntrack: remove ugly hack in l4proto registration
Remove ugly special-casing of nf_conntrack_l4proto_generic, all it
wants is its sysctl tables registered, so do that explicitly in an
init function and move the remaining protocol initialization and
cleanup code to nf_conntrack_proto.c as well.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 54043273620aa19f6b4334a56e04d90385b96d85
tree b1d212025330251bf39a38414de7488a2bf9bf30
parent 69b5f8d51819903743c648e829d247f0d156b889
author Patrick McHardy <kaber@trash.net> Thu, 08 Mar 2007 18:24:09 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 14 Mar 2007 09:27:11 +0100
include/net/netfilter/nf_conntrack_core.h | 3 +++
net/netfilter/nf_conntrack_core.c | 18 ++-------------
net/netfilter/nf_conntrack_proto.c | 34 ++++++++++++++++++++++-------
3 files changed, 31 insertions(+), 24 deletions(-)
diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h
index 85634e1..9fb9066 100644
--- a/include/net/netfilter/nf_conntrack_core.h
+++ b/include/net/netfilter/nf_conntrack_core.h
@@ -27,6 +27,9 @@ extern unsigned int nf_conntrack_in(int
extern int nf_conntrack_init(void);
extern void nf_conntrack_cleanup(void);
+extern int nf_conntrack_proto_init(void);
+extern void nf_conntrack_proto_fini(void);
+
struct nf_conntrack_l3proto;
extern struct nf_conntrack_l3proto *nf_ct_find_l3proto(u_int16_t pf);
/* Like above, but you already have conntrack read lock. */
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 7694c51..9858bcb 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -1152,14 +1152,7 @@ void nf_conntrack_cleanup(void)
free_conntrack_hash(nf_conntrack_hash, nf_conntrack_vmalloc,
nf_conntrack_htable_size);
- nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_generic);
-
- /* free l3proto protocol tables */
- for (i = 0; i < PF_MAX; i++)
- if (nf_ct_protos[i]) {
- kfree(nf_ct_protos[i]);
- nf_ct_protos[i] = NULL;
- }
+ nf_conntrack_proto_fini();
}
static struct list_head *alloc_hashtable(int size, int *vmalloced)
@@ -1237,7 +1230,6 @@ module_param_call(hashsize, set_hashsize
int __init nf_conntrack_init(void)
{
- unsigned int i;
int ret;
/* Idea from tcp.c: use 1/16384 of memory. On i386: 32MB
@@ -1279,16 +1271,10 @@ int __init nf_conntrack_init(void)
goto err_free_conntrack_slab;
}
- ret = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_generic);
+ ret = nf_conntrack_proto_init();
if (ret < 0)
goto out_free_expect_slab;
- /* Don't NEED lock here, but good form anyway. */
- write_lock_bh(&nf_conntrack_lock);
- for (i = 0; i < AF_MAX; i++)
- nf_ct_l3protos[i] = &nf_conntrack_l3proto_generic;
- write_unlock_bh(&nf_conntrack_lock);
-
/* For use by REJECT target */
rcu_assign_pointer(ip_ct_attach, __nf_conntrack_attach);
diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
index e2c4a58..0ca2f0b 100644
--- a/net/netfilter/nf_conntrack_proto.c
+++ b/net/netfilter/nf_conntrack_proto.c
@@ -294,9 +294,6 @@ int nf_conntrack_l4proto_register(struct
goto out;
}
- if (l4proto == &nf_conntrack_l4proto_generic)
- return nf_ct_l4proto_register_sysctl(l4proto);
-
mutex_lock(&nf_ct_proto_mutex);
retry:
if (nf_ct_protos[l4proto->l3proto]) {
@@ -353,11 +350,6 @@ void nf_conntrack_l4proto_unregister(str
{
BUG_ON(l4proto->l3proto >= PF_MAX);
- if (l4proto == &nf_conntrack_l4proto_generic) {
- nf_ct_l4proto_unregister_sysctl(l4proto);
- return;
- }
-
mutex_lock(&nf_ct_proto_mutex);
BUG_ON(nf_ct_protos[l4proto->l3proto][l4proto->l4proto] != l4proto);
rcu_assign_pointer(nf_ct_protos[l4proto->l3proto][l4proto->l4proto],
@@ -371,3 +363,29 @@ void nf_conntrack_l4proto_unregister(str
nf_ct_iterate_cleanup(kill_l4proto, l4proto);
}
EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_unregister);
+
+int nf_conntrack_proto_init(void)
+{
+ unsigned int i;
+ int err;
+
+ err = nf_ct_l4proto_register_sysctl(&nf_conntrack_l4proto_generic);
+ if (err < 0)
+ return err;
+
+ for (i = 0; i < AF_MAX; i++)
+ rcu_assign_pointer(nf_ct_l3protos[i],
+ &nf_conntrack_l3proto_generic);
+ return 0;
+}
+
+void nf_conntrack_proto_fini(void)
+{
+ unsigned int i;
+
+ nf_ct_l4proto_unregister_sysctl(&nf_conntrack_l4proto_generic);
+
+ /* free l3proto protocol tables */
+ for (i = 0; i < PF_MAX; i++)
+ kfree(nf_ct_protos[i]);
+}
^ permalink raw reply related [flat|nested] 25+ messages in thread* [NETFILTER 05/22]: nf_conntrack: simplify protocol locking
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
` (2 preceding siblings ...)
2007-03-14 8:50 ` [NETFILTER 04/22]: nf_conntrack: remove ugly hack in l4proto registration Patrick McHardy
@ 2007-03-14 8:50 ` Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 06/22]: nf_conntrack: simplify l4 protocol array allocation Patrick McHardy
` (17 subsequent siblings)
21 siblings, 0 replies; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 8:50 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
[NETFILTER]: nf_conntrack: simplify protocol locking
Now that we don't use nf_conntrack_lock anymore but a single mutex for
all protocol handling, no need to release and grab it again for sysctl
registration.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit ea67c267464258ebf4752a9f23a30b965b6985a0
tree ba2a559594f6035e5b827a9a2d6651559dfbde08
parent 54043273620aa19f6b4334a56e04d90385b96d85
author Patrick McHardy <kaber@trash.net> Thu, 08 Mar 2007 18:24:21 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 14 Mar 2007 09:28:46 +0100
net/netfilter/nf_conntrack_proto.c | 45 +++++++++++-------------------------
1 files changed, 14 insertions(+), 31 deletions(-)
diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
index 0ca2f0b..5097254 100644
--- a/net/netfilter/nf_conntrack_proto.c
+++ b/net/netfilter/nf_conntrack_proto.c
@@ -164,13 +164,11 @@ static int nf_ct_l3proto_register_sysctl
int err = 0;
#ifdef CONFIG_SYSCTL
- mutex_lock(&nf_ct_proto_mutex);
if (l3proto->ctl_table != NULL) {
err = nf_ct_register_sysctl(&l3proto->ctl_table_header,
l3proto->ctl_table_path,
l3proto->ctl_table, NULL);
}
- mutex_unlock(&nf_ct_proto_mutex);
#endif
return err;
}
@@ -178,11 +176,9 @@ #endif
static void nf_ct_l3proto_unregister_sysctl(struct nf_conntrack_l3proto *l3proto)
{
#ifdef CONFIG_SYSCTL
- mutex_lock(&nf_ct_proto_mutex);
if (l3proto->ctl_table_header != NULL)
nf_ct_unregister_sysctl(&l3proto->ctl_table_header,
l3proto->ctl_table, NULL);
- mutex_unlock(&nf_ct_proto_mutex);
#endif
}
@@ -190,27 +186,23 @@ int nf_conntrack_l3proto_register(struct
{
int ret = 0;
- if (proto->l3proto >= AF_MAX) {
- ret = -EBUSY;
- goto out;
- }
+ if (proto->l3proto >= AF_MAX)
+ return -EBUSY;
mutex_lock(&nf_ct_proto_mutex);
if (nf_ct_l3protos[proto->l3proto] != &nf_conntrack_l3proto_generic) {
ret = -EBUSY;
goto out_unlock;
}
- rcu_assign_pointer(nf_ct_l3protos[proto->l3proto], proto);
- mutex_unlock(&nf_ct_proto_mutex);
ret = nf_ct_l3proto_register_sysctl(proto);
if (ret < 0)
- nf_conntrack_l3proto_unregister(proto);
- return ret;
+ goto out_unlock;
+
+ rcu_assign_pointer(nf_ct_l3protos[proto->l3proto], proto);
out_unlock:
mutex_unlock(&nf_ct_proto_mutex);
-out:
return ret;
}
EXPORT_SYMBOL_GPL(nf_conntrack_l3proto_register);
@@ -223,10 +215,10 @@ void nf_conntrack_l3proto_unregister(str
BUG_ON(nf_ct_l3protos[proto->l3proto] != proto);
rcu_assign_pointer(nf_ct_l3protos[proto->l3proto],
&nf_conntrack_l3proto_generic);
+ nf_ct_l3proto_unregister_sysctl(proto);
mutex_unlock(&nf_ct_proto_mutex);
- synchronize_rcu();
- nf_ct_l3proto_unregister_sysctl(proto);
+ synchronize_rcu();
/* Remove all contrack entries for this protocol */
nf_ct_iterate_cleanup(kill_l3proto, proto);
@@ -238,7 +230,6 @@ static int nf_ct_l4proto_register_sysctl
int err = 0;
#ifdef CONFIG_SYSCTL
- mutex_lock(&nf_ct_proto_mutex);
if (l4proto->ctl_table != NULL) {
err = nf_ct_register_sysctl(l4proto->ctl_table_header,
nf_net_netfilter_sysctl_path,
@@ -260,7 +251,6 @@ #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
}
#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
out:
- mutex_unlock(&nf_ct_proto_mutex);
#endif /* CONFIG_SYSCTL */
return err;
}
@@ -268,7 +258,6 @@ #endif /* CONFIG_SYSCTL */
static void nf_ct_l4proto_unregister_sysctl(struct nf_conntrack_l4proto *l4proto)
{
#ifdef CONFIG_SYSCTL
- mutex_lock(&nf_ct_proto_mutex);
if (l4proto->ctl_table_header != NULL &&
*l4proto->ctl_table_header != NULL)
nf_ct_unregister_sysctl(l4proto->ctl_table_header,
@@ -279,7 +268,6 @@ #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
nf_ct_unregister_sysctl(&l4proto->ctl_compat_table_header,
l4proto->ctl_compat_table, NULL);
#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
- mutex_unlock(&nf_ct_proto_mutex);
#endif /* CONFIG_SYSCTL */
}
@@ -289,10 +277,8 @@ int nf_conntrack_l4proto_register(struct
{
int ret = 0;
- if (l4proto->l3proto >= PF_MAX) {
- ret = -EBUSY;
- goto out;
- }
+ if (l4proto->l3proto >= PF_MAX)
+ return -EBUSY;
mutex_lock(&nf_ct_proto_mutex);
retry:
@@ -331,17 +317,14 @@ retry:
goto retry;
}
- rcu_assign_pointer(nf_ct_protos[l4proto->l3proto][l4proto->l4proto], l4proto);
- mutex_unlock(&nf_ct_proto_mutex);
-
ret = nf_ct_l4proto_register_sysctl(l4proto);
if (ret < 0)
- nf_conntrack_l4proto_unregister(l4proto);
- return ret;
+ goto out_unlock;
+
+ rcu_assign_pointer(nf_ct_protos[l4proto->l3proto][l4proto->l4proto], l4proto);
out_unlock:
mutex_unlock(&nf_ct_proto_mutex);
-out:
return ret;
}
EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_register);
@@ -354,10 +337,10 @@ void nf_conntrack_l4proto_unregister(str
BUG_ON(nf_ct_protos[l4proto->l3proto][l4proto->l4proto] != l4proto);
rcu_assign_pointer(nf_ct_protos[l4proto->l3proto][l4proto->l4proto],
&nf_conntrack_l4proto_generic);
+ nf_ct_l4proto_unregister_sysctl(l4proto);
mutex_unlock(&nf_ct_proto_mutex);
- synchronize_rcu();
- nf_ct_l4proto_unregister_sysctl(l4proto);
+ synchronize_rcu();
/* Remove all contrack entries for this protocol */
nf_ct_iterate_cleanup(kill_l4proto, l4proto);
^ permalink raw reply related [flat|nested] 25+ messages in thread* [NETFILTER 06/22]: nf_conntrack: simplify l4 protocol array allocation
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
` (3 preceding siblings ...)
2007-03-14 8:50 ` [NETFILTER 05/22]: nf_conntrack: simplify protocol locking Patrick McHardy
@ 2007-03-14 8:50 ` Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 07/22]: nfnetlink: use mutex instead of semaphore Patrick McHardy
` (16 subsequent siblings)
21 siblings, 0 replies; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 8:50 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
[NETFILTER]: nf_conntrack: simplify l4 protocol array allocation
The retrying after an allocation failure is not necessary anymore
since we're holding the mutex the entire time, for the same
reason the double allocation race can't happen anymore.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit e4cfced6765b323aaf85882448deef3008a2e204
tree 39afbf17c060a2de7cd21bfbbc807a14a2d66dad
parent ea67c267464258ebf4752a9f23a30b965b6985a0
author Patrick McHardy <kaber@trash.net> Thu, 08 Mar 2007 18:24:32 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 14 Mar 2007 09:29:11 +0100
net/netfilter/nf_conntrack_proto.c | 37 ++++++++++++------------------------
1 files changed, 12 insertions(+), 25 deletions(-)
diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
index 5097254..e4aad20 100644
--- a/net/netfilter/nf_conntrack_proto.c
+++ b/net/netfilter/nf_conntrack_proto.c
@@ -281,47 +281,34 @@ int nf_conntrack_l4proto_register(struct
return -EBUSY;
mutex_lock(&nf_ct_proto_mutex);
-retry:
- if (nf_ct_protos[l4proto->l3proto]) {
- if (nf_ct_protos[l4proto->l3proto][l4proto->l4proto]
- != &nf_conntrack_l4proto_generic) {
- ret = -EBUSY;
- goto out_unlock;
- }
- } else {
+ if (!nf_ct_protos[l4proto->l3proto]) {
/* l3proto may be loaded latter. */
struct nf_conntrack_l4proto **proto_array;
int i;
- proto_array = (struct nf_conntrack_l4proto **)
- kmalloc(MAX_NF_CT_PROTO *
- sizeof(struct nf_conntrack_l4proto *),
- GFP_KERNEL);
+ proto_array = kmalloc(MAX_NF_CT_PROTO *
+ sizeof(struct nf_conntrack_l4proto *),
+ GFP_KERNEL);
if (proto_array == NULL) {
ret = -ENOMEM;
goto out_unlock;
}
+
for (i = 0; i < MAX_NF_CT_PROTO; i++)
proto_array[i] = &nf_conntrack_l4proto_generic;
-
- if (nf_ct_protos[l4proto->l3proto])
- /* bad timing, but no problem */
- kfree(proto_array);
- else
- nf_ct_protos[l4proto->l3proto] = proto_array;
-
- /*
- * Just once because array is never freed until unloading
- * nf_conntrack.ko
- */
- goto retry;
+ nf_ct_protos[l4proto->l3proto] = proto_array;
+ } else if (nf_ct_protos[l4proto->l3proto][l4proto->l4proto] !=
+ &nf_conntrack_l4proto_generic) {
+ ret = -EBUSY;
+ goto out_unlock;
}
ret = nf_ct_l4proto_register_sysctl(l4proto);
if (ret < 0)
goto out_unlock;
- rcu_assign_pointer(nf_ct_protos[l4proto->l3proto][l4proto->l4proto], l4proto);
+ rcu_assign_pointer(nf_ct_protos[l4proto->l3proto][l4proto->l4proto],
+ l4proto);
out_unlock:
mutex_unlock(&nf_ct_proto_mutex);
^ permalink raw reply related [flat|nested] 25+ messages in thread* [NETFILTER 07/22]: nfnetlink: use mutex instead of semaphore
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
` (4 preceding siblings ...)
2007-03-14 8:50 ` [NETFILTER 06/22]: nf_conntrack: simplify l4 protocol array allocation Patrick McHardy
@ 2007-03-14 8:50 ` Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 08/22]: nfnetlink: use netlink_run_queue() Patrick McHardy
` (15 subsequent siblings)
21 siblings, 0 replies; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 8:50 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
[NETFILTER]: nfnetlink: use mutex instead of semaphore
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit d61dcfb467bf886f404643585b36317fc2be7254
tree 366fde24982c43ff86f8f6fb3c78bcebf55931ef
parent e4cfced6765b323aaf85882448deef3008a2e204
author Patrick McHardy <kaber@trash.net> Thu, 08 Mar 2007 18:24:47 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 14 Mar 2007 09:29:39 +0100
include/linux/netfilter/nfnetlink.h | 13 ----------
include/net/netfilter/nf_conntrack_l3proto.h | 5 +---
net/netfilter/nfnetlink.c | 35 ++++++++++++++++++--------
3 files changed, 25 insertions(+), 28 deletions(-)
diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
index 1e9c821..6179648 100644
--- a/include/linux/netfilter/nfnetlink.h
+++ b/include/linux/netfilter/nfnetlink.h
@@ -129,19 +129,6 @@ #define NFA_PUT(skb, attrtype, attrlen,
({ if (skb_tailroom(skb) < (int)NFA_SPACE(attrlen)) goto nfattr_failure; \
__nfa_fill(skb, attrtype, attrlen, data); })
-extern struct semaphore nfnl_sem;
-
-#define nfnl_shlock() down(&nfnl_sem)
-#define nfnl_shlock_nowait() down_trylock(&nfnl_sem)
-
-#define nfnl_shunlock() do { up(&nfnl_sem); \
- if(nfnl && nfnl->sk_receive_queue.qlen) \
- nfnl->sk_data_ready(nfnl, 0); \
- } while(0)
-
-extern void nfnl_lock(void);
-extern void nfnl_unlock(void);
-
extern int nfnetlink_subsys_register(struct nfnetlink_subsystem *n);
extern int nfnetlink_subsys_unregister(struct nfnetlink_subsystem *n);
diff --git a/include/net/netfilter/nf_conntrack_l3proto.h b/include/net/netfilter/nf_conntrack_l3proto.h
index eb575cb..f32f714 100644
--- a/include/net/netfilter/nf_conntrack_l3proto.h
+++ b/include/net/netfilter/nf_conntrack_l3proto.h
@@ -90,10 +90,7 @@ extern struct nf_conntrack_l3proto *nf_c
/* Protocol registration. */
extern int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto);
extern void nf_conntrack_l3proto_unregister(struct nf_conntrack_l3proto *proto);
-
-extern struct nf_conntrack_l3proto *
-nf_ct_l3proto_find_get(u_int16_t l3proto);
-
+extern struct nf_conntrack_l3proto *nf_ct_l3proto_find_get(u_int16_t l3proto);
extern void nf_ct_l3proto_put(struct nf_conntrack_l3proto *p);
/* Existing built-in protocols */
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index bf23e48..7865a47 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -28,6 +28,7 @@ #include <linux/skbuff.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <net/sock.h>
+#include <net/netlink.h>
#include <linux/init.h>
#include <linux/spinlock.h>
@@ -51,16 +52,28 @@ #endif
static struct sock *nfnl = NULL;
static struct nfnetlink_subsystem *subsys_table[NFNL_SUBSYS_COUNT];
-DECLARE_MUTEX(nfnl_sem);
+static DEFINE_MUTEX(nfnl_mutex);
-void nfnl_lock(void)
+static void nfnl_lock(void)
{
- nfnl_shlock();
+ mutex_lock(&nfnl_mutex);
}
-void nfnl_unlock(void)
+static int nfnl_trylock(void)
{
- nfnl_shunlock();
+ return !mutex_trylock(&nfnl_mutex);
+}
+
+static void __nfnl_unlock(void)
+{
+ mutex_unlock(&nfnl_mutex);
+}
+
+static void nfnl_unlock(void)
+{
+ mutex_unlock(&nfnl_mutex);
+ if (nfnl->sk_receive_queue.qlen)
+ nfnl->sk_data_ready(nfnl, 0);
}
int nfnetlink_subsys_register(struct nfnetlink_subsystem *n)
@@ -248,11 +261,11 @@ static int nfnetlink_rcv_msg(struct sk_b
ss = nfnetlink_get_subsys(type);
if (!ss) {
#ifdef CONFIG_KMOD
- /* don't call nfnl_shunlock, since it would reenter
+ /* don't call nfnl_unlock, since it would reenter
* with further packet processing */
- up(&nfnl_sem);
+ __nfnl_unlock();
request_module("nfnetlink-subsys-%d", NFNL_SUBSYS_ID(type));
- nfnl_shlock();
+ nfnl_lock();
ss = nfnetlink_get_subsys(type);
if (!ss)
#endif
@@ -322,7 +335,7 @@ static void nfnetlink_rcv(struct sock *s
do {
struct sk_buff *skb;
- if (nfnl_shlock_nowait())
+ if (nfnl_trylock())
return;
while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
@@ -337,9 +350,9 @@ static void nfnetlink_rcv(struct sock *s
kfree_skb(skb);
}
- /* don't call nfnl_shunlock, since it would reenter
+ /* don't call nfnl_unlock, since it would reenter
* with further packet processing */
- up(&nfnl_sem);
+ __nfnl_unlock();
} while(nfnl && nfnl->sk_receive_queue.qlen);
}
^ permalink raw reply related [flat|nested] 25+ messages in thread* [NETFILTER 08/22]: nfnetlink: use netlink_run_queue()
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
` (5 preceding siblings ...)
2007-03-14 8:50 ` [NETFILTER 07/22]: nfnetlink: use mutex instead of semaphore Patrick McHardy
@ 2007-03-14 8:50 ` Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 09/22]: nf_conntrack: uninline notifier registration functions Patrick McHardy
` (14 subsequent siblings)
21 siblings, 0 replies; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 8:50 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
[NETFILTER]: nfnetlink: use netlink_run_queue()
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 9a256881f5e3027a9833ad87b1fe36c0be0c20fb
tree 756d0b3c3f1905fc3f441c650551e334e670f4ff
parent d61dcfb467bf886f404643585b36317fc2be7254
author Patrick McHardy <kaber@trash.net> Thu, 08 Mar 2007 18:24:55 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 14 Mar 2007 09:30:30 +0100
net/netfilter/nfnetlink.c | 51 ++++-----------------------------------------
1 files changed, 4 insertions(+), 47 deletions(-)
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 7865a47..5be6ac4 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -301,59 +301,16 @@ err_inval:
return -1;
}
-/* Process one packet of messages. */
-static inline int nfnetlink_rcv_skb(struct sk_buff *skb)
-{
- int err;
- struct nlmsghdr *nlh;
-
- while (skb->len >= NLMSG_SPACE(0)) {
- u32 rlen;
-
- nlh = (struct nlmsghdr *)skb->data;
- if (nlh->nlmsg_len < sizeof(struct nlmsghdr)
- || skb->len < nlh->nlmsg_len)
- return 0;
- rlen = NLMSG_ALIGN(nlh->nlmsg_len);
- if (rlen > skb->len)
- rlen = skb->len;
- if (nfnetlink_rcv_msg(skb, nlh, &err)) {
- if (!err)
- return -1;
- netlink_ack(skb, nlh, err);
- } else
- if (nlh->nlmsg_flags & NLM_F_ACK)
- netlink_ack(skb, nlh, 0);
- skb_pull(skb, rlen);
- }
-
- return 0;
-}
-
static void nfnetlink_rcv(struct sock *sk, int len)
{
- do {
- struct sk_buff *skb;
+ unsigned int qlen = 0;
+ do {
if (nfnl_trylock())
return;
-
- while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
- if (nfnetlink_rcv_skb(skb)) {
- if (skb->len)
- skb_queue_head(&sk->sk_receive_queue,
- skb);
- else
- kfree_skb(skb);
- break;
- }
- kfree_skb(skb);
- }
-
- /* don't call nfnl_unlock, since it would reenter
- * with further packet processing */
+ netlink_run_queue(sk, &qlen, nfnetlink_rcv_msg);
__nfnl_unlock();
- } while(nfnl && nfnl->sk_receive_queue.qlen);
+ } while (qlen);
}
static void __exit nfnetlink_exit(void)
^ permalink raw reply related [flat|nested] 25+ messages in thread* [NETFILTER 09/22]: nf_conntrack: uninline notifier registration functions
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
` (6 preceding siblings ...)
2007-03-14 8:50 ` [NETFILTER 08/22]: nfnetlink: use netlink_run_queue() Patrick McHardy
@ 2007-03-14 8:50 ` Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 10/22]: nfnetlink: remove early debugging messages from nfnetlink Patrick McHardy
` (13 subsequent siblings)
21 siblings, 0 replies; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 8:50 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
[NETFILTER]: nf_conntrack: uninline notifier registration functions
SIgned-off-by: Patrick McHardy <kaber@trash.net>
---
commit f8184abb940940e7503c5b089e89d2d88b4eb34c
tree 5a953b2f7dc58cb1b2b4ff96b5e0094a1d33e9dd
parent 9a256881f5e3027a9833ad87b1fe36c0be0c20fb
author Patrick McHardy <kaber@trash.net> Thu, 08 Mar 2007 18:25:12 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 14 Mar 2007 09:30:39 +0100
include/net/netfilter/nf_conntrack_ecache.h | 30 +++++----------------------
net/netfilter/nf_conntrack_ecache.c | 23 +++++++++++++++++++++
2 files changed, 29 insertions(+), 24 deletions(-)
diff --git a/include/net/netfilter/nf_conntrack_ecache.h b/include/net/netfilter/nf_conntrack_ecache.h
index b62a8a9..811c907 100644
--- a/include/net/netfilter/nf_conntrack_ecache.h
+++ b/include/net/netfilter/nf_conntrack_ecache.h
@@ -20,30 +20,8 @@ DECLARE_PER_CPU(struct nf_conntrack_ecac
#define CONNTRACK_ECACHE(x) (__get_cpu_var(nf_conntrack_ecache).x)
extern struct atomic_notifier_head nf_conntrack_chain;
-extern struct atomic_notifier_head nf_conntrack_expect_chain;
-
-static inline int nf_conntrack_register_notifier(struct notifier_block *nb)
-{
- return atomic_notifier_chain_register(&nf_conntrack_chain, nb);
-}
-
-static inline int nf_conntrack_unregister_notifier(struct notifier_block *nb)
-{
- return atomic_notifier_chain_unregister(&nf_conntrack_chain, nb);
-}
-
-static inline int
-nf_conntrack_expect_register_notifier(struct notifier_block *nb)
-{
- return atomic_notifier_chain_register(&nf_conntrack_expect_chain, nb);
-}
-
-static inline int
-nf_conntrack_expect_unregister_notifier(struct notifier_block *nb)
-{
- return atomic_notifier_chain_unregister(&nf_conntrack_expect_chain,
- nb);
-}
+extern int nf_conntrack_register_notifier(struct notifier_block *nb);
+extern int nf_conntrack_unregister_notifier(struct notifier_block *nb);
extern void nf_ct_deliver_cached_events(const struct nf_conn *ct);
extern void __nf_ct_event_cache_init(struct nf_conn *ct);
@@ -71,6 +49,10 @@ static inline void nf_conntrack_event(en
atomic_notifier_call_chain(&nf_conntrack_chain, event, ct);
}
+extern struct atomic_notifier_head nf_conntrack_expect_chain;
+extern int nf_conntrack_expect_register_notifier(struct notifier_block *nb);
+extern int nf_conntrack_expect_unregister_notifier(struct notifier_block *nb);
+
static inline void
nf_conntrack_expect_event(enum ip_conntrack_expect_events event,
struct nf_conntrack_expect *exp)
diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
index 1a223e0..6bd421d 100644
--- a/net/netfilter/nf_conntrack_ecache.c
+++ b/net/netfilter/nf_conntrack_ecache.c
@@ -91,3 +91,26 @@ void nf_ct_event_cache_flush(void)
}
}
+int nf_conntrack_register_notifier(struct notifier_block *nb)
+{
+ return atomic_notifier_chain_register(&nf_conntrack_chain, nb);
+}
+EXPORT_SYMBOL_GPL(nf_conntrack_register_notifier);
+
+int nf_conntrack_unregister_notifier(struct notifier_block *nb)
+{
+ return atomic_notifier_chain_unregister(&nf_conntrack_chain, nb);
+}
+EXPORT_SYMBOL_GPL(nf_conntrack_unregister_notifier);
+
+int nf_conntrack_expect_register_notifier(struct notifier_block *nb)
+{
+ return atomic_notifier_chain_register(&nf_conntrack_expect_chain, nb);
+}
+EXPORT_SYMBOL_GPL(nf_conntrack_expect_register_notifier);
+
+int nf_conntrack_expect_unregister_notifier(struct notifier_block *nb)
+{
+ return atomic_notifier_chain_unregister(&nf_conntrack_expect_chain, nb);
+}
+EXPORT_SYMBOL_GPL(nf_conntrack_expect_unregister_notifier);
^ permalink raw reply related [flat|nested] 25+ messages in thread* [NETFILTER 10/22]: nfnetlink: remove early debugging messages from nfnetlink
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
` (7 preceding siblings ...)
2007-03-14 8:50 ` [NETFILTER 09/22]: nf_conntrack: uninline notifier registration functions Patrick McHardy
@ 2007-03-14 8:50 ` Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 11/22]: nfnetlink: remove duplicate checks in nfnetlink_check_attributes Patrick McHardy
` (12 subsequent siblings)
21 siblings, 0 replies; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 8:50 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
[NETFILTER]: nfnetlink: remove early debugging messages from nfnetlink
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 750623a576cf1a6cd62d138be4da5b95a8419c35
tree 1ae7982c1e123a23f56e890c0d8110cfd23bf13a
parent f8184abb940940e7503c5b089e89d2d88b4eb34c
author Pablo Neira Ayuso <pablo@netfilter.org> Thu, 08 Mar 2007 18:25:20 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 14 Mar 2007 09:30:46 +0100
net/netfilter/nfnetlink.c | 42 ++++++------------------------------------
1 files changed, 6 insertions(+), 36 deletions(-)
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 5be6ac4..c8b4f0d 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -3,7 +3,7 @@
*
* (C) 2001 by Jay Schulist <jschlst@samba.org>,
* (C) 2002-2005 by Harald Welte <laforge@gnumonks.org>
- * (C) 2005 by Pablo Neira Ayuso <pablo@eurodev.net>
+ * (C) 2005,2007 by Pablo Neira Ayuso <pablo@netfilter.org>
*
* Initial netfilter messages via netlink development funded and
* generally made possible by Network Robots, Inc. (www.networkrobots.com)
@@ -42,14 +42,6 @@ MODULE_ALIAS_NET_PF_PROTO(PF_NETLINK, NE
static char __initdata nfversion[] = "0.30";
-#if 0
-#define DEBUGP(format, args...) \
- printk(KERN_DEBUG "%s(%d):%s(): " format, __FILE__, \
- __LINE__, __FUNCTION__, ## args)
-#else
-#define DEBUGP(format, args...)
-#endif
-
static struct sock *nfnl = NULL;
static struct nfnetlink_subsystem *subsys_table[NFNL_SUBSYS_COUNT];
static DEFINE_MUTEX(nfnl_mutex);
@@ -78,8 +70,6 @@ static void nfnl_unlock(void)
int nfnetlink_subsys_register(struct nfnetlink_subsystem *n)
{
- DEBUGP("registering subsystem ID %u\n", n->subsys_id);
-
nfnl_lock();
if (subsys_table[n->subsys_id]) {
nfnl_unlock();
@@ -93,8 +83,6 @@ int nfnetlink_subsys_register(struct nfn
int nfnetlink_subsys_unregister(struct nfnetlink_subsystem *n)
{
- DEBUGP("unregistering subsystem ID %u\n", n->subsys_id);
-
nfnl_lock();
subsys_table[n->subsys_id] = NULL;
nfnl_unlock();
@@ -118,10 +106,8 @@ nfnetlink_find_client(u_int16_t type, st
{
u_int8_t cb_id = NFNL_MSG_TYPE(type);
- if (cb_id >= ss->cb_count) {
- DEBUGP("msgtype %u >= %u, returning\n", type, ss->cb_count);
+ if (cb_id >= ss->cb_count)
return NULL;
- }
return &ss->cb[cb_id];
}
@@ -167,11 +153,8 @@ nfnetlink_check_attributes(struct nfnetl
u_int16_t attr_count;
u_int8_t cb_id = NFNL_MSG_TYPE(nlh->nlmsg_type);
- if (unlikely(cb_id >= subsys->cb_count)) {
- DEBUGP("msgtype %u >= %u, returning\n",
- cb_id, subsys->cb_count);
+ if (unlikely(cb_id >= subsys->cb_count))
return -EINVAL;
- }
min_len = NLMSG_SPACE(sizeof(struct nfgenmsg));
if (unlikely(nlh->nlmsg_len < min_len))
@@ -235,27 +218,18 @@ static int nfnetlink_rcv_msg(struct sk_b
struct nfnetlink_subsystem *ss;
int type, err = 0;
- DEBUGP("entered; subsys=%u, msgtype=%u\n",
- NFNL_SUBSYS_ID(nlh->nlmsg_type),
- NFNL_MSG_TYPE(nlh->nlmsg_type));
-
if (security_netlink_recv(skb, CAP_NET_ADMIN)) {
- DEBUGP("missing CAP_NET_ADMIN\n");
*errp = -EPERM;
return -1;
}
/* Only requests are handled by kernel now. */
- if (!(nlh->nlmsg_flags & NLM_F_REQUEST)) {
- DEBUGP("received non-request message\n");
+ if (!(nlh->nlmsg_flags & NLM_F_REQUEST))
return 0;
- }
/* All the messages must at least contain nfgenmsg */
- if (nlh->nlmsg_len < NLMSG_SPACE(sizeof(struct nfgenmsg))) {
- DEBUGP("received message was too short\n");
+ if (nlh->nlmsg_len < NLMSG_SPACE(sizeof(struct nfgenmsg)))
return 0;
- }
type = nlh->nlmsg_type;
ss = nfnetlink_get_subsys(type);
@@ -273,10 +247,8 @@ #endif
}
nc = nfnetlink_find_client(type, ss);
- if (!nc) {
- DEBUGP("unable to find client for type %d\n", type);
+ if (!nc)
goto err_inval;
- }
{
u_int16_t attr_count =
@@ -289,14 +261,12 @@ #endif
if (err < 0)
goto err_inval;
- DEBUGP("calling handler\n");
err = nc->call(nfnl, skb, nlh, cda, errp);
*errp = err;
return err;
}
err_inval:
- DEBUGP("returning -EINVAL\n");
*errp = -EINVAL;
return -1;
}
^ permalink raw reply related [flat|nested] 25+ messages in thread* [NETFILTER 11/22]: nfnetlink: remove duplicate checks in nfnetlink_check_attributes
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
` (8 preceding siblings ...)
2007-03-14 8:50 ` [NETFILTER 10/22]: nfnetlink: remove early debugging messages from nfnetlink Patrick McHardy
@ 2007-03-14 8:50 ` Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 12/22]: nfnetlink: remove unrequired check in nfnetlink_get_subsys Patrick McHardy
` (11 subsequent siblings)
21 siblings, 0 replies; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 8:50 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
[NETFILTER]: nfnetlink: remove duplicate checks in nfnetlink_check_attributes
Remove nfnetlink_check_attributes duplicates message size and callback
id checks. nfnetlink_find_client and nfnetlink_rcv_msg already do
such checks.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 6399e6156d65ce163cc77aeb6d53eacf9d9a1fb2
tree a5a5206f0e21e755c7d076be09ba1459412b21a6
parent 750623a576cf1a6cd62d138be4da5b95a8419c35
author Pablo Neira Ayuso <pablo@netfilter.org> Thu, 08 Mar 2007 18:25:28 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 14 Mar 2007 09:30:57 +0100
net/netfilter/nfnetlink.c | 9 +--------
1 files changed, 1 insertions(+), 8 deletions(-)
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index c8b4f0d..9d33807 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -149,17 +149,10 @@ static int
nfnetlink_check_attributes(struct nfnetlink_subsystem *subsys,
struct nlmsghdr *nlh, struct nfattr *cda[])
{
- int min_len;
+ int min_len = NLMSG_SPACE(sizeof(struct nfgenmsg));
u_int16_t attr_count;
u_int8_t cb_id = NFNL_MSG_TYPE(nlh->nlmsg_type);
- if (unlikely(cb_id >= subsys->cb_count))
- return -EINVAL;
-
- min_len = NLMSG_SPACE(sizeof(struct nfgenmsg));
- if (unlikely(nlh->nlmsg_len < min_len))
- return -EINVAL;
-
attr_count = subsys->cb[cb_id].attr_count;
memset(cda, 0, sizeof(struct nfattr *) * attr_count);
^ permalink raw reply related [flat|nested] 25+ messages in thread* [NETFILTER 12/22]: nfnetlink: remove unrequired check in nfnetlink_get_subsys
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
` (9 preceding siblings ...)
2007-03-14 8:50 ` [NETFILTER 11/22]: nfnetlink: remove duplicate checks in nfnetlink_check_attributes Patrick McHardy
@ 2007-03-14 8:50 ` Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 13/22]: nfnetlink: remove unused includes in nfnetlink.c Patrick McHardy
` (10 subsequent siblings)
21 siblings, 0 replies; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 8:50 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
[NETFILTER]: nfnetlink: remove unrequired check in nfnetlink_get_subsys
subsys_table is initialized to NULL, therefore just returns NULL in case
that it is not set.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit bc5959a6bd9a56d1ea0e31344bde2b4f119d8b4c
tree 7c56a7256ee573e38f4a480dd7b8f6412e7e29bc
parent 6399e6156d65ce163cc77aeb6d53eacf9d9a1fb2
author Pablo Neira Ayuso <pablo@netfilter.org> Thu, 08 Mar 2007 18:25:37 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 14 Mar 2007 09:31:09 +0100
net/netfilter/nfnetlink.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 9d33807..0b0a966 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -94,8 +94,7 @@ static inline struct nfnetlink_subsystem
{
u_int8_t subsys_id = NFNL_SUBSYS_ID(type);
- if (subsys_id >= NFNL_SUBSYS_COUNT
- || subsys_table[subsys_id] == NULL)
+ if (subsys_id >= NFNL_SUBSYS_COUNT)
return NULL;
return subsys_table[subsys_id];
^ permalink raw reply related [flat|nested] 25+ messages in thread* [NETFILTER 13/22]: nfnetlink: remove unused includes in nfnetlink.c
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
` (10 preceding siblings ...)
2007-03-14 8:50 ` [NETFILTER 12/22]: nfnetlink: remove unrequired check in nfnetlink_get_subsys Patrick McHardy
@ 2007-03-14 8:50 ` Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 14/22]: nfnetlink: move EXPORT_SYMBOL declarations next to the exported symbol Patrick McHardy
` (9 subsequent siblings)
21 siblings, 0 replies; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 8:50 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
[NETFILTER]: nfnetlink: remove unused includes in nfnetlink.c
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit b826bdd775fb219458b886e3fc41491019af0d67
tree e355d5cc9d828eb93b11211e047b56e849c01229
parent bc5959a6bd9a56d1ea0e31344bde2b4f119d8b4c
author Pablo Neira Ayuso <pablo@netfilter.org> Thu, 08 Mar 2007 18:25:49 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 14 Mar 2007 09:31:19 +0100
net/netfilter/nfnetlink.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 0b0a966..6dd6654 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -30,9 +30,7 @@ #include <asm/system.h>
#include <net/sock.h>
#include <net/netlink.h>
#include <linux/init.h>
-#include <linux/spinlock.h>
-#include <linux/netfilter.h>
#include <linux/netlink.h>
#include <linux/netfilter/nfnetlink.h>
^ permalink raw reply related [flat|nested] 25+ messages in thread* [NETFILTER 14/22]: nfnetlink: move EXPORT_SYMBOL declarations next to the exported symbol
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
` (11 preceding siblings ...)
2007-03-14 8:50 ` [NETFILTER 13/22]: nfnetlink: remove unused includes in nfnetlink.c Patrick McHardy
@ 2007-03-14 8:50 ` Patrick McHardy
2007-03-14 8:50 ` [JHASH 15/22]: Use const in jhash2 Patrick McHardy
` (8 subsequent siblings)
21 siblings, 0 replies; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 8:50 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
[NETFILTER]: nfnetlink: move EXPORT_SYMBOL declarations next to the exported symbol
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit f7ec69deeb727422f3e7b2aec0e89a411c165d81
tree ea9661307f8d0e661338d3df4765692bf3e3d608
parent b826bdd775fb219458b886e3fc41491019af0d67
author Pablo Neira Ayuso <pablo@netfilter.org> Thu, 08 Mar 2007 18:25:59 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 14 Mar 2007 09:31:29 +0100
net/netfilter/nfnetlink.c | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 6dd6654..9ba6aa4 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -78,6 +78,7 @@ int nfnetlink_subsys_register(struct nfn
return 0;
}
+EXPORT_SYMBOL_GPL(nfnetlink_subsys_register);
int nfnetlink_subsys_unregister(struct nfnetlink_subsystem *n)
{
@@ -87,6 +88,7 @@ int nfnetlink_subsys_unregister(struct n
return 0;
}
+EXPORT_SYMBOL_GPL(nfnetlink_subsys_unregister);
static inline struct nfnetlink_subsystem *nfnetlink_get_subsys(u_int16_t type)
{
@@ -121,6 +123,7 @@ void __nfa_fill(struct sk_buff *skb, int
memcpy(NFA_DATA(nfa), data, attrlen);
memset(NFA_DATA(nfa) + attrlen, 0, NFA_ALIGN(size) - size);
}
+EXPORT_SYMBOL_GPL(__nfa_fill);
void nfattr_parse(struct nfattr *tb[], int maxattr, struct nfattr *nfa, int len)
{
@@ -133,6 +136,7 @@ void nfattr_parse(struct nfattr *tb[], i
nfa = NFA_NEXT(nfa, len);
}
}
+EXPORT_SYMBOL_GPL(nfattr_parse);
/**
* nfnetlink_check_attributes - check and parse nfnetlink attributes
@@ -194,11 +198,13 @@ int nfnetlink_send(struct sk_buff *skb,
return err;
}
+EXPORT_SYMBOL_GPL(nfnetlink_send);
int nfnetlink_unicast(struct sk_buff *skb, u_int32_t pid, int flags)
{
return netlink_unicast(nfnl, skb, pid, flags);
}
+EXPORT_SYMBOL_GPL(nfnetlink_unicast);
/* Process one complete nfnetlink message. */
static int nfnetlink_rcv_msg(struct sk_buff *skb,
@@ -296,10 +302,3 @@ static int __init nfnetlink_init(void)
module_init(nfnetlink_init);
module_exit(nfnetlink_exit);
-
-EXPORT_SYMBOL_GPL(nfnetlink_subsys_register);
-EXPORT_SYMBOL_GPL(nfnetlink_subsys_unregister);
-EXPORT_SYMBOL_GPL(nfnetlink_send);
-EXPORT_SYMBOL_GPL(nfnetlink_unicast);
-EXPORT_SYMBOL_GPL(nfattr_parse);
-EXPORT_SYMBOL_GPL(__nfa_fill);
^ permalink raw reply related [flat|nested] 25+ messages in thread* [JHASH 15/22]: Use const in jhash2
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
` (12 preceding siblings ...)
2007-03-14 8:50 ` [NETFILTER 14/22]: nfnetlink: move EXPORT_SYMBOL declarations next to the exported symbol Patrick McHardy
@ 2007-03-14 8:50 ` Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 16/22]: nf_conntrack: use jhash2 in __hash_conntrack Patrick McHardy
` (7 subsequent siblings)
21 siblings, 0 replies; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 8:50 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
[JHASH]: Use const in jhash2
Use const to avoid forcing users to cast const data.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 2fdc283757d6f33fda2d4d86a51abce3d155bb22
tree b032ab64f7219db843f68b291ff28993e9dc441b
parent f7ec69deeb727422f3e7b2aec0e89a411c165d81
author Patrick McHardy <kaber@trash.net> Thu, 08 Mar 2007 18:26:09 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 14 Mar 2007 09:31:39 +0100
include/linux/jhash.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/include/linux/jhash.h b/include/linux/jhash.h
index 82c7ae4..2a2f99f 100644
--- a/include/linux/jhash.h
+++ b/include/linux/jhash.h
@@ -84,7 +84,7 @@ static inline u32 jhash(const void *key,
/* A special optimized version that handles 1 or more of u32s.
* The length parameter here is the number of u32s in the key.
*/
-static inline u32 jhash2(u32 *k, u32 length, u32 initval)
+static inline u32 jhash2(const u32 *k, u32 length, u32 initval)
{
u32 a, b, c, len;
^ permalink raw reply related [flat|nested] 25+ messages in thread* [NETFILTER 16/22]: nf_conntrack: use jhash2 in __hash_conntrack
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
` (13 preceding siblings ...)
2007-03-14 8:50 ` [JHASH 15/22]: Use const in jhash2 Patrick McHardy
@ 2007-03-14 8:50 ` Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 17/22]: conntrack: add __nf_copy() to copy members in skb Patrick McHardy
` (6 subsequent siblings)
21 siblings, 0 replies; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 8:50 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
[NETFILTER]: nf_conntrack: use jhash2 in __hash_conntrack
Now it uses jhash, but using jhash2 would be around 3-4 times faster
(on P4).
Signed-off-by: Sami Farin <safari-netfilter@safari.iki.fi>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit a36f33350b8220397ac33ee98c26e808289a302b
tree d505586b3eb93b7cfb9990a892ca9538325fb57d
parent 2fdc283757d6f33fda2d4d86a51abce3d155bb22
author Sami Farin <safari-netfilter@safari.iki.fi> Thu, 08 Mar 2007 18:26:17 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 14 Mar 2007 09:31:52 +0100
net/netfilter/nf_conntrack_core.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 9858bcb..2b0cc7a 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -128,10 +128,11 @@ static u_int32_t __hash_conntrack(const
unsigned int size, unsigned int rnd)
{
unsigned int a, b;
- a = jhash((void *)tuple->src.u3.all, sizeof(tuple->src.u3.all),
- ((tuple->src.l3num) << 16) | tuple->dst.protonum);
- b = jhash((void *)tuple->dst.u3.all, sizeof(tuple->dst.u3.all),
- (tuple->src.u.all << 16) | tuple->dst.u.all);
+
+ a = jhash2(tuple->src.u3.all, ARRAY_SIZE(tuple->src.u3.all),
+ (tuple->src.l3num << 16) | tuple->dst.protonum);
+ b = jhash2(tuple->dst.u3.all, ARRAY_SIZE(tuple->dst.u3.all),
+ (tuple->src.u.all << 16) | tuple->dst.u.all);
return jhash_2words(a, b, rnd) % size;
}
^ permalink raw reply related [flat|nested] 25+ messages in thread* [NETFILTER 17/22]: conntrack: add __nf_copy() to copy members in skb
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
` (14 preceding siblings ...)
2007-03-14 8:50 ` [NETFILTER 16/22]: nf_conntrack: use jhash2 in __hash_conntrack Patrick McHardy
@ 2007-03-14 8:50 ` Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 18/22]: conntrack: add nf_copy() to safely " Patrick McHardy
` (5 subsequent siblings)
21 siblings, 0 replies; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 8:50 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
[NETFILTER]: nf_conntrack: add __nf_copy() to copy members in skb
This unifies the codes to copy netfilter related datas. Note that
__nf_copy() assumes destination skb doesn't have any netfilter
related members.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit c3f281b640e4bec1e09a5ec338d3e605c23a3e9e
tree 9084a7a022b9222cc4d7230f9b885a8693f08296
parent a36f33350b8220397ac33ee98c26e808289a302b
author Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> Wed, 14 Mar 2007 09:32:00 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 14 Mar 2007 09:32:00 +0100
include/linux/skbuff.h | 17 +++++++++++++++++
net/core/skbuff.c | 28 ++--------------------------
2 files changed, 19 insertions(+), 26 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 6148cb3..3d4d49d 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1481,8 +1481,25 @@ #ifdef CONFIG_BRIDGE_NETFILTER
#endif
}
+/* Note: This doesn't put any conntrack and bridge info in dst. */
+static inline void __nf_copy(struct sk_buff *dst, const struct sk_buff *src)
+{
+ dst->nfct = src->nfct;
+ nf_conntrack_get(src->nfct);
+ dst->nfctinfo = src->nfctinfo;
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ dst->nfct_reasm = src->nfct_reasm;
+ nf_conntrack_get_reasm(src->nfct_reasm);
+#endif
+#ifdef CONFIG_BRIDGE_NETFILTER
+ dst->nf_bridge = src->nf_bridge;
+ nf_bridge_get(src->nf_bridge);
+#endif
+}
+
#else /* CONFIG_NETFILTER */
static inline void nf_reset(struct sk_buff *skb) {}
+static inline void __nf_copy(struct sk_buff *dst, const struct sk_buff *src) {}
#endif /* CONFIG_NETFILTER */
#ifdef CONFIG_NETWORK_SECMARK
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 05949c9..100af5b 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -476,19 +476,7 @@ #endif
C(protocol);
n->destructor = NULL;
C(mark);
-#ifdef CONFIG_NETFILTER
- C(nfct);
- nf_conntrack_get(skb->nfct);
- C(nfctinfo);
-#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
- C(nfct_reasm);
- nf_conntrack_get_reasm(skb->nfct_reasm);
-#endif
-#ifdef CONFIG_BRIDGE_NETFILTER
- C(nf_bridge);
- nf_bridge_get(skb->nf_bridge);
-#endif
-#endif /*CONFIG_NETFILTER*/
+ __nf_copy(n, skb);
#ifdef CONFIG_NET_SCHED
C(tc_index);
#ifdef CONFIG_NET_CLS_ACT
@@ -537,22 +525,10 @@ #endif
new->tstamp = old->tstamp;
new->destructor = NULL;
new->mark = old->mark;
-#ifdef CONFIG_NETFILTER
- new->nfct = old->nfct;
- nf_conntrack_get(old->nfct);
- new->nfctinfo = old->nfctinfo;
-#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
- new->nfct_reasm = old->nfct_reasm;
- nf_conntrack_get_reasm(old->nfct_reasm);
-#endif
+ __nf_copy(new, old);
#if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE)
new->ipvs_property = old->ipvs_property;
#endif
-#ifdef CONFIG_BRIDGE_NETFILTER
- new->nf_bridge = old->nf_bridge;
- nf_bridge_get(old->nf_bridge);
-#endif
-#endif
#ifdef CONFIG_NET_SCHED
#ifdef CONFIG_NET_CLS_ACT
new->tc_verd = old->tc_verd;
^ permalink raw reply related [flat|nested] 25+ messages in thread* [NETFILTER 18/22]: conntrack: add nf_copy() to safely copy members in skb
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
` (15 preceding siblings ...)
2007-03-14 8:50 ` [NETFILTER 17/22]: conntrack: add __nf_copy() to copy members in skb Patrick McHardy
@ 2007-03-14 8:50 ` Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 19/22]: tcp_conntrack: accept RST|PSH as valid Patrick McHardy
` (4 subsequent siblings)
21 siblings, 0 replies; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 8:50 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
[NETFILTER]: nf_conntrack: add nf_copy() to safely copy members in skb
This unifies the codes to copy netfilter related datas. Before copying,
nf_copy() puts original members in destination skb.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 625c028a6c0ccfd684f4334699f9ec7672fd179c
tree 2a28f1dbd73d0dab5458df7203534f9ad7bf942e
parent c3f281b640e4bec1e09a5ec338d3e605c23a3e9e
author Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> Wed, 14 Mar 2007 09:32:30 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 14 Mar 2007 09:32:30 +0100
include/linux/skbuff.h | 13 +++++++++++++
net/ipv4/ip_output.c | 13 +------------
net/ipv6/ip6_output.c | 18 +-----------------
3 files changed, 15 insertions(+), 29 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 3d4d49d..2451264 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1497,9 +1497,22 @@ #ifdef CONFIG_BRIDGE_NETFILTER
#endif
}
+static inline void nf_copy(struct sk_buff *dst, const struct sk_buff *src)
+{
+ nf_conntrack_put(dst->nfct);
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ nf_conntrack_put_reasm(dst->nfct_reasm);
+#endif
+#ifdef CONFIG_BRIDGE_NETFILTER
+ nf_bridge_put(dst->nf_bridge);
+#endif
+ __nf_copy(dst, src);
+}
+
#else /* CONFIG_NETFILTER */
static inline void nf_reset(struct sk_buff *skb) {}
static inline void __nf_copy(struct sk_buff *dst, const struct sk_buff *src) {}
+static inline void nf_copy(struct sk_buff *dst, const struct sk_buff *src) {}
#endif /* CONFIG_NETFILTER */
#ifdef CONFIG_NETWORK_SECMARK
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 1abc488..f05ea0e 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -384,21 +384,10 @@ static void ip_copy_metadata(struct sk_b
#ifdef CONFIG_NET_SCHED
to->tc_index = from->tc_index;
#endif
-#ifdef CONFIG_NETFILTER
- /* Connection association is same as pre-frag packet */
- nf_conntrack_put(to->nfct);
- to->nfct = from->nfct;
- nf_conntrack_get(to->nfct);
- to->nfctinfo = from->nfctinfo;
+ nf_copy(to, from);
#if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE)
to->ipvs_property = from->ipvs_property;
#endif
-#ifdef CONFIG_BRIDGE_NETFILTER
- nf_bridge_put(to->nf_bridge);
- to->nf_bridge = from->nf_bridge;
- nf_bridge_get(to->nf_bridge);
-#endif
-#endif
skb_copy_secmark(to, from);
}
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 1900c62..26b834e 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -504,23 +504,7 @@ static void ip6_copy_metadata(struct sk_
#ifdef CONFIG_NET_SCHED
to->tc_index = from->tc_index;
#endif
-#ifdef CONFIG_NETFILTER
- /* Connection association is same as pre-frag packet */
- nf_conntrack_put(to->nfct);
- to->nfct = from->nfct;
- nf_conntrack_get(to->nfct);
- to->nfctinfo = from->nfctinfo;
-#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
- nf_conntrack_put_reasm(to->nfct_reasm);
- to->nfct_reasm = from->nfct_reasm;
- nf_conntrack_get_reasm(to->nfct_reasm);
-#endif
-#ifdef CONFIG_BRIDGE_NETFILTER
- nf_bridge_put(to->nf_bridge);
- to->nf_bridge = from->nf_bridge;
- nf_bridge_get(to->nf_bridge);
-#endif
-#endif
+ nf_copy(to, from);
skb_copy_secmark(to, from);
}
^ permalink raw reply related [flat|nested] 25+ messages in thread* [NETFILTER 19/22]: tcp_conntrack: accept RST|PSH as valid
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
` (16 preceding siblings ...)
2007-03-14 8:50 ` [NETFILTER 18/22]: conntrack: add nf_copy() to safely " Patrick McHardy
@ 2007-03-14 8:50 ` Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 20/22]: tcp_conntrack: factorize out the PUSH flag Patrick McHardy
` (3 subsequent siblings)
21 siblings, 0 replies; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 8:50 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
[NETFILTER]: TCP conntrack: accept RST|PSH as valid
This combination has been encountered on an IBM AS/400 in response
to packets sent to a closed session. There is no particular reason
to mark it invalid.
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 922ad96654a159769dc890c4ef1896e10985f5bb
tree fe6736631229cdb0d961de37b738268e8dfca032
parent 625c028a6c0ccfd684f4334699f9ec7672fd179c
author Willy Tarreau <w@1wt.eu> Wed, 14 Mar 2007 09:32:43 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 14 Mar 2007 09:32:43 +0100
net/netfilter/nf_conntrack_proto_tcp.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 9e49631..926e302 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -774,6 +774,7 @@ static u8 tcp_valid_flags[(TH_FIN|TH_SYN
[TH_SYN|TH_ACK] = 1,
[TH_SYN|TH_ACK|TH_PUSH] = 1,
[TH_RST] = 1,
+ [TH_RST|TH_PUSH] = 1,
[TH_RST|TH_ACK] = 1,
[TH_RST|TH_ACK|TH_PUSH] = 1,
[TH_FIN|TH_ACK] = 1,
^ permalink raw reply related [flat|nested] 25+ messages in thread* [NETFILTER 20/22]: tcp_conntrack: factorize out the PUSH flag
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
` (17 preceding siblings ...)
2007-03-14 8:50 ` [NETFILTER 19/22]: tcp_conntrack: accept RST|PSH as valid Patrick McHardy
@ 2007-03-14 8:50 ` Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 21/22]: ctnetlink: add support for internal tcp connection tracking flags handling Patrick McHardy
` (2 subsequent siblings)
21 siblings, 0 replies; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 8:50 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
[NETFILTER]: TCP conntrack: factorize out the PUSH flag
The PUSH flag is accepted with every other valid combination.
Let's get it out of the tcp_valid_flags table and reduce the
number of combinations we have to handle. This does not
significantly reduce the table size however (8 bytes).
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 3607514396585a2be00d6d0aa3081a96532e5db7
tree 7aeb2263123d7bba9d8265c2dc55c1e5d3b3ad50
parent 922ad96654a159769dc890c4ef1896e10985f5bb
author Willy Tarreau <w@1wt.eu> Wed, 14 Mar 2007 09:34:29 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 14 Mar 2007 09:34:29 +0100
net/netfilter/nf_conntrack_proto_tcp.c | 17 ++++-------------
1 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 926e302..a136362 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -764,27 +764,18 @@ #define TH_URG 0x20
#define TH_ECE 0x40
#define TH_CWR 0x80
-/* table of valid flag combinations - ECE and CWR are always valid */
-static u8 tcp_valid_flags[(TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG) + 1] =
+/* table of valid flag combinations - PUSH, ECE and CWR are always valid */
+static u8 tcp_valid_flags[(TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG) + 1] =
{
[TH_SYN] = 1,
- [TH_SYN|TH_PUSH] = 1,
[TH_SYN|TH_URG] = 1,
- [TH_SYN|TH_PUSH|TH_URG] = 1,
[TH_SYN|TH_ACK] = 1,
- [TH_SYN|TH_ACK|TH_PUSH] = 1,
[TH_RST] = 1,
- [TH_RST|TH_PUSH] = 1,
[TH_RST|TH_ACK] = 1,
- [TH_RST|TH_ACK|TH_PUSH] = 1,
[TH_FIN|TH_ACK] = 1,
+ [TH_FIN|TH_ACK|TH_URG] = 1,
[TH_ACK] = 1,
- [TH_ACK|TH_PUSH] = 1,
[TH_ACK|TH_URG] = 1,
- [TH_ACK|TH_URG|TH_PUSH] = 1,
- [TH_FIN|TH_ACK|TH_PUSH] = 1,
- [TH_FIN|TH_ACK|TH_URG] = 1,
- [TH_FIN|TH_ACK|TH_URG|TH_PUSH] = 1,
};
/* Protect conntrack agaist broken packets. Code taken from ipt_unclean.c. */
@@ -831,7 +822,7 @@ static int tcp_error(struct sk_buff *skb
}
/* Check TCP flags. */
- tcpflags = (((u_int8_t *)th)[13] & ~(TH_ECE|TH_CWR));
+ tcpflags = (((u_int8_t *)th)[13] & ~(TH_ECE|TH_CWR|TH_PUSH));
if (!tcp_valid_flags[tcpflags]) {
if (LOG_INVALID(IPPROTO_TCP))
nf_log_packet(pf, 0, skb, NULL, NULL, NULL,
^ permalink raw reply related [flat|nested] 25+ messages in thread* [NETFILTER 21/22]: ctnetlink: add support for internal tcp connection tracking flags handling
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
` (18 preceding siblings ...)
2007-03-14 8:50 ` [NETFILTER 20/22]: tcp_conntrack: factorize out the PUSH flag Patrick McHardy
@ 2007-03-14 8:50 ` Patrick McHardy
2007-03-14 8:50 ` [NETFILTER 22/22]: nfnetlink: parse attributes with nfattr_parse in nfnetlink_check_attribute Patrick McHardy
2007-03-14 23:05 ` [NETFILTER 00/22]: Netfilter update for 2.6.22 David Miller
21 siblings, 0 replies; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 8:50 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
[NETFILTER]: ctnetlink: add support for internal tcp connection tracking flags handling
This patch let userspace programs set the IP_CT_TCP_BE_LIBERAL flag to
force the pickup of established connections.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 95cddede9ae6fddfb993ab5d989f6d96cdf4e8e8
tree 760bf19f0f49fb668b24552e9243b5568b0a615e
parent 3607514396585a2be00d6d0aa3081a96532e5db7
author Pablo Neira Ayuso <pablo@netfilter.org> Wed, 14 Mar 2007 09:34:50 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 14 Mar 2007 09:34:50 +0100
include/linux/netfilter/nf_conntrack_tcp.h | 5 +++
include/linux/netfilter/nfnetlink_conntrack.h | 4 ++
net/netfilter/nf_conntrack_proto_tcp.c | 45 ++++++++++++++++++++++++-
3 files changed, 53 insertions(+), 1 deletions(-)
diff --git a/include/linux/netfilter/nf_conntrack_tcp.h b/include/linux/netfilter/nf_conntrack_tcp.h
index 007af4c..22ce299 100644
--- a/include/linux/netfilter/nf_conntrack_tcp.h
+++ b/include/linux/netfilter/nf_conntrack_tcp.h
@@ -30,6 +30,11 @@ #define IP_CT_TCP_FLAG_CLOSE_INIT 0x04
/* Be liberal in window checking */
#define IP_CT_TCP_FLAG_BE_LIBERAL 0x08
+struct nf_ct_tcp_flags {
+ u_int8_t flags;
+ u_int8_t mask;
+};
+
#ifdef __KERNEL__
struct ip_ct_tcp_state {
diff --git a/include/linux/netfilter/nfnetlink_conntrack.h b/include/linux/netfilter/nfnetlink_conntrack.h
index b5883cc..d7c3503 100644
--- a/include/linux/netfilter/nfnetlink_conntrack.h
+++ b/include/linux/netfilter/nfnetlink_conntrack.h
@@ -83,6 +83,10 @@ #define CTA_PROTOINFO_MAX (__CTA_PROTOIN
enum ctattr_protoinfo_tcp {
CTA_PROTOINFO_TCP_UNSPEC,
CTA_PROTOINFO_TCP_STATE,
+ CTA_PROTOINFO_TCP_WSCALE_ORIGINAL,
+ CTA_PROTOINFO_TCP_WSCALE_REPLY,
+ CTA_PROTOINFO_TCP_FLAGS_ORIGINAL,
+ CTA_PROTOINFO_TCP_FLAGS_REPLY,
__CTA_PROTOINFO_TCP_MAX
};
#define CTA_PROTOINFO_TCP_MAX (__CTA_PROTOINFO_TCP_MAX - 1)
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index a136362..8439768 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -1101,11 +1101,26 @@ static int tcp_to_nfattr(struct sk_buff
const struct nf_conn *ct)
{
struct nfattr *nest_parms;
+ struct nf_ct_tcp_flags tmp = {};
read_lock_bh(&tcp_lock);
nest_parms = NFA_NEST(skb, CTA_PROTOINFO_TCP);
NFA_PUT(skb, CTA_PROTOINFO_TCP_STATE, sizeof(u_int8_t),
&ct->proto.tcp.state);
+
+ NFA_PUT(skb, CTA_PROTOINFO_TCP_WSCALE_ORIGINAL, sizeof(u_int8_t),
+ &ct->proto.tcp.seen[0].td_scale);
+
+ NFA_PUT(skb, CTA_PROTOINFO_TCP_WSCALE_REPLY, sizeof(u_int8_t),
+ &ct->proto.tcp.seen[1].td_scale);
+
+ tmp.flags = ct->proto.tcp.seen[0].flags;
+ NFA_PUT(skb, CTA_PROTOINFO_TCP_FLAGS_ORIGINAL,
+ sizeof(struct nf_ct_tcp_flags), &tmp);
+
+ tmp.flags = ct->proto.tcp.seen[1].flags;
+ NFA_PUT(skb, CTA_PROTOINFO_TCP_FLAGS_REPLY,
+ sizeof(struct nf_ct_tcp_flags), &tmp);
read_unlock_bh(&tcp_lock);
NFA_NEST_END(skb, nest_parms);
@@ -1118,7 +1133,11 @@ nfattr_failure:
}
static const size_t cta_min_tcp[CTA_PROTOINFO_TCP_MAX] = {
- [CTA_PROTOINFO_TCP_STATE-1] = sizeof(u_int8_t),
+ [CTA_PROTOINFO_TCP_STATE-1] = sizeof(u_int8_t),
+ [CTA_PROTOINFO_TCP_WSCALE_ORIGINAL-1] = sizeof(u_int8_t),
+ [CTA_PROTOINFO_TCP_WSCALE_REPLY-1] = sizeof(u_int8_t),
+ [CTA_PROTOINFO_TCP_FLAGS_ORIGINAL-1] = sizeof(struct nf_ct_tcp_flags),
+ [CTA_PROTOINFO_TCP_FLAGS_REPLY-1] = sizeof(struct nf_ct_tcp_flags)
};
static int nfattr_to_tcp(struct nfattr *cda[], struct nf_conn *ct)
@@ -1142,6 +1161,30 @@ static int nfattr_to_tcp(struct nfattr *
write_lock_bh(&tcp_lock);
ct->proto.tcp.state =
*(u_int8_t *)NFA_DATA(tb[CTA_PROTOINFO_TCP_STATE-1]);
+
+ if (tb[CTA_PROTOINFO_TCP_FLAGS_ORIGINAL-1]) {
+ struct nf_ct_tcp_flags *attr =
+ NFA_DATA(tb[CTA_PROTOINFO_TCP_FLAGS_ORIGINAL-1]);
+ ct->proto.tcp.seen[0].flags &= ~attr->mask;
+ ct->proto.tcp.seen[0].flags |= attr->flags & attr->mask;
+ }
+
+ if (tb[CTA_PROTOINFO_TCP_FLAGS_REPLY-1]) {
+ struct nf_ct_tcp_flags *attr =
+ NFA_DATA(tb[CTA_PROTOINFO_TCP_FLAGS_REPLY-1]);
+ ct->proto.tcp.seen[1].flags &= ~attr->mask;
+ ct->proto.tcp.seen[1].flags |= attr->flags & attr->mask;
+ }
+
+ if (tb[CTA_PROTOINFO_TCP_WSCALE_ORIGINAL-1] &&
+ tb[CTA_PROTOINFO_TCP_WSCALE_REPLY-1] &&
+ ct->proto.tcp.seen[0].flags & IP_CT_TCP_FLAG_WINDOW_SCALE &&
+ ct->proto.tcp.seen[1].flags & IP_CT_TCP_FLAG_WINDOW_SCALE) {
+ ct->proto.tcp.seen[0].td_scale = *(u_int8_t *)
+ NFA_DATA(tb[CTA_PROTOINFO_TCP_WSCALE_ORIGINAL-1]);
+ ct->proto.tcp.seen[1].td_scale = *(u_int8_t *)
+ NFA_DATA(tb[CTA_PROTOINFO_TCP_WSCALE_REPLY-1]);
+ }
write_unlock_bh(&tcp_lock);
return 0;
^ permalink raw reply related [flat|nested] 25+ messages in thread* [NETFILTER 22/22]: nfnetlink: parse attributes with nfattr_parse in nfnetlink_check_attribute
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
` (19 preceding siblings ...)
2007-03-14 8:50 ` [NETFILTER 21/22]: ctnetlink: add support for internal tcp connection tracking flags handling Patrick McHardy
@ 2007-03-14 8:50 ` Patrick McHardy
2007-03-14 23:05 ` [NETFILTER 00/22]: Netfilter update for 2.6.22 David Miller
21 siblings, 0 replies; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 8:50 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
[NETFILTER]: nfnetlink: parse attributes with nfattr_parse in nfnetlink_check_attribute
Use nfattr_parse to parse attributes, this patch also modifies the default
behaviour since unknown attributes will be ignored instead of returning
EINVAL. This ensure backward compatibility: new libraries with new
attributes and old kernels can work.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 53d0099da1eea04b818399e4548daeb7399c7bc2
tree 20ef7dfae6763dabbc5b0a84a169e1c69db2f0c6
parent 95cddede9ae6fddfb993ab5d989f6d96cdf4e8e8
author Pablo Neira Ayuso <pablo@netfilter.org> Wed, 14 Mar 2007 09:35:23 +0100
committer Patrick McHardy <kaber@trash.net> Wed, 14 Mar 2007 09:35:23 +0100
net/netfilter/nfnetlink.c | 16 ++--------------
1 files changed, 2 insertions(+), 14 deletions(-)
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 9ba6aa4..dec36ab 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -151,26 +151,14 @@ nfnetlink_check_attributes(struct nfnetl
struct nlmsghdr *nlh, struct nfattr *cda[])
{
int min_len = NLMSG_SPACE(sizeof(struct nfgenmsg));
- u_int16_t attr_count;
u_int8_t cb_id = NFNL_MSG_TYPE(nlh->nlmsg_type);
-
- attr_count = subsys->cb[cb_id].attr_count;
- memset(cda, 0, sizeof(struct nfattr *) * attr_count);
+ u_int16_t attr_count = subsys->cb[cb_id].attr_count;
/* check attribute lengths. */
if (likely(nlh->nlmsg_len > min_len)) {
struct nfattr *attr = NFM_NFA(NLMSG_DATA(nlh));
int attrlen = nlh->nlmsg_len - NLMSG_ALIGN(min_len);
-
- while (NFA_OK(attr, attrlen)) {
- unsigned flavor = NFA_TYPE(attr);
- if (flavor) {
- if (flavor > attr_count)
- return -EINVAL;
- cda[flavor - 1] = attr;
- }
- attr = NFA_NEXT(attr, attrlen);
- }
+ nfattr_parse(cda, attr_count, attr, attrlen);
}
/* implicit: if nlmsg_len == min_len, we return 0, and an empty
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [NETFILTER 00/22]: Netfilter update for 2.6.22
2007-03-14 8:50 [NETFILTER 00/22]: Netfilter update for 2.6.22 Patrick McHardy
` (20 preceding siblings ...)
2007-03-14 8:50 ` [NETFILTER 22/22]: nfnetlink: parse attributes with nfattr_parse in nfnetlink_check_attribute Patrick McHardy
@ 2007-03-14 23:05 ` David Miller
2007-03-14 23:14 ` Patrick McHardy
21 siblings, 1 reply; 25+ messages in thread
From: David Miller @ 2007-03-14 23:05 UTC (permalink / raw)
To: kaber; +Cc: netfilter-devel
From: Patrick McHardy <kaber@trash.net>
Date: Wed, 14 Mar 2007 09:50:02 +0100 (MET)
> following is a first batch of netfilter patches for 2.6.22, containing the
> scheduled removal of ip_conntrack/ip_nat, some further nf_conntrack locking
> cleanup, nfnetlink cleanup and a few minor enhancements in various places.
> The patches should apply cleanly to the current net-2.6.22 tree.
>
> Please apply, thanks.
Thanks Patrick.
I have two major merges to do today, one large set from Arnaldo with
more skb data access refinements, and this netfilter set.
What I'm going to do is merge Arnaldo's first, then your's.
The logic is that it's easier for me to fix conflicts in your
patch set (since it largely just removes code) than the other
way around.
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [NETFILTER 00/22]: Netfilter update for 2.6.22
2007-03-14 23:05 ` [NETFILTER 00/22]: Netfilter update for 2.6.22 David Miller
@ 2007-03-14 23:14 ` Patrick McHardy
2007-03-14 23:52 ` David Miller
0 siblings, 1 reply; 25+ messages in thread
From: Patrick McHardy @ 2007-03-14 23:14 UTC (permalink / raw)
To: David Miller; +Cc: netfilter-devel
David Miller wrote:
> I have two major merges to do today, one large set from Arnaldo with
> more skb data access refinements, and this netfilter set.
>
> What I'm going to do is merge Arnaldo's first, then your's.
>
> The logic is that it's easier for me to fix conflicts in your
> patch set (since it largely just removes code) than the other
> way around.
Thanks. I had a quick look at Arnaldo's patches and think there
shouldn't be any conflicts, but if there are, just let me know
and I'll go over it afterwards.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [NETFILTER 00/22]: Netfilter update for 2.6.22
2007-03-14 23:14 ` Patrick McHardy
@ 2007-03-14 23:52 ` David Miller
0 siblings, 0 replies; 25+ messages in thread
From: David Miller @ 2007-03-14 23:52 UTC (permalink / raw)
To: kaber; +Cc: netfilter-devel
From: Patrick McHardy <kaber@trash.net>
Date: Thu, 15 Mar 2007 00:14:25 +0100
> David Miller wrote:
> > I have two major merges to do today, one large set from Arnaldo with
> > more skb data access refinements, and this netfilter set.
> >
> > What I'm going to do is merge Arnaldo's first, then your's.
> >
> > The logic is that it's easier for me to fix conflicts in your
> > patch set (since it largely just removes code) than the other
> > way around.
>
> Thanks. I had a quick look at Arnaldo's patches and think there
> shouldn't be any conflicts, but if there are, just let me know
> and I'll go over it afterwards.
Happily, it all went in cleanly. I push it all back out to
kernel.org, let me know if I screw up anything :-)
Thanks!
^ permalink raw reply [flat|nested] 25+ messages in thread