mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-08 21:54:57 +02:00
geoip: use real atomic_t and remove casts from uint32_t
This commit is contained in:
@@ -31,8 +31,8 @@ MODULE_ALIAS("ipt_geoip");
|
|||||||
struct geoip_country_kernel {
|
struct geoip_country_kernel {
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
struct geoip_subnet *subnets;
|
struct geoip_subnet *subnets;
|
||||||
|
atomic_t ref;
|
||||||
u_int32_t count;
|
u_int32_t count;
|
||||||
u_int32_t ref;
|
|
||||||
u_int16_t cc;
|
u_int16_t cc;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ geoip_add_node(const struct geoip_country_user __user *umem_ptr)
|
|||||||
spin_lock_bh(&geoip_lock);
|
spin_lock_bh(&geoip_lock);
|
||||||
|
|
||||||
p->subnets = s;
|
p->subnets = s;
|
||||||
p->ref = 1;
|
atomic_set(&p->ref, 1);
|
||||||
INIT_LIST_HEAD(&p->list);
|
INIT_LIST_HEAD(&p->list);
|
||||||
list_add_tail(&p->list, &geoip_head);
|
list_add_tail(&p->list, &geoip_head);
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ geoip_add_node(const struct geoip_country_user __user *umem_ptr)
|
|||||||
static void geoip_try_remove_node(struct geoip_country_kernel *p)
|
static void geoip_try_remove_node(struct geoip_country_kernel *p)
|
||||||
{
|
{
|
||||||
spin_lock_bh(&geoip_lock);
|
spin_lock_bh(&geoip_lock);
|
||||||
if (!atomic_dec_and_test((atomic_t *)&p->ref)) {
|
if (!atomic_dec_and_test(&p->ref)) {
|
||||||
spin_unlock_bh(&geoip_lock);
|
spin_unlock_bh(&geoip_lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ static struct geoip_country_kernel *find_node(u_int16_t cc)
|
|||||||
|
|
||||||
list_for_each_entry(p, &geoip_head, list)
|
list_for_each_entry(p, &geoip_head, list)
|
||||||
if (p->cc == cc) {
|
if (p->cc == cc) {
|
||||||
atomic_inc((atomic_t *)&p->ref);
|
atomic_inc(&p->ref);
|
||||||
spin_unlock_bh(&geoip_lock);
|
spin_unlock_bh(&geoip_lock);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user