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

Commit 021e9299 authored by David S. Miller's avatar David S. Miller
Browse files

inetpeer: Add v6 peers tree, abstract root properly.



Add the ipv6 peer tree instance, and adapt remaining
direct references to 'v4_peers' as needed.

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 02663045
Loading
Loading
Loading
Loading
+18 −9
Original line number Original line Diff line number Diff line
@@ -79,15 +79,24 @@ static const struct inet_peer peer_fake_node = {
	.avl_height	= 0
	.avl_height	= 0
};
};


static struct inet_peer_base {
struct inet_peer_base {
	struct inet_peer __rcu *root;
	struct inet_peer __rcu *root;
	spinlock_t	lock;
	spinlock_t	lock;
	int		total;
	int		total;
} v4_peers = {
};

static struct inet_peer_base v4_peers = {
	.root		= peer_avl_empty_rcu,
	.root		= peer_avl_empty_rcu,
	.lock		= __SPIN_LOCK_UNLOCKED(v4_peers.lock),
	.lock		= __SPIN_LOCK_UNLOCKED(v4_peers.lock),
	.total		= 0,
	.total		= 0,
};
};

static struct inet_peer_base v6_peers = {
	.root		= peer_avl_empty_rcu,
	.lock		= __SPIN_LOCK_UNLOCKED(v6_peers.lock),
	.total		= 0,
};

#define PEER_MAXDEPTH 40 /* sufficient for about 2^27 nodes */
#define PEER_MAXDEPTH 40 /* sufficient for about 2^27 nodes */


/* Exported for sysctl_net_ipv4.  */
/* Exported for sysctl_net_ipv4.  */
@@ -415,9 +424,14 @@ static void unlink_from_pool(struct inet_peer *p, struct inet_peer_base *base)
		inet_putpeer(p);
		inet_putpeer(p);
}
}


static struct inet_peer_base *family_to_base(int family)
{
	return (family == AF_INET ? &v4_peers : &v6_peers);
}

static struct inet_peer_base *peer_to_base(struct inet_peer *p)
static struct inet_peer_base *peer_to_base(struct inet_peer *p)
{
{
	return &v4_peers;
	return family_to_base(p->daddr.family);
}
}


/* May be called with local BH enabled. */
/* May be called with local BH enabled. */
@@ -457,11 +471,6 @@ static int cleanup_once(unsigned long ttl)
	return 0;
	return 0;
}
}


static struct inet_peer_base *family_to_base(int family)
{
	return &v4_peers;
}

/* Called with or without local BH being disabled. */
/* Called with or without local BH being disabled. */
struct inet_peer *inet_getpeer(inet_peer_address_t *daddr, int create)
struct inet_peer *inet_getpeer(inet_peer_address_t *daddr, int create)
{
{
@@ -521,7 +530,7 @@ struct inet_peer *inet_getpeer(inet_peer_address_t *daddr, int create)


static int compute_total(void)
static int compute_total(void)
{
{
	return v4_peers.total;
	return v4_peers.total + v6_peers.total;
}
}


/* Called with local BH disabled. */
/* Called with local BH disabled. */