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

Commit bf18ab32 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by J. Bruce Fields
Browse files

sunrpc: Pass the ip_map_parse's cd to lower calls



The target is to have many ip_map_cache-s in the system. This particular
patch handles its usage by the ip_map_parse callback.

Signed-off-by: default avatarPavel Emelyanov <xemul@openvz.org>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 74ec1e12
Loading
Loading
Loading
Loading
+21 −10
Original line number Diff line number Diff line
@@ -178,8 +178,8 @@ static int ip_map_upcall(struct cache_detail *cd, struct cache_head *h)
	return sunrpc_cache_pipe_upcall(cd, h, ip_map_request);
}

static struct ip_map *ip_map_lookup(char *class, struct in6_addr *addr);
static int ip_map_update(struct ip_map *ipm, struct unix_domain *udom, time_t expiry);
static struct ip_map *__ip_map_lookup(struct cache_detail *cd, char *class, struct in6_addr *addr);
static int __ip_map_update(struct cache_detail *cd, struct ip_map *ipm, struct unix_domain *udom, time_t expiry);

static int ip_map_parse(struct cache_detail *cd,
			  char *mesg, int mlen)
@@ -249,9 +249,9 @@ static int ip_map_parse(struct cache_detail *cd,
		dom = NULL;

	/* IPv6 scope IDs are ignored for now */
	ipmp = ip_map_lookup(class, &sin6.sin6_addr);
	ipmp = __ip_map_lookup(cd, class, &sin6.sin6_addr);
	if (ipmp) {
		err = ip_map_update(ipmp,
		err = __ip_map_update(cd, ipmp,
			     container_of(dom, struct unix_domain, h),
			     expiry);
	} else
@@ -309,14 +309,15 @@ struct cache_detail ip_map_cache = {
	.alloc		= ip_map_alloc,
};

static struct ip_map *ip_map_lookup(char *class, struct in6_addr *addr)
static struct ip_map *__ip_map_lookup(struct cache_detail *cd, char *class,
		struct in6_addr *addr)
{
	struct ip_map ip;
	struct cache_head *ch;

	strcpy(ip.m_class, class);
	ipv6_addr_copy(&ip.m_addr, addr);
	ch = sunrpc_cache_lookup(&ip_map_cache, &ip.h,
	ch = sunrpc_cache_lookup(cd, &ip.h,
				 hash_str(class, IP_HASHBITS) ^
				 hash_ip6(*addr));

@@ -326,7 +327,13 @@ static struct ip_map *ip_map_lookup(char *class, struct in6_addr *addr)
		return NULL;
}

static int ip_map_update(struct ip_map *ipm, struct unix_domain *udom, time_t expiry)
static inline struct ip_map *ip_map_lookup(char *class, struct in6_addr *addr)
{
	return __ip_map_lookup(&ip_map_cache, class, addr);
}

static int __ip_map_update(struct cache_detail *cd, struct ip_map *ipm,
		struct unix_domain *udom, time_t expiry)
{
	struct ip_map ip;
	struct cache_head *ch;
@@ -344,16 +351,20 @@ static int ip_map_update(struct ip_map *ipm, struct unix_domain *udom, time_t ex
			ip.m_add_change++;
	}
	ip.h.expiry_time = expiry;
	ch = sunrpc_cache_update(&ip_map_cache,
				 &ip.h, &ipm->h,
	ch = sunrpc_cache_update(cd, &ip.h, &ipm->h,
				 hash_str(ipm->m_class, IP_HASHBITS) ^
				 hash_ip6(ipm->m_addr));
	if (!ch)
		return -ENOMEM;
	cache_put(ch, &ip_map_cache);
	cache_put(ch, cd);
	return 0;
}

static inline int ip_map_update(struct ip_map *ipm, struct unix_domain *udom, time_t expiry)
{
	return __ip_map_update(&ip_map_cache, ipm, udom, expiry);
}

int auth_unix_add_addr(struct in6_addr *addr, struct auth_domain *dom)
{
	struct unix_domain *udom;