diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2008-07-08 05:35:55 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-07-08 05:35:55 -0400 |
commit | b891c5a831b13f74989dcbd7b39d04537b2a05d9 (patch) | |
tree | b2bc084458948473e31be39edfbc494325f95176 | |
parent | b11c16beb92112885edccc79e17d39c5d218f441 (diff) |
netfilter: nf_conntrack: add allocation flag to nf_conntrack_alloc
ctnetlink does not need to allocate the conntrack entries with GFP_ATOMIC
as its code is executed in user context.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/netfilter/nf_conntrack.h | 3 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_core.c | 7 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_netlink.c | 2 |
3 files changed, 7 insertions, 5 deletions
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h index d77dec768dc2..d5d76ec7abb0 100644 --- a/include/net/netfilter/nf_conntrack.h +++ b/include/net/netfilter/nf_conntrack.h | |||
@@ -258,7 +258,8 @@ nf_ct_iterate_cleanup(int (*iter)(struct nf_conn *i, void *data), void *data); | |||
258 | extern void nf_conntrack_free(struct nf_conn *ct); | 258 | extern void nf_conntrack_free(struct nf_conn *ct); |
259 | extern struct nf_conn * | 259 | extern struct nf_conn * |
260 | nf_conntrack_alloc(const struct nf_conntrack_tuple *orig, | 260 | nf_conntrack_alloc(const struct nf_conntrack_tuple *orig, |
261 | const struct nf_conntrack_tuple *repl); | 261 | const struct nf_conntrack_tuple *repl, |
262 | gfp_t gfp); | ||
262 | 263 | ||
263 | /* It's confirmed if it is, or has been in the hash table. */ | 264 | /* It's confirmed if it is, or has been in the hash table. */ |
264 | static inline int nf_ct_is_confirmed(struct nf_conn *ct) | 265 | static inline int nf_ct_is_confirmed(struct nf_conn *ct) |
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index f27c99246a4c..212a0888408d 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c | |||
@@ -464,7 +464,8 @@ static noinline int early_drop(unsigned int hash) | |||
464 | } | 464 | } |
465 | 465 | ||
466 | struct nf_conn *nf_conntrack_alloc(const struct nf_conntrack_tuple *orig, | 466 | struct nf_conn *nf_conntrack_alloc(const struct nf_conntrack_tuple *orig, |
467 | const struct nf_conntrack_tuple *repl) | 467 | const struct nf_conntrack_tuple *repl, |
468 | gfp_t gfp) | ||
468 | { | 469 | { |
469 | struct nf_conn *ct = NULL; | 470 | struct nf_conn *ct = NULL; |
470 | 471 | ||
@@ -489,7 +490,7 @@ struct nf_conn *nf_conntrack_alloc(const struct nf_conntrack_tuple *orig, | |||
489 | } | 490 | } |
490 | } | 491 | } |
491 | 492 | ||
492 | ct = kmem_cache_zalloc(nf_conntrack_cachep, GFP_ATOMIC); | 493 | ct = kmem_cache_zalloc(nf_conntrack_cachep, gfp); |
493 | if (ct == NULL) { | 494 | if (ct == NULL) { |
494 | pr_debug("nf_conntrack_alloc: Can't alloc conntrack.\n"); | 495 | pr_debug("nf_conntrack_alloc: Can't alloc conntrack.\n"); |
495 | atomic_dec(&nf_conntrack_count); | 496 | atomic_dec(&nf_conntrack_count); |
@@ -542,7 +543,7 @@ init_conntrack(const struct nf_conntrack_tuple *tuple, | |||
542 | return NULL; | 543 | return NULL; |
543 | } | 544 | } |
544 | 545 | ||
545 | ct = nf_conntrack_alloc(tuple, &repl_tuple); | 546 | ct = nf_conntrack_alloc(tuple, &repl_tuple, GFP_ATOMIC); |
546 | if (ct == NULL || IS_ERR(ct)) { | 547 | if (ct == NULL || IS_ERR(ct)) { |
547 | pr_debug("Can't allocate conntrack.\n"); | 548 | pr_debug("Can't allocate conntrack.\n"); |
548 | return (struct nf_conntrack_tuple_hash *)ct; | 549 | return (struct nf_conntrack_tuple_hash *)ct; |
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 63c4e1f299b8..dd233393f695 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c | |||
@@ -1128,7 +1128,7 @@ ctnetlink_create_conntrack(struct nlattr *cda[], | |||
1128 | struct nf_conn_help *help; | 1128 | struct nf_conn_help *help; |
1129 | struct nf_conntrack_helper *helper; | 1129 | struct nf_conntrack_helper *helper; |
1130 | 1130 | ||
1131 | ct = nf_conntrack_alloc(otuple, rtuple); | 1131 | ct = nf_conntrack_alloc(otuple, rtuple, GFP_KERNEL); |
1132 | if (ct == NULL || IS_ERR(ct)) | 1132 | if (ct == NULL || IS_ERR(ct)) |
1133 | return -ENOMEM; | 1133 | return -ENOMEM; |
1134 | 1134 | ||