[netfilter-cvslog] r3738 -
trunk/patch-o-matic-ng/hashlimit/linux-2.6/net/ipv4/netfilter
laforge at netfilter.org
laforge at netfilter.org
Tue Feb 22 12:26:23 CET 2005
Author: laforge at netfilter.org
Date: 2005-02-22 12:26:22 +0100 (Tue, 22 Feb 2005)
New Revision: 3738
Modified:
trunk/patch-o-matic-ng/hashlimit/linux-2.6/net/ipv4/netfilter/ipt_hashlimit.c
Log:
sync with fixes and updates in 2.6.11-rc4 mainline
- use correct list macros
- fix port name & -> | change
- use GFP_ATOMIC
- don't hardware align slab cache
Modified: trunk/patch-o-matic-ng/hashlimit/linux-2.6/net/ipv4/netfilter/ipt_hashlimit.c
===================================================================
--- trunk/patch-o-matic-ng/hashlimit/linux-2.6/net/ipv4/netfilter/ipt_hashlimit.c 2005-02-22 10:50:19 UTC (rev 3737)
+++ trunk/patch-o-matic-ng/hashlimit/linux-2.6/net/ipv4/netfilter/ipt_hashlimit.c 2005-02-22 11:26:22 UTC (rev 3738)
@@ -97,7 +97,7 @@
struct list_head hash[0]; /* hashtable itself */
};
-DECLARE_RWLOCK(hashlimit_lock); /* protects htables list */
+static DECLARE_RWLOCK(hashlimit_lock); /* protects htables list */
static LIST_HEAD(hashlimit_htables);
static kmem_cache_t *hashlimit_cachep;
@@ -112,7 +112,7 @@
static inline u_int32_t
hash_dst(const struct ipt_hashlimit_htable *ht, const struct dsthash_dst *dst)
{
- return (jhash_3words(dst->dst_ip, (dst->dst_port<<16 | dst->src_port),
+ return (jhash_3words(dst->dst_ip, (dst->dst_port<<16 & dst->src_port),
dst->src_ip, ht->rnd) % ht->cfg.size);
}
@@ -121,7 +121,6 @@
{
struct dsthash_ent *ent;
u_int32_t hash = hash_dst(ht, dst);
- MUST_BE_LOCKED(&ht->lock);
ent = LIST_FIND(&ht->hash[hash], dst_cmp, struct dsthash_ent *, dst);
return ent;
}
@@ -170,8 +169,6 @@
static inline void
__dsthash_free(struct ipt_hashlimit_htable *ht, struct dsthash_ent *ent)
{
- MUST_BE_LOCKED(&ht->lock);
-
list_del(&ent->list);
kmem_cache_free(hashlimit_cachep, ent);
atomic_dec(&ht->count);
@@ -217,7 +214,7 @@
atomic_set(&hinfo->count, 0);
atomic_set(&hinfo->use, 1);
hinfo->rnd = 0;
- hinfo->lock = SPIN_LOCK_UNLOCKED;
+ spin_lock_init(&hinfo->lock);
hinfo->pde = create_proc_entry(minfo->name, 0, hashlimit_procdir);
if (!hinfo->pde) {
vfree(hinfo);
@@ -258,7 +255,7 @@
IP_NF_ASSERT(ht->cfg.size && ht->cfg.max);
/* lock hash table and iterate over it */
- LOCK_BH(&ht->lock);
+ spin_lock_bh(&ht->lock);
for (i = 0; i < ht->cfg.size; i++) {
struct dsthash_ent *dh, *n;
list_for_each_entry_safe(dh, n, &ht->hash[i], list) {
@@ -266,7 +263,7 @@
__dsthash_free(ht, dh);
}
}
- UNLOCK_BH(&ht->lock);
+ spin_unlock_bh(&ht->lock);
}
/* hash table garbage collector, run by timer */
@@ -457,7 +454,7 @@
dst.dst_port = ports[1];
}
- LOCK_BH(&hinfo->lock);
+ spin_lock_bh(&hinfo->lock);
dh = __dsthash_find(hinfo, &dst);
if (!dh) {
dh = __dsthash_alloc_init(hinfo, &dst);
@@ -466,7 +463,7 @@
/* enomem... don't match == DROP */
if (net_ratelimit())
printk(KERN_ERR "%s: ENOMEM\n", __FUNCTION__);
- UNLOCK_BH(&hinfo->lock);
+ spin_unlock_bh(&hinfo->lock);
return 0;
}
@@ -479,7 +476,7 @@
hinfo->cfg.burst);
dh->rateinfo.cost = user2credits(hinfo->cfg.avg);
- UNLOCK_BH(&hinfo->lock);
+ spin_unlock_bh(&hinfo->lock);
return 1;
}
@@ -490,11 +487,11 @@
if (dh->rateinfo.credit >= dh->rateinfo.cost) {
/* We're underlimit. */
dh->rateinfo.credit -= dh->rateinfo.cost;
- UNLOCK_BH(&hinfo->lock);
+ spin_unlock_bh(&hinfo->lock);
return 1;
}
- UNLOCK_BH(&hinfo->lock);
+ spin_unlock_bh(&hinfo->lock);
/* default case: we're overlimit, thus don't match */
return 0;
@@ -569,11 +566,11 @@
struct ipt_hashlimit_htable *htable = pde->data;
unsigned int *bucket;
- LOCK_BH(&htable->lock);
+ spin_lock_bh(&htable->lock);
if (*pos >= htable->cfg.size)
return NULL;
- bucket = kmalloc(sizeof(unsigned int), GFP_KERNEL);
+ bucket = kmalloc(sizeof(unsigned int), GFP_ATOMIC);
if (!bucket)
return ERR_PTR(-ENOMEM);
@@ -603,7 +600,7 @@
kfree(bucket);
- UNLOCK_BH(&htable->lock);
+ spin_unlock_bh(&htable->lock);
}
static inline int dl_seq_real_show(struct dsthash_ent *ent, struct seq_file *s)
@@ -671,11 +668,9 @@
goto cleanup_nothing;
}
- /* FIXME: do we really want HWCACHE_ALIGN since our objects are
- * quite small ? */
hashlimit_cachep = kmem_cache_create("ipt_hashlimit",
sizeof(struct dsthash_ent), 0,
- SLAB_HWCACHE_ALIGN, NULL, NULL);
+ 0, NULL, NULL);
if (!hashlimit_cachep) {
printk(KERN_ERR "Unable to create ipt_hashlimit slab cache\n");
ret = -ENOMEM;
More information about the netfilter-cvslog
mailing list