1 #include <linux/types.h>
2 #include <linux/sched.h>
3 #include <linux/module.h>
4 #include <linux/sunrpc/types.h>
5 #include <linux/sunrpc/xdr.h>
6 #include <linux/sunrpc/svcsock.h>
7 #include <linux/sunrpc/svcauth.h>
8 #include <linux/sunrpc/gss_api.h>
10 #include <linux/seq_file.h>
11 #include <linux/hash.h>
12 #include <linux/string.h>
13 #include <linux/slab.h>
16 #include <linux/kernel.h>
17 #define RPCDBG_FACILITY RPCDBG_AUTH
19 #include <linux/sunrpc/clnt.h>
24 * AUTHUNIX and AUTHNULL credentials are both handled here.
25 * AUTHNULL is treated just like AUTHUNIX except that the uid/gid
26 * are always nobody (-2). i.e. we do the same IP address checks for
27 * AUTHNULL as for AUTHUNIX, and that is done here.
34 /* other stuff later */
37 extern struct auth_ops svcauth_unix;
39 struct auth_domain *unix_domain_find(char *name)
41 struct auth_domain *rv;
42 struct unix_domain *new = NULL;
44 rv = auth_domain_lookup(name, NULL);
47 if (new && rv != &new->h)
48 auth_domain_put(&new->h);
50 if (rv->flavour != &svcauth_unix) {
57 new = kmalloc(sizeof(*new), GFP_KERNEL);
60 kref_init(&new->h.ref);
61 new->h.name = kstrdup(name, GFP_KERNEL);
62 if (new->h.name == NULL) {
66 new->h.flavour = &svcauth_unix;
67 new->addr_changes = 0;
68 rv = auth_domain_lookup(name, &new->h);
71 EXPORT_SYMBOL_GPL(unix_domain_find);
73 static void svcauth_unix_domain_release(struct auth_domain *dom)
75 struct unix_domain *ud = container_of(dom, struct unix_domain, h);
82 /**************************************************
83 * cache for IP address to unix_domain
84 * as needed by AUTH_UNIX
87 #define IP_HASHMAX (1<<IP_HASHBITS)
91 char m_class[8]; /* e.g. "nfsd" */
92 struct in6_addr m_addr;
93 struct unix_domain *m_client;
97 static void ip_map_put(struct kref *kref)
99 struct cache_head *item = container_of(kref, struct cache_head, ref);
100 struct ip_map *im = container_of(item, struct ip_map,h);
102 if (test_bit(CACHE_VALID, &item->flags) &&
103 !test_bit(CACHE_NEGATIVE, &item->flags))
104 auth_domain_put(&im->m_client->h);
109 /* hash_long on a 64 bit machine is currently REALLY BAD for
110 * IP addresses in reverse-endian (i.e. on a little-endian machine).
111 * So use a trivial but reliable hash instead
113 static inline int hash_ip(__be32 ip)
115 int hash = (__force u32)ip ^ ((__force u32)ip>>16);
116 return (hash ^ (hash>>8)) & 0xff;
119 static inline int hash_ip6(struct in6_addr ip)
121 return (hash_ip(ip.s6_addr32[0]) ^
122 hash_ip(ip.s6_addr32[1]) ^
123 hash_ip(ip.s6_addr32[2]) ^
124 hash_ip(ip.s6_addr32[3]));
126 static int ip_map_match(struct cache_head *corig, struct cache_head *cnew)
128 struct ip_map *orig = container_of(corig, struct ip_map, h);
129 struct ip_map *new = container_of(cnew, struct ip_map, h);
130 return strcmp(orig->m_class, new->m_class) == 0 &&
131 ipv6_addr_equal(&orig->m_addr, &new->m_addr);
133 static void ip_map_init(struct cache_head *cnew, struct cache_head *citem)
135 struct ip_map *new = container_of(cnew, struct ip_map, h);
136 struct ip_map *item = container_of(citem, struct ip_map, h);
138 strcpy(new->m_class, item->m_class);
139 ipv6_addr_copy(&new->m_addr, &item->m_addr);
141 static void update(struct cache_head *cnew, struct cache_head *citem)
143 struct ip_map *new = container_of(cnew, struct ip_map, h);
144 struct ip_map *item = container_of(citem, struct ip_map, h);
146 kref_get(&item->m_client->h.ref);
147 new->m_client = item->m_client;
148 new->m_add_change = item->m_add_change;
150 static struct cache_head *ip_map_alloc(void)
152 struct ip_map *i = kmalloc(sizeof(*i), GFP_KERNEL);
159 static void ip_map_request(struct cache_detail *cd,
160 struct cache_head *h,
161 char **bpp, int *blen)
164 struct ip_map *im = container_of(h, struct ip_map, h);
166 if (ipv6_addr_v4mapped(&(im->m_addr))) {
167 snprintf(text_addr, 20, "%pI4", &im->m_addr.s6_addr32[3]);
169 snprintf(text_addr, 40, "%pI6", &im->m_addr);
171 qword_add(bpp, blen, im->m_class);
172 qword_add(bpp, blen, text_addr);
176 static int ip_map_upcall(struct cache_detail *cd, struct cache_head *h)
178 return sunrpc_cache_pipe_upcall(cd, h, ip_map_request);
181 static struct ip_map *__ip_map_lookup(struct cache_detail *cd, char *class, struct in6_addr *addr);
182 static int __ip_map_update(struct cache_detail *cd, struct ip_map *ipm, struct unix_domain *udom, time_t expiry);
184 static int ip_map_parse(struct cache_detail *cd,
185 char *mesg, int mlen)
187 /* class ipaddress [domainname] */
188 /* should be safe just to use the start of the input buffer
195 struct sockaddr_in s4;
196 struct sockaddr_in6 s6;
198 struct sockaddr_in6 sin6;
202 struct auth_domain *dom;
205 if (mesg[mlen-1] != '\n')
210 len = qword_get(&mesg, class, sizeof(class));
211 if (len <= 0) return -EINVAL;
214 len = qword_get(&mesg, buf, mlen);
215 if (len <= 0) return -EINVAL;
217 if (rpc_pton(buf, len, &address.sa, sizeof(address)) == 0)
219 switch (address.sa.sa_family) {
221 /* Form a mapped IPv4 address in sin6 */
222 sin6.sin6_family = AF_INET6;
223 ipv6_addr_set_v4mapped(address.s4.sin_addr.s_addr,
226 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
228 memcpy(&sin6, &address.s6, sizeof(sin6));
235 expiry = get_expiry(&mesg);
239 /* domainname, or empty for NEGATIVE */
240 len = qword_get(&mesg, buf, mlen);
241 if (len < 0) return -EINVAL;
244 dom = unix_domain_find(buf);
250 /* IPv6 scope IDs are ignored for now */
251 ipmp = __ip_map_lookup(cd, class, &sin6.sin6_addr);
253 err = __ip_map_update(cd, ipmp,
254 container_of(dom, struct unix_domain, h),
260 auth_domain_put(dom);
266 static int ip_map_show(struct seq_file *m,
267 struct cache_detail *cd,
268 struct cache_head *h)
271 struct in6_addr addr;
272 char *dom = "-no-domain-";
275 seq_puts(m, "#class IP domain\n");
278 im = container_of(h, struct ip_map, h);
279 /* class addr domain */
280 ipv6_addr_copy(&addr, &im->m_addr);
282 if (test_bit(CACHE_VALID, &h->flags) &&
283 !test_bit(CACHE_NEGATIVE, &h->flags))
284 dom = im->m_client->h.name;
286 if (ipv6_addr_v4mapped(&addr)) {
287 seq_printf(m, "%s %pI4 %s\n",
288 im->m_class, &addr.s6_addr32[3], dom);
290 seq_printf(m, "%s %pI6 %s\n", im->m_class, &addr, dom);
296 static struct ip_map *__ip_map_lookup(struct cache_detail *cd, char *class,
297 struct in6_addr *addr)
300 struct cache_head *ch;
302 strcpy(ip.m_class, class);
303 ipv6_addr_copy(&ip.m_addr, addr);
304 ch = sunrpc_cache_lookup(cd, &ip.h,
305 hash_str(class, IP_HASHBITS) ^
309 return container_of(ch, struct ip_map, h);
314 static inline struct ip_map *ip_map_lookup(struct net *net, char *class,
315 struct in6_addr *addr)
317 struct sunrpc_net *sn;
319 sn = net_generic(net, sunrpc_net_id);
320 return __ip_map_lookup(sn->ip_map_cache, class, addr);
323 static int __ip_map_update(struct cache_detail *cd, struct ip_map *ipm,
324 struct unix_domain *udom, time_t expiry)
327 struct cache_head *ch;
332 set_bit(CACHE_NEGATIVE, &ip.h.flags);
334 ip.m_add_change = udom->addr_changes;
335 /* if this is from the legacy set_client system call,
336 * we need m_add_change to be one higher
341 ip.h.expiry_time = expiry;
342 ch = sunrpc_cache_update(cd, &ip.h, &ipm->h,
343 hash_str(ipm->m_class, IP_HASHBITS) ^
344 hash_ip6(ipm->m_addr));
351 static inline int ip_map_update(struct net *net, struct ip_map *ipm,
352 struct unix_domain *udom, time_t expiry)
354 struct sunrpc_net *sn;
356 sn = net_generic(net, sunrpc_net_id);
357 return __ip_map_update(sn->ip_map_cache, ipm, udom, expiry);
360 int auth_unix_add_addr(struct net *net, struct in6_addr *addr, struct auth_domain *dom)
362 struct unix_domain *udom;
365 if (dom->flavour != &svcauth_unix)
367 udom = container_of(dom, struct unix_domain, h);
368 ipmp = ip_map_lookup(net, "nfsd", addr);
371 return ip_map_update(net, ipmp, udom, NEVER);
375 EXPORT_SYMBOL_GPL(auth_unix_add_addr);
377 int auth_unix_forget_old(struct auth_domain *dom)
379 struct unix_domain *udom;
381 if (dom->flavour != &svcauth_unix)
383 udom = container_of(dom, struct unix_domain, h);
384 udom->addr_changes++;
387 EXPORT_SYMBOL_GPL(auth_unix_forget_old);
389 struct auth_domain *auth_unix_lookup(struct net *net, struct in6_addr *addr)
392 struct auth_domain *rv;
393 struct sunrpc_net *sn;
395 sn = net_generic(net, sunrpc_net_id);
396 ipm = ip_map_lookup(net, "nfsd", addr);
400 if (cache_check(sn->ip_map_cache, &ipm->h, NULL))
403 if ((ipm->m_client->addr_changes - ipm->m_add_change) >0) {
404 if (test_and_set_bit(CACHE_NEGATIVE, &ipm->h.flags) == 0)
405 auth_domain_put(&ipm->m_client->h);
408 rv = &ipm->m_client->h;
411 cache_put(&ipm->h, sn->ip_map_cache);
414 EXPORT_SYMBOL_GPL(auth_unix_lookup);
416 void svcauth_unix_purge(void)
421 struct sunrpc_net *sn;
423 sn = net_generic(net, sunrpc_net_id);
424 cache_purge(sn->ip_map_cache);
427 EXPORT_SYMBOL_GPL(svcauth_unix_purge);
429 static inline struct ip_map *
430 ip_map_cached_get(struct svc_xprt *xprt)
432 struct ip_map *ipm = NULL;
433 struct sunrpc_net *sn;
435 if (test_bit(XPT_CACHE_AUTH, &xprt->xpt_flags)) {
436 spin_lock(&xprt->xpt_lock);
437 ipm = xprt->xpt_auth_cache;
439 if (!cache_valid(&ipm->h)) {
441 * The entry has been invalidated since it was
442 * remembered, e.g. by a second mount from the
445 sn = net_generic(xprt->xpt_net, sunrpc_net_id);
446 xprt->xpt_auth_cache = NULL;
447 spin_unlock(&xprt->xpt_lock);
448 cache_put(&ipm->h, sn->ip_map_cache);
453 spin_unlock(&xprt->xpt_lock);
459 ip_map_cached_put(struct svc_xprt *xprt, struct ip_map *ipm)
461 if (test_bit(XPT_CACHE_AUTH, &xprt->xpt_flags)) {
462 spin_lock(&xprt->xpt_lock);
463 if (xprt->xpt_auth_cache == NULL) {
464 /* newly cached, keep the reference */
465 xprt->xpt_auth_cache = ipm;
468 spin_unlock(&xprt->xpt_lock);
471 struct sunrpc_net *sn;
473 sn = net_generic(xprt->xpt_net, sunrpc_net_id);
474 cache_put(&ipm->h, sn->ip_map_cache);
479 svcauth_unix_info_release(struct svc_xprt *xpt)
483 ipm = xpt->xpt_auth_cache;
485 struct sunrpc_net *sn;
487 sn = net_generic(xpt->xpt_net, sunrpc_net_id);
488 cache_put(&ipm->h, sn->ip_map_cache);
492 /****************************************************************************
493 * auth.unix.gid cache
494 * simple cache to map a UID to a list of GIDs
495 * because AUTH_UNIX aka AUTH_SYS has a max of 16
497 #define GID_HASHBITS 8
498 #define GID_HASHMAX (1<<GID_HASHBITS)
503 struct group_info *gi;
505 static struct cache_head *gid_table[GID_HASHMAX];
507 static void unix_gid_put(struct kref *kref)
509 struct cache_head *item = container_of(kref, struct cache_head, ref);
510 struct unix_gid *ug = container_of(item, struct unix_gid, h);
511 if (test_bit(CACHE_VALID, &item->flags) &&
512 !test_bit(CACHE_NEGATIVE, &item->flags))
513 put_group_info(ug->gi);
517 static int unix_gid_match(struct cache_head *corig, struct cache_head *cnew)
519 struct unix_gid *orig = container_of(corig, struct unix_gid, h);
520 struct unix_gid *new = container_of(cnew, struct unix_gid, h);
521 return orig->uid == new->uid;
523 static void unix_gid_init(struct cache_head *cnew, struct cache_head *citem)
525 struct unix_gid *new = container_of(cnew, struct unix_gid, h);
526 struct unix_gid *item = container_of(citem, struct unix_gid, h);
527 new->uid = item->uid;
529 static void unix_gid_update(struct cache_head *cnew, struct cache_head *citem)
531 struct unix_gid *new = container_of(cnew, struct unix_gid, h);
532 struct unix_gid *item = container_of(citem, struct unix_gid, h);
534 get_group_info(item->gi);
537 static struct cache_head *unix_gid_alloc(void)
539 struct unix_gid *g = kmalloc(sizeof(*g), GFP_KERNEL);
546 static void unix_gid_request(struct cache_detail *cd,
547 struct cache_head *h,
548 char **bpp, int *blen)
551 struct unix_gid *ug = container_of(h, struct unix_gid, h);
553 snprintf(tuid, 20, "%u", ug->uid);
554 qword_add(bpp, blen, tuid);
558 static int unix_gid_upcall(struct cache_detail *cd, struct cache_head *h)
560 return sunrpc_cache_pipe_upcall(cd, h, unix_gid_request);
563 static struct unix_gid *unix_gid_lookup(uid_t uid);
564 extern struct cache_detail unix_gid_cache;
566 static int unix_gid_parse(struct cache_detail *cd,
567 char *mesg, int mlen)
569 /* uid expiry Ngid gid0 gid1 ... gidN-1 */
576 struct unix_gid ug, *ugp;
578 if (mlen <= 0 || mesg[mlen-1] != '\n')
582 rv = get_int(&mesg, &uid);
587 expiry = get_expiry(&mesg);
591 rv = get_int(&mesg, &gids);
592 if (rv || gids < 0 || gids > 8192)
595 ug.gi = groups_alloc(gids);
599 for (i = 0 ; i < gids ; i++) {
601 rv = get_int(&mesg, &gid);
605 GROUP_AT(ug.gi, i) = gid;
608 ugp = unix_gid_lookup(uid);
610 struct cache_head *ch;
612 ug.h.expiry_time = expiry;
613 ch = sunrpc_cache_update(&unix_gid_cache,
615 hash_long(uid, GID_HASHBITS));
620 cache_put(ch, &unix_gid_cache);
626 put_group_info(ug.gi);
630 static int unix_gid_show(struct seq_file *m,
631 struct cache_detail *cd,
632 struct cache_head *h)
639 seq_puts(m, "#uid cnt: gids...\n");
642 ug = container_of(h, struct unix_gid, h);
643 if (test_bit(CACHE_VALID, &h->flags) &&
644 !test_bit(CACHE_NEGATIVE, &h->flags))
645 glen = ug->gi->ngroups;
649 seq_printf(m, "%u %d:", ug->uid, glen);
650 for (i = 0; i < glen; i++)
651 seq_printf(m, " %d", GROUP_AT(ug->gi, i));
656 struct cache_detail unix_gid_cache = {
657 .owner = THIS_MODULE,
658 .hash_size = GID_HASHMAX,
659 .hash_table = gid_table,
660 .name = "auth.unix.gid",
661 .cache_put = unix_gid_put,
662 .cache_upcall = unix_gid_upcall,
663 .cache_parse = unix_gid_parse,
664 .cache_show = unix_gid_show,
665 .match = unix_gid_match,
666 .init = unix_gid_init,
667 .update = unix_gid_update,
668 .alloc = unix_gid_alloc,
671 static struct unix_gid *unix_gid_lookup(uid_t uid)
674 struct cache_head *ch;
677 ch = sunrpc_cache_lookup(&unix_gid_cache, &ug.h,
678 hash_long(uid, GID_HASHBITS));
680 return container_of(ch, struct unix_gid, h);
685 static struct group_info *unix_gid_find(uid_t uid, struct svc_rqst *rqstp)
688 struct group_info *gi;
691 ug = unix_gid_lookup(uid);
693 return ERR_PTR(-EAGAIN);
694 ret = cache_check(&unix_gid_cache, &ug->h, &rqstp->rq_chandle);
697 return ERR_PTR(-ENOENT);
699 return ERR_PTR(-ESHUTDOWN);
701 gi = get_group_info(ug->gi);
702 cache_put(&ug->h, &unix_gid_cache);
705 return ERR_PTR(-EAGAIN);
710 svcauth_unix_set_client(struct svc_rqst *rqstp)
712 struct sockaddr_in *sin;
713 struct sockaddr_in6 *sin6, sin6_storage;
715 struct group_info *gi;
716 struct svc_cred *cred = &rqstp->rq_cred;
717 struct svc_xprt *xprt = rqstp->rq_xprt;
718 struct net *net = xprt->xpt_net;
719 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
721 switch (rqstp->rq_addr.ss_family) {
723 sin = svc_addr_in(rqstp);
724 sin6 = &sin6_storage;
725 ipv6_addr_set_v4mapped(sin->sin_addr.s_addr, &sin6->sin6_addr);
728 sin6 = svc_addr_in6(rqstp);
734 rqstp->rq_client = NULL;
735 if (rqstp->rq_proc == 0)
738 ipm = ip_map_cached_get(xprt);
740 ipm = __ip_map_lookup(sn->ip_map_cache, rqstp->rq_server->sv_program->pg_class,
746 switch (cache_check(sn->ip_map_cache, &ipm->h, &rqstp->rq_chandle)) {
756 rqstp->rq_client = &ipm->m_client->h;
757 kref_get(&rqstp->rq_client->ref);
758 ip_map_cached_put(xprt, ipm);
762 gi = unix_gid_find(cred->cr_uid, rqstp);
763 switch (PTR_ERR(gi)) {
771 put_group_info(cred->cr_group_info);
772 cred->cr_group_info = gi;
777 EXPORT_SYMBOL_GPL(svcauth_unix_set_client);
780 svcauth_null_accept(struct svc_rqst *rqstp, __be32 *authp)
782 struct kvec *argv = &rqstp->rq_arg.head[0];
783 struct kvec *resv = &rqstp->rq_res.head[0];
784 struct svc_cred *cred = &rqstp->rq_cred;
786 cred->cr_group_info = NULL;
787 rqstp->rq_client = NULL;
789 if (argv->iov_len < 3*4)
792 if (svc_getu32(argv) != 0) {
793 dprintk("svc: bad null cred\n");
794 *authp = rpc_autherr_badcred;
797 if (svc_getu32(argv) != htonl(RPC_AUTH_NULL) || svc_getu32(argv) != 0) {
798 dprintk("svc: bad null verf\n");
799 *authp = rpc_autherr_badverf;
803 /* Signal that mapping to nobody uid/gid is required */
804 cred->cr_uid = (uid_t) -1;
805 cred->cr_gid = (gid_t) -1;
806 cred->cr_group_info = groups_alloc(0);
807 if (cred->cr_group_info == NULL)
808 return SVC_CLOSE; /* kmalloc failure - client must retry */
810 /* Put NULL verifier */
811 svc_putnl(resv, RPC_AUTH_NULL);
814 rqstp->rq_flavor = RPC_AUTH_NULL;
819 svcauth_null_release(struct svc_rqst *rqstp)
821 if (rqstp->rq_client)
822 auth_domain_put(rqstp->rq_client);
823 rqstp->rq_client = NULL;
824 if (rqstp->rq_cred.cr_group_info)
825 put_group_info(rqstp->rq_cred.cr_group_info);
826 rqstp->rq_cred.cr_group_info = NULL;
828 return 0; /* don't drop */
832 struct auth_ops svcauth_null = {
834 .owner = THIS_MODULE,
835 .flavour = RPC_AUTH_NULL,
836 .accept = svcauth_null_accept,
837 .release = svcauth_null_release,
838 .set_client = svcauth_unix_set_client,
843 svcauth_unix_accept(struct svc_rqst *rqstp, __be32 *authp)
845 struct kvec *argv = &rqstp->rq_arg.head[0];
846 struct kvec *resv = &rqstp->rq_res.head[0];
847 struct svc_cred *cred = &rqstp->rq_cred;
849 int len = argv->iov_len;
851 cred->cr_group_info = NULL;
852 rqstp->rq_client = NULL;
854 if ((len -= 3*4) < 0)
857 svc_getu32(argv); /* length */
858 svc_getu32(argv); /* time stamp */
859 slen = XDR_QUADLEN(svc_getnl(argv)); /* machname length */
860 if (slen > 64 || (len -= (slen + 3)*4) < 0)
862 argv->iov_base = (void*)((__be32*)argv->iov_base + slen); /* skip machname */
863 argv->iov_len -= slen*4;
865 cred->cr_uid = svc_getnl(argv); /* uid */
866 cred->cr_gid = svc_getnl(argv); /* gid */
867 slen = svc_getnl(argv); /* gids length */
868 if (slen > 16 || (len -= (slen + 2)*4) < 0)
870 cred->cr_group_info = groups_alloc(slen);
871 if (cred->cr_group_info == NULL)
873 for (i = 0; i < slen; i++)
874 GROUP_AT(cred->cr_group_info, i) = svc_getnl(argv);
875 if (svc_getu32(argv) != htonl(RPC_AUTH_NULL) || svc_getu32(argv) != 0) {
876 *authp = rpc_autherr_badverf;
880 /* Put NULL verifier */
881 svc_putnl(resv, RPC_AUTH_NULL);
884 rqstp->rq_flavor = RPC_AUTH_UNIX;
888 *authp = rpc_autherr_badcred;
893 svcauth_unix_release(struct svc_rqst *rqstp)
895 /* Verifier (such as it is) is already in place.
897 if (rqstp->rq_client)
898 auth_domain_put(rqstp->rq_client);
899 rqstp->rq_client = NULL;
900 if (rqstp->rq_cred.cr_group_info)
901 put_group_info(rqstp->rq_cred.cr_group_info);
902 rqstp->rq_cred.cr_group_info = NULL;
908 struct auth_ops svcauth_unix = {
910 .owner = THIS_MODULE,
911 .flavour = RPC_AUTH_UNIX,
912 .accept = svcauth_unix_accept,
913 .release = svcauth_unix_release,
914 .domain_release = svcauth_unix_domain_release,
915 .set_client = svcauth_unix_set_client,
918 int ip_map_cache_create(struct net *net)
921 struct cache_detail *cd;
922 struct cache_head **tbl;
923 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
925 cd = kzalloc(sizeof(struct cache_detail), GFP_KERNEL);
929 tbl = kzalloc(IP_HASHMAX * sizeof(struct cache_head *), GFP_KERNEL);
933 cd->owner = THIS_MODULE,
934 cd->hash_size = IP_HASHMAX,
935 cd->hash_table = tbl,
936 cd->name = "auth.unix.ip",
937 cd->cache_put = ip_map_put,
938 cd->cache_upcall = ip_map_upcall,
939 cd->cache_parse = ip_map_parse,
940 cd->cache_show = ip_map_show,
941 cd->match = ip_map_match,
942 cd->init = ip_map_init,
944 cd->alloc = ip_map_alloc,
946 err = cache_register_net(cd, net);
950 sn->ip_map_cache = cd;
961 void ip_map_cache_destroy(struct net *net)
963 struct sunrpc_net *sn;
965 sn = net_generic(net, sunrpc_net_id);
966 cache_purge(sn->ip_map_cache);
967 cache_unregister_net(sn->ip_map_cache, net);
968 kfree(sn->ip_map_cache->hash_table);
969 kfree(sn->ip_map_cache);