aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2009-08-09 15:14:29 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2009-08-09 15:14:29 -0400
commitbc74b4f5e63a09fb78e245794a0de1e5a2716bbe (patch)
tree5e96e63fd69303162456549f12bff5f9b2ee2a22 /net/sunrpc
parentda77005f0d64486cd760f43d9b7cc2379262a363 (diff)
SUNRPC: Allow the cache_detail to specify alternative upcall mechanisms
For events that are rare, such as referral DNS lookups, it makes limited sense to have a daemon constantly listening for upcalls on a channel. An alternative in those cases might simply be to run the app that fills the cache using call_usermodehelper_exec() and friends. The following patch allows the cache_detail to specify alternative upcall mechanisms for these particular cases. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc')
-rw-r--r--net/sunrpc/auth_gss/svcauth_gss.c7
-rw-r--r--net/sunrpc/cache.c26
-rw-r--r--net/sunrpc/svcauth_unix.c14
3 files changed, 36 insertions, 11 deletions
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
index 2278a50c6444..2e6a148d277c 100644
--- a/net/sunrpc/auth_gss/svcauth_gss.c
+++ b/net/sunrpc/auth_gss/svcauth_gss.c
@@ -181,6 +181,11 @@ static void rsi_request(struct cache_detail *cd,
181 (*bpp)[-1] = '\n'; 181 (*bpp)[-1] = '\n';
182} 182}
183 183
184static int rsi_upcall(struct cache_detail *cd, struct cache_head *h)
185{
186 return sunrpc_cache_pipe_upcall(cd, h, rsi_request);
187}
188
184 189
185static int rsi_parse(struct cache_detail *cd, 190static int rsi_parse(struct cache_detail *cd,
186 char *mesg, int mlen) 191 char *mesg, int mlen)
@@ -270,7 +275,7 @@ static struct cache_detail rsi_cache = {
270 .hash_table = rsi_table, 275 .hash_table = rsi_table,
271 .name = "auth.rpcsec.init", 276 .name = "auth.rpcsec.init",
272 .cache_put = rsi_put, 277 .cache_put = rsi_put,
273 .cache_request = rsi_request, 278 .cache_upcall = rsi_upcall,
274 .cache_parse = rsi_parse, 279 .cache_parse = rsi_parse,
275 .match = rsi_match, 280 .match = rsi_match,
276 .init = rsi_init, 281 .init = rsi_init,
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index c8e7d2d07260..e438352bed7b 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -176,7 +176,13 @@ struct cache_head *sunrpc_cache_update(struct cache_detail *detail,
176} 176}
177EXPORT_SYMBOL_GPL(sunrpc_cache_update); 177EXPORT_SYMBOL_GPL(sunrpc_cache_update);
178 178
179static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h); 179static int cache_make_upcall(struct cache_detail *cd, struct cache_head *h)
180{
181 if (!cd->cache_upcall)
182 return -EINVAL;
183 return cd->cache_upcall(cd, h);
184}
185
180/* 186/*
181 * This is the generic cache management routine for all 187 * This is the generic cache management routine for all
182 * the authentication caches. 188 * the authentication caches.
@@ -322,7 +328,7 @@ static int create_cache_proc_entries(struct cache_detail *cd)
322 if (p == NULL) 328 if (p == NULL)
323 goto out_nomem; 329 goto out_nomem;
324 330
325 if (cd->cache_request || cd->cache_parse) { 331 if (cd->cache_upcall || cd->cache_parse) {
326 p = proc_create_data("channel", S_IFREG|S_IRUSR|S_IWUSR, 332 p = proc_create_data("channel", S_IFREG|S_IRUSR|S_IWUSR,
327 cd->proc_ent, &cache_file_operations, cd); 333 cd->proc_ent, &cache_file_operations, cd);
328 cd->channel_ent = p; 334 cd->channel_ent = p;
@@ -1080,10 +1086,16 @@ static void warn_no_listener(struct cache_detail *detail)
1080} 1086}
1081 1087
1082/* 1088/*
1083 * register an upcall request to user-space. 1089 * register an upcall request to user-space and queue it up for read() by the
1090 * upcall daemon.
1091 *
1084 * Each request is at most one page long. 1092 * Each request is at most one page long.
1085 */ 1093 */
1086static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h) 1094int sunrpc_cache_pipe_upcall(struct cache_detail *detail, struct cache_head *h,
1095 void (*cache_request)(struct cache_detail *,
1096 struct cache_head *,
1097 char **,
1098 int *))
1087{ 1099{
1088 1100
1089 char *buf; 1101 char *buf;
@@ -1091,9 +1103,6 @@ static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h)
1091 char *bp; 1103 char *bp;
1092 int len; 1104 int len;
1093 1105
1094 if (detail->cache_request == NULL)
1095 return -EINVAL;
1096
1097 if (atomic_read(&detail->readers) == 0 && 1106 if (atomic_read(&detail->readers) == 0 &&
1098 detail->last_close < get_seconds() - 30) { 1107 detail->last_close < get_seconds() - 30) {
1099 warn_no_listener(detail); 1108 warn_no_listener(detail);
@@ -1112,7 +1121,7 @@ static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h)
1112 1121
1113 bp = buf; len = PAGE_SIZE; 1122 bp = buf; len = PAGE_SIZE;
1114 1123
1115 detail->cache_request(detail, h, &bp, &len); 1124 cache_request(detail, h, &bp, &len);
1116 1125
1117 if (len < 0) { 1126 if (len < 0) {
1118 kfree(buf); 1127 kfree(buf);
@@ -1130,6 +1139,7 @@ static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h)
1130 wake_up(&queue_wait); 1139 wake_up(&queue_wait);
1131 return 0; 1140 return 0;
1132} 1141}
1142EXPORT_SYMBOL_GPL(sunrpc_cache_pipe_upcall);
1133 1143
1134/* 1144/*
1135 * parse a message from user-space and pass it 1145 * parse a message from user-space and pass it
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
index 5c865e2d299e..6caffa34ac01 100644
--- a/net/sunrpc/svcauth_unix.c
+++ b/net/sunrpc/svcauth_unix.c
@@ -171,6 +171,11 @@ static void ip_map_request(struct cache_detail *cd,
171 (*bpp)[-1] = '\n'; 171 (*bpp)[-1] = '\n';
172} 172}
173 173
174static int ip_map_upcall(struct cache_detail *cd, struct cache_head *h)
175{
176 return sunrpc_cache_pipe_upcall(cd, h, ip_map_request);
177}
178
174static struct ip_map *ip_map_lookup(char *class, struct in6_addr *addr); 179static struct ip_map *ip_map_lookup(char *class, struct in6_addr *addr);
175static int ip_map_update(struct ip_map *ipm, struct unix_domain *udom, time_t expiry); 180static int ip_map_update(struct ip_map *ipm, struct unix_domain *udom, time_t expiry);
176 181
@@ -289,7 +294,7 @@ struct cache_detail ip_map_cache = {
289 .hash_table = ip_table, 294 .hash_table = ip_table,
290 .name = "auth.unix.ip", 295 .name = "auth.unix.ip",
291 .cache_put = ip_map_put, 296 .cache_put = ip_map_put,
292 .cache_request = ip_map_request, 297 .cache_upcall = ip_map_upcall,
293 .cache_parse = ip_map_parse, 298 .cache_parse = ip_map_parse,
294 .cache_show = ip_map_show, 299 .cache_show = ip_map_show,
295 .match = ip_map_match, 300 .match = ip_map_match,
@@ -523,6 +528,11 @@ static void unix_gid_request(struct cache_detail *cd,
523 (*bpp)[-1] = '\n'; 528 (*bpp)[-1] = '\n';
524} 529}
525 530
531static int unix_gid_upcall(struct cache_detail *cd, struct cache_head *h)
532{
533 return sunrpc_cache_pipe_upcall(cd, h, unix_gid_request);
534}
535
526static struct unix_gid *unix_gid_lookup(uid_t uid); 536static struct unix_gid *unix_gid_lookup(uid_t uid);
527extern struct cache_detail unix_gid_cache; 537extern struct cache_detail unix_gid_cache;
528 538
@@ -622,7 +632,7 @@ struct cache_detail unix_gid_cache = {
622 .hash_table = gid_table, 632 .hash_table = gid_table,
623 .name = "auth.unix.gid", 633 .name = "auth.unix.gid",
624 .cache_put = unix_gid_put, 634 .cache_put = unix_gid_put,
625 .cache_request = unix_gid_request, 635 .cache_upcall = unix_gid_upcall,
626 .cache_parse = unix_gid_parse, 636 .cache_parse = unix_gid_parse,
627 .cache_show = unix_gid_show, 637 .cache_show = unix_gid_show,
628 .match = unix_gid_match, 638 .match = unix_gid_match,