geoip: use appropriate and normal types

For the header file, we need __u32 and so on because they are exported
to userspace and rather constitute a kernel header.

Use normal types instead of uintXX_t in the main code.
This commit is contained in:
Jan Engelhardt
2008-03-18 04:02:07 +01:00
parent 52a0ed7f15
commit f4c4208e75
2 changed files with 19 additions and 19 deletions

View File

@@ -33,8 +33,8 @@ struct geoip_country_kernel {
struct list_head list; struct list_head list;
struct geoip_subnet *subnets; struct geoip_subnet *subnets;
atomic_t ref; atomic_t ref;
u_int32_t count; unsigned int count;
u_int16_t cc; unsigned short cc;
}; };
static LIST_HEAD(geoip_head); static LIST_HEAD(geoip_head);
@@ -98,10 +98,9 @@ static void geoip_try_remove_node(struct geoip_country_kernel *p)
synchronize_rcu(); synchronize_rcu();
vfree(p->subnets); vfree(p->subnets);
kfree(p); kfree(p);
return;
} }
static struct geoip_country_kernel *find_node(u_int16_t cc) static struct geoip_country_kernel *find_node(unsigned short cc)
{ {
struct geoip_country_kernel *p; struct geoip_country_kernel *p;
spin_lock(&geoip_lock); spin_lock(&geoip_lock);
@@ -143,7 +142,8 @@ static bool xt_geoip_mt(const struct sk_buff *skb, const struct net_device *in,
const struct xt_geoip_match_info *info = matchinfo; const struct xt_geoip_match_info *info = matchinfo;
const struct geoip_country_kernel *node; const struct geoip_country_kernel *node;
const struct iphdr *iph = ip_hdr(skb); const struct iphdr *iph = ip_hdr(skb);
uint32_t ip, i; unsigned int i;
uint32_t ip;
if (info->flags & XT_GEOIP_SRC) if (info->flags & XT_GEOIP_SRC)
ip = ntohl(iph->saddr); ip = ntohl(iph->saddr);
@@ -161,12 +161,12 @@ static bool xt_geoip_mt(const struct sk_buff *skb, const struct net_device *in,
if (geoip_bsearch(node->subnets, ip, 0, node->count)) { if (geoip_bsearch(node->subnets, ip, 0, node->count)) {
rcu_read_unlock(); rcu_read_unlock();
return (info->flags & XT_GEOIP_INV) ? 0 : 1; return !(info->flags & XT_GEOIP_INV);
} }
} }
rcu_read_unlock(); rcu_read_unlock();
return (info->flags & XT_GEOIP_INV) ? 1 : 0; return info->flags & XT_GEOIP_INV;
} }
static bool xt_geoip_mt_checkentry(const char *table, const void *entry, static bool xt_geoip_mt_checkentry(const char *table, const void *entry,
@@ -174,7 +174,7 @@ static bool xt_geoip_mt_checkentry(const char *table, const void *entry,
{ {
struct xt_geoip_match_info *info = matchinfo; struct xt_geoip_match_info *info = matchinfo;
struct geoip_country_kernel *node; struct geoip_country_kernel *node;
u_int8_t i; unsigned int i;
for (i = 0; i < info->count; i++) { for (i = 0; i < info->count; i++) {
node = find_node(info->cc[i]); node = find_node(info->cc[i]);
@@ -183,7 +183,7 @@ static bool xt_geoip_mt_checkentry(const char *table, const void *entry,
printk(KERN_ERR printk(KERN_ERR
"xt_geoip: unable to load '%c%c' into memory\n", "xt_geoip: unable to load '%c%c' into memory\n",
COUNTRY(info->cc[i])); COUNTRY(info->cc[i]));
return 0; return false;
} }
/* Overwrite the now-useless pointer info->mem[i] with /* Overwrite the now-useless pointer info->mem[i] with
@@ -194,14 +194,14 @@ static bool xt_geoip_mt_checkentry(const char *table, const void *entry,
info->mem[i].kernel = node; info->mem[i].kernel = node;
} }
return 1; return true;
} }
static void xt_geoip_mt_destroy(const struct xt_match *match, void *matchinfo) static void xt_geoip_mt_destroy(const struct xt_match *match, void *matchinfo)
{ {
struct xt_geoip_match_info *info = matchinfo; struct xt_geoip_match_info *info = matchinfo;
struct geoip_country_kernel *node; struct geoip_country_kernel *node;
u_int8_t i; unsigned int i;
/* This entry has been removed from the table so /* This entry has been removed from the table so
* decrease the refcount of all countries it is * decrease the refcount of all countries it is
@@ -220,7 +220,6 @@ static void xt_geoip_mt_destroy(const struct xt_match *match, void *matchinfo)
printk(KERN_ERR printk(KERN_ERR
"xt_geoip: What happened peejix ? What happened acidfu ?\n" "xt_geoip: What happened peejix ? What happened acidfu ?\n"
"xt_geoip: please report this bug to the maintainers\n"); "xt_geoip: please report this bug to the maintainers\n");
return;
} }
static struct xt_match xt_geoip_match __read_mostly = { static struct xt_match xt_geoip_match __read_mostly = {

View File

@@ -19,15 +19,16 @@
#define XT_GEOIP_MAX 15 /* Maximum of countries */ #define XT_GEOIP_MAX 15 /* Maximum of countries */
/* Yup, an address range will be passed in with host-order */
struct geoip_subnet { struct geoip_subnet {
u_int32_t begin; __u32 begin;
u_int32_t end; __u32 end;
}; };
struct geoip_country_user { struct geoip_country_user {
aligned_u64 subnets; aligned_u64 subnets;
u_int32_t count; __u32 count;
u_int16_t cc; __u16 cc;
}; };
struct geoip_country_kernel; struct geoip_country_kernel;
@@ -38,9 +39,9 @@ union geoip_country_group {
}; };
struct xt_geoip_match_info { struct xt_geoip_match_info {
u_int8_t flags; __u8 flags;
u_int8_t count; __u8 count;
u_int16_t cc[XT_GEOIP_MAX]; __u16 cc[XT_GEOIP_MAX];
/* Used internally by the kernel */ /* Used internally by the kernel */
union geoip_country_group mem[XT_GEOIP_MAX]; union geoip_country_group mem[XT_GEOIP_MAX];