From f91c72c70b26eb0b0b3b729e4e4f2a7ae96248dd Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 11 Jul 2017 04:25:32 +0200 Subject: ratelimiter: use KMEM_CACHE macro Suggested-by: Samuel Holland --- src/ratelimiter.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/ratelimiter.c') diff --git a/src/ratelimiter.c b/src/ratelimiter.c index 9c8a0c9..9ad451e 100644 --- a/src/ratelimiter.c +++ b/src/ratelimiter.c @@ -19,7 +19,7 @@ static struct hlist_head *table_v4; static struct hlist_head *table_v6; #endif -struct entry { +struct ratelimiter_entry { u64 last_time_ns, tokens; __be64 ip; void *net; @@ -37,11 +37,11 @@ enum { static void entry_free(struct rcu_head *rcu) { - kmem_cache_free(entry_cache, container_of(rcu, struct entry, rcu)); + kmem_cache_free(entry_cache, container_of(rcu, struct ratelimiter_entry, rcu)); atomic_dec(&total_entries); } -static void entry_uninit(struct entry *entry) +static void entry_uninit(struct ratelimiter_entry *entry) { hlist_del_rcu(&entry->hash); call_rcu(&entry->rcu, entry_free); @@ -51,7 +51,7 @@ static void entry_uninit(struct entry *entry) static void gc_entries(struct work_struct *work) { unsigned int i; - struct entry *entry; + struct ratelimiter_entry *entry; struct hlist_node *temp; const u64 now = ktime_get_ns(); @@ -77,7 +77,7 @@ static void gc_entries(struct work_struct *work) bool ratelimiter_allow(struct sk_buff *skb, struct net *net) { - struct entry *entry; + struct ratelimiter_entry *entry; struct hlist_head *bucket; struct { __be64 ip; u32 net; } data = { .net = (unsigned long)net & 0xffffffff }; @@ -142,7 +142,7 @@ int ratelimiter_init(void) if (atomic64_inc_return(&refcnt) != 1) return 0; - entry_cache = kmem_cache_create("wireguard_ratelimiter", sizeof(struct entry), 0, 0, NULL); + entry_cache = KMEM_CACHE(ratelimiter_entry, 0); if (!entry_cache) goto err; -- cgit v1.2.3-59-g8ed1b