Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 717ac5ce authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

ipv6: sr: static percpu allocation for hmac_ring



Current allocations are not NUMA aware, and lack proper
cleanup in case of error.

It is perfectly fine to use static per cpu allocations for 256 bytes
per cpu.

Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: David Lebrun <david.lebrun@uclouvain.be>
Acked-by: default avatarDavid Lebrun <david.lebrun@uclouvain.be>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8fb472c0
Loading
Loading
Loading
Loading
+3 −40
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@
#include <net/seg6_hmac.h>
#include <linux/random.h>

static char * __percpu *hmac_ring;
static DEFINE_PER_CPU(char [SEG6_HMAC_RING_SIZE], hmac_ring);

static int seg6_hmac_cmpfn(struct rhashtable_compare_arg *arg, const void *obj)
{
@@ -192,7 +192,7 @@ int seg6_hmac_compute(struct seg6_hmac_info *hinfo, struct ipv6_sr_hdr *hdr,
	 */

	local_bh_disable();
	ring = *this_cpu_ptr(hmac_ring);
	ring = this_cpu_ptr(hmac_ring);
	off = ring;

	/* source address */
@@ -353,27 +353,6 @@ int seg6_push_hmac(struct net *net, struct in6_addr *saddr,
}
EXPORT_SYMBOL(seg6_push_hmac);

static int seg6_hmac_init_ring(void)
{
	int i;

	hmac_ring = alloc_percpu(char *);

	if (!hmac_ring)
		return -ENOMEM;

	for_each_possible_cpu(i) {
		char *ring = kzalloc(SEG6_HMAC_RING_SIZE, GFP_KERNEL);

		if (!ring)
			return -ENOMEM;

		*per_cpu_ptr(hmac_ring, i) = ring;
	}

	return 0;
}

static int seg6_hmac_init_algo(void)
{
	struct seg6_hmac_algo *algo;
@@ -422,16 +401,7 @@ static int seg6_hmac_init_algo(void)

int __init seg6_hmac_init(void)
{
	int ret;

	ret = seg6_hmac_init_ring();
	if (ret < 0)
		goto out;

	ret = seg6_hmac_init_algo();

out:
	return ret;
	return seg6_hmac_init_algo();
}
EXPORT_SYMBOL(seg6_hmac_init);

@@ -450,13 +420,6 @@ void seg6_hmac_exit(void)
	struct seg6_hmac_algo *algo = NULL;
	int i, alg_count, cpu;

	for_each_possible_cpu(i) {
		char *ring = *per_cpu_ptr(hmac_ring, i);

		kfree(ring);
	}
	free_percpu(hmac_ring);

	alg_count = sizeof(hmac_algos) / sizeof(struct seg6_hmac_algo);
	for (i = 0; i < alg_count; i++) {
		algo = &hmac_algos[i];