diff options
author | Patrick McHardy <kaber@trash.net> | 2008-04-14 05:15:51 -0400 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2008-04-14 05:15:51 -0400 |
commit | 55871d04793d9c069ee277b1e98794b88d92ed80 (patch) | |
tree | 7e06b1ae438b45e9d5b5da8146ba197222d875f4 | |
parent | 8c87238b726e543f8af4bdb4296020a328df4744 (diff) |
[NETFILTER]: nf_conntrack_extend: warn on confirmed conntracks
New extensions may only be added to unconfirmed conntracks to avoid races
when reallocating the storage.
Also change NF_CT_ASSERT to use WARN_ON to get backtraces.
Signed-off-by: Patrick McHardy <kaber@trash.net>
-rw-r--r-- | include/net/netfilter/nf_conntrack.h | 9 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_extend.c | 3 |
2 files changed, 4 insertions, 8 deletions
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h index bb9fc852e973..4a0496aa32d5 100644 --- a/include/net/netfilter/nf_conntrack.h +++ b/include/net/netfilter/nf_conntrack.h | |||
@@ -65,14 +65,7 @@ union nf_conntrack_help { | |||
65 | #include <linux/timer.h> | 65 | #include <linux/timer.h> |
66 | 66 | ||
67 | #ifdef CONFIG_NETFILTER_DEBUG | 67 | #ifdef CONFIG_NETFILTER_DEBUG |
68 | #define NF_CT_ASSERT(x) \ | 68 | #define NF_CT_ASSERT(x) WARN_ON(!(x)) |
69 | do { \ | ||
70 | if (!(x)) \ | ||
71 | /* Wooah! I'm tripping my conntrack in a frenzy of \ | ||
72 | netplay... */ \ | ||
73 | printk("NF_CT_ASSERT: %s:%i(%s)\n", \ | ||
74 | __FILE__, __LINE__, __FUNCTION__); \ | ||
75 | } while(0) | ||
76 | #else | 69 | #else |
77 | #define NF_CT_ASSERT(x) | 70 | #define NF_CT_ASSERT(x) |
78 | #endif | 71 | #endif |
diff --git a/net/netfilter/nf_conntrack_extend.c b/net/netfilter/nf_conntrack_extend.c index 2bd9963b5b3e..bcc19fa4ed1e 100644 --- a/net/netfilter/nf_conntrack_extend.c +++ b/net/netfilter/nf_conntrack_extend.c | |||
@@ -71,6 +71,9 @@ void *__nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp) | |||
71 | int i, newlen, newoff; | 71 | int i, newlen, newoff; |
72 | struct nf_ct_ext_type *t; | 72 | struct nf_ct_ext_type *t; |
73 | 73 | ||
74 | /* Conntrack must not be confirmed to avoid races on reallocation. */ | ||
75 | NF_CT_ASSERT(!nf_ct_is_confirmed(ct)); | ||
76 | |||
74 | if (!ct->ext) | 77 | if (!ct->ext) |
75 | return nf_ct_ext_create(&ct->ext, id, gfp); | 78 | return nf_ct_ext_create(&ct->ext, id, gfp); |
76 | 79 | ||