SUNRPC: Refactor rpcb_register to make rpcbindv4 support easier
[pandora-kernel.git] / net / sunrpc / rpcb_clnt.c
1 /*
2  * In-kernel rpcbind client supporting versions 2, 3, and 4 of the rpcbind
3  * protocol
4  *
5  * Based on RFC 1833: "Binding Protocols for ONC RPC Version 2" and
6  * RFC 3530: "Network File System (NFS) version 4 Protocol"
7  *
8  * Original: Gilles Quillard, Bull Open Source, 2005 <gilles.quillard@bull.net>
9  * Updated: Chuck Lever, Oracle Corporation, 2007 <chuck.lever@oracle.com>
10  *
11  * Descended from net/sunrpc/pmap_clnt.c,
12  *  Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
13  */
14
15 #include <linux/module.h>
16
17 #include <linux/types.h>
18 #include <linux/socket.h>
19 #include <linux/in.h>
20 #include <linux/in6.h>
21 #include <linux/kernel.h>
22 #include <linux/errno.h>
23
24 #include <linux/sunrpc/clnt.h>
25 #include <linux/sunrpc/sched.h>
26 #include <linux/sunrpc/xprtsock.h>
27
28 #ifdef RPC_DEBUG
29 # define RPCDBG_FACILITY        RPCDBG_BIND
30 #endif
31
32 #define RPCBIND_PROGRAM         (100000u)
33 #define RPCBIND_PORT            (111u)
34
35 #define RPCBVERS_2              (2u)
36 #define RPCBVERS_3              (3u)
37 #define RPCBVERS_4              (4u)
38
39 enum {
40         RPCBPROC_NULL,
41         RPCBPROC_SET,
42         RPCBPROC_UNSET,
43         RPCBPROC_GETPORT,
44         RPCBPROC_GETADDR = 3,           /* alias for GETPORT */
45         RPCBPROC_DUMP,
46         RPCBPROC_CALLIT,
47         RPCBPROC_BCAST = 5,             /* alias for CALLIT */
48         RPCBPROC_GETTIME,
49         RPCBPROC_UADDR2TADDR,
50         RPCBPROC_TADDR2UADDR,
51         RPCBPROC_GETVERSADDR,
52         RPCBPROC_INDIRECT,
53         RPCBPROC_GETADDRLIST,
54         RPCBPROC_GETSTAT,
55 };
56
57 #define RPCB_HIGHPROC_2         RPCBPROC_CALLIT
58 #define RPCB_HIGHPROC_3         RPCBPROC_TADDR2UADDR
59 #define RPCB_HIGHPROC_4         RPCBPROC_GETSTAT
60
61 /*
62  * r_owner
63  *
64  * The "owner" is allowed to unset a service in the rpcbind database.
65  * We always use the following (arbitrary) fixed string.
66  */
67 #define RPCB_OWNER_STRING       "rpcb"
68 #define RPCB_MAXOWNERLEN        sizeof(RPCB_OWNER_STRING)
69
70 static void                     rpcb_getport_done(struct rpc_task *, void *);
71 static void                     rpcb_map_release(void *data);
72 static struct rpc_program       rpcb_program;
73
74 struct rpcbind_args {
75         struct rpc_xprt *       r_xprt;
76
77         u32                     r_prog;
78         u32                     r_vers;
79         u32                     r_prot;
80         unsigned short          r_port;
81         const char *            r_netid;
82         const char *            r_addr;
83         const char *            r_owner;
84
85         int                     r_status;
86 };
87
88 static struct rpc_procinfo rpcb_procedures2[];
89 static struct rpc_procinfo rpcb_procedures3[];
90
91 struct rpcb_info {
92         u32                     rpc_vers;
93         struct rpc_procinfo *   rpc_proc;
94 };
95
96 static struct rpcb_info rpcb_next_version[];
97 static struct rpcb_info rpcb_next_version6[];
98
99 static const struct rpc_call_ops rpcb_getport_ops = {
100         .rpc_call_done          = rpcb_getport_done,
101         .rpc_release            = rpcb_map_release,
102 };
103
104 static void rpcb_wake_rpcbind_waiters(struct rpc_xprt *xprt, int status)
105 {
106         xprt_clear_binding(xprt);
107         rpc_wake_up_status(&xprt->binding, status);
108 }
109
110 static void rpcb_map_release(void *data)
111 {
112         struct rpcbind_args *map = data;
113
114         rpcb_wake_rpcbind_waiters(map->r_xprt, map->r_status);
115         xprt_put(map->r_xprt);
116         kfree(map);
117 }
118
119 static const struct sockaddr_in rpcb_inaddr_loopback = {
120         .sin_family             = AF_INET,
121         .sin_addr.s_addr        = htonl(INADDR_LOOPBACK),
122         .sin_port               = htons(RPCBIND_PORT),
123 };
124
125 static struct rpc_clnt *rpcb_create_local(struct sockaddr *addr,
126                                           size_t addrlen, u32 version)
127 {
128         struct rpc_create_args args = {
129                 .protocol       = XPRT_TRANSPORT_UDP,
130                 .address        = addr,
131                 .addrsize       = addrlen,
132                 .servername     = "localhost",
133                 .program        = &rpcb_program,
134                 .version        = version,
135                 .authflavor     = RPC_AUTH_UNIX,
136                 .flags          = RPC_CLNT_CREATE_NOPING,
137         };
138
139         return rpc_create(&args);
140 }
141
142 static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr,
143                                     size_t salen, int proto, u32 version)
144 {
145         struct rpc_create_args args = {
146                 .protocol       = proto,
147                 .address        = srvaddr,
148                 .addrsize       = salen,
149                 .servername     = hostname,
150                 .program        = &rpcb_program,
151                 .version        = version,
152                 .authflavor     = RPC_AUTH_UNIX,
153                 .flags          = (RPC_CLNT_CREATE_NOPING |
154                                         RPC_CLNT_CREATE_NONPRIVPORT),
155         };
156
157         switch (srvaddr->sa_family) {
158         case AF_INET:
159                 ((struct sockaddr_in *)srvaddr)->sin_port = htons(RPCBIND_PORT);
160                 break;
161         case AF_INET6:
162                 ((struct sockaddr_in6 *)srvaddr)->sin6_port = htons(RPCBIND_PORT);
163                 break;
164         default:
165                 return NULL;
166         }
167
168         return rpc_create(&args);
169 }
170
171 static int rpcb_register_call(struct sockaddr *addr, size_t addrlen,
172                               u32 version, struct rpc_message *msg,
173                               int *result)
174 {
175         struct rpc_clnt *rpcb_clnt;
176         int error = 0;
177
178         *result = 0;
179
180         rpcb_clnt = rpcb_create_local(addr, addrlen, version);
181         if (!IS_ERR(rpcb_clnt)) {
182                 error = rpc_call_sync(rpcb_clnt, msg, 0);
183                 rpc_shutdown_client(rpcb_clnt);
184         } else
185                 error = PTR_ERR(rpcb_clnt);
186
187         if (error < 0)
188                 printk(KERN_WARNING "RPC: failed to contact local rpcbind "
189                                 "server (errno %d).\n", -error);
190         dprintk("RPC:       registration status %d/%d\n", error, *result);
191
192         return error;
193 }
194
195 /**
196  * rpcb_register - set or unset a port registration with the local rpcbind svc
197  * @prog: RPC program number to bind
198  * @vers: RPC version number to bind
199  * @prot: transport protocol to use to make this request
200  * @port: port value to register
201  * @okay: result code
202  *
203  * port == 0 means unregister, port != 0 means register.
204  *
205  * This routine supports only rpcbind version 2.
206  */
207 int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay)
208 {
209         struct rpcbind_args map = {
210                 .r_prog         = prog,
211                 .r_vers         = vers,
212                 .r_prot         = prot,
213                 .r_port         = port,
214         };
215         struct rpc_message msg = {
216                 .rpc_argp       = &map,
217                 .rpc_resp       = okay,
218         };
219
220         dprintk("RPC:       %sregistering (%u, %u, %d, %u) with local "
221                         "rpcbind\n", (port ? "" : "un"),
222                         prog, vers, prot, port);
223
224         msg.rpc_proc = &rpcb_procedures2[RPCBPROC_UNSET];
225         if (port)
226                 msg.rpc_proc = &rpcb_procedures2[RPCBPROC_SET];
227
228         return rpcb_register_call((struct sockaddr *)&rpcb_inaddr_loopback,
229                                         sizeof(rpcb_inaddr_loopback),
230                                         RPCBVERS_2, &msg, okay);
231 }
232
233 /**
234  * rpcb_getport_sync - obtain the port for an RPC service on a given host
235  * @sin: address of remote peer
236  * @prog: RPC program number to bind
237  * @vers: RPC version number to bind
238  * @prot: transport protocol to use to make this request
239  *
240  * Return value is the requested advertised port number,
241  * or a negative errno value.
242  *
243  * Called from outside the RPC client in a synchronous task context.
244  * Uses default timeout parameters specified by underlying transport.
245  *
246  * XXX: Needs to support IPv6
247  */
248 int rpcb_getport_sync(struct sockaddr_in *sin, u32 prog, u32 vers, int prot)
249 {
250         struct rpcbind_args map = {
251                 .r_prog         = prog,
252                 .r_vers         = vers,
253                 .r_prot         = prot,
254                 .r_port         = 0,
255         };
256         struct rpc_message msg = {
257                 .rpc_proc       = &rpcb_procedures2[RPCBPROC_GETPORT],
258                 .rpc_argp       = &map,
259                 .rpc_resp       = &map.r_port,
260         };
261         struct rpc_clnt *rpcb_clnt;
262         int status;
263
264         dprintk("RPC:       %s(" NIPQUAD_FMT ", %u, %u, %d)\n",
265                 __func__, NIPQUAD(sin->sin_addr.s_addr), prog, vers, prot);
266
267         rpcb_clnt = rpcb_create(NULL, (struct sockaddr *)sin,
268                                 sizeof(*sin), prot, RPCBVERS_2);
269         if (IS_ERR(rpcb_clnt))
270                 return PTR_ERR(rpcb_clnt);
271
272         status = rpc_call_sync(rpcb_clnt, &msg, 0);
273         rpc_shutdown_client(rpcb_clnt);
274
275         if (status >= 0) {
276                 if (map.r_port != 0)
277                         return map.r_port;
278                 status = -EACCES;
279         }
280         return status;
281 }
282 EXPORT_SYMBOL_GPL(rpcb_getport_sync);
283
284 static struct rpc_task *rpcb_call_async(struct rpc_clnt *rpcb_clnt, struct rpcbind_args *map, struct rpc_procinfo *proc)
285 {
286         struct rpc_message msg = {
287                 .rpc_proc = proc,
288                 .rpc_argp = map,
289                 .rpc_resp = &map->r_port,
290         };
291         struct rpc_task_setup task_setup_data = {
292                 .rpc_client = rpcb_clnt,
293                 .rpc_message = &msg,
294                 .callback_ops = &rpcb_getport_ops,
295                 .callback_data = map,
296                 .flags = RPC_TASK_ASYNC,
297         };
298
299         return rpc_run_task(&task_setup_data);
300 }
301
302 /**
303  * rpcb_getport_async - obtain the port for a given RPC service on a given host
304  * @task: task that is waiting for portmapper request
305  *
306  * This one can be called for an ongoing RPC request, and can be used in
307  * an async (rpciod) context.
308  */
309 void rpcb_getport_async(struct rpc_task *task)
310 {
311         struct rpc_clnt *clnt = task->tk_client;
312         struct rpc_procinfo *proc;
313         u32 bind_version;
314         struct rpc_xprt *xprt = task->tk_xprt;
315         struct rpc_clnt *rpcb_clnt;
316         static struct rpcbind_args *map;
317         struct rpc_task *child;
318         struct sockaddr_storage addr;
319         struct sockaddr *sap = (struct sockaddr *)&addr;
320         size_t salen;
321         int status;
322
323         dprintk("RPC: %5u %s(%s, %u, %u, %d)\n",
324                 task->tk_pid, __func__,
325                 clnt->cl_server, clnt->cl_prog, clnt->cl_vers, xprt->prot);
326
327         /* Autobind on cloned rpc clients is discouraged */
328         BUG_ON(clnt->cl_parent != clnt);
329
330         /* Put self on the wait queue to ensure we get notified if
331          * some other task is already attempting to bind the port */
332         rpc_sleep_on(&xprt->binding, task, NULL);
333
334         if (xprt_test_and_set_binding(xprt)) {
335                 dprintk("RPC: %5u %s: waiting for another binder\n",
336                         task->tk_pid, __func__);
337                 return;
338         }
339
340         /* Someone else may have bound if we slept */
341         if (xprt_bound(xprt)) {
342                 status = 0;
343                 dprintk("RPC: %5u %s: already bound\n",
344                         task->tk_pid, __func__);
345                 goto bailout_nofree;
346         }
347
348         salen = rpc_peeraddr(clnt, sap, sizeof(addr));
349
350         /* Don't ever use rpcbind v2 for AF_INET6 requests */
351         switch (sap->sa_family) {
352         case AF_INET:
353                 proc = rpcb_next_version[xprt->bind_index].rpc_proc;
354                 bind_version = rpcb_next_version[xprt->bind_index].rpc_vers;
355                 break;
356         case AF_INET6:
357                 proc = rpcb_next_version6[xprt->bind_index].rpc_proc;
358                 bind_version = rpcb_next_version6[xprt->bind_index].rpc_vers;
359                 break;
360         default:
361                 status = -EAFNOSUPPORT;
362                 dprintk("RPC: %5u %s: bad address family\n",
363                                 task->tk_pid, __func__);
364                 goto bailout_nofree;
365         }
366         if (proc == NULL) {
367                 xprt->bind_index = 0;
368                 status = -EPFNOSUPPORT;
369                 dprintk("RPC: %5u %s: no more getport versions available\n",
370                         task->tk_pid, __func__);
371                 goto bailout_nofree;
372         }
373
374         dprintk("RPC: %5u %s: trying rpcbind version %u\n",
375                 task->tk_pid, __func__, bind_version);
376
377         rpcb_clnt = rpcb_create(clnt->cl_server, sap, salen, xprt->prot,
378                                 bind_version);
379         if (IS_ERR(rpcb_clnt)) {
380                 status = PTR_ERR(rpcb_clnt);
381                 dprintk("RPC: %5u %s: rpcb_create failed, error %ld\n",
382                         task->tk_pid, __func__, PTR_ERR(rpcb_clnt));
383                 goto bailout_nofree;
384         }
385
386         map = kzalloc(sizeof(struct rpcbind_args), GFP_ATOMIC);
387         if (!map) {
388                 status = -ENOMEM;
389                 dprintk("RPC: %5u %s: no memory available\n",
390                         task->tk_pid, __func__);
391                 goto bailout_nofree;
392         }
393         map->r_prog = clnt->cl_prog;
394         map->r_vers = clnt->cl_vers;
395         map->r_prot = xprt->prot;
396         map->r_port = 0;
397         map->r_xprt = xprt_get(xprt);
398         map->r_netid = rpc_peeraddr2str(clnt, RPC_DISPLAY_NETID);
399         map->r_addr = rpc_peeraddr2str(rpcb_clnt, RPC_DISPLAY_UNIVERSAL_ADDR);
400         map->r_owner = RPCB_OWNER_STRING;       /* ignored for GETADDR */
401         map->r_status = -EIO;
402
403         child = rpcb_call_async(rpcb_clnt, map, proc);
404         rpc_release_client(rpcb_clnt);
405         if (IS_ERR(child)) {
406                 /* rpcb_map_release() has freed the arguments */
407                 dprintk("RPC: %5u %s: rpc_run_task failed\n",
408                         task->tk_pid, __func__);
409                 return;
410         }
411         rpc_put_task(child);
412
413         task->tk_xprt->stat.bind_count++;
414         return;
415
416 bailout_nofree:
417         rpcb_wake_rpcbind_waiters(xprt, status);
418         task->tk_status = status;
419 }
420 EXPORT_SYMBOL_GPL(rpcb_getport_async);
421
422 /*
423  * Rpcbind child task calls this callback via tk_exit.
424  */
425 static void rpcb_getport_done(struct rpc_task *child, void *data)
426 {
427         struct rpcbind_args *map = data;
428         struct rpc_xprt *xprt = map->r_xprt;
429         int status = child->tk_status;
430
431         /* Garbage reply: retry with a lesser rpcbind version */
432         if (status == -EIO)
433                 status = -EPROTONOSUPPORT;
434
435         /* rpcbind server doesn't support this rpcbind protocol version */
436         if (status == -EPROTONOSUPPORT)
437                 xprt->bind_index++;
438
439         if (status < 0) {
440                 /* rpcbind server not available on remote host? */
441                 xprt->ops->set_port(xprt, 0);
442         } else if (map->r_port == 0) {
443                 /* Requested RPC service wasn't registered on remote host */
444                 xprt->ops->set_port(xprt, 0);
445                 status = -EACCES;
446         } else {
447                 /* Succeeded */
448                 xprt->ops->set_port(xprt, map->r_port);
449                 xprt_set_bound(xprt);
450                 status = 0;
451         }
452
453         dprintk("RPC: %5u rpcb_getport_done(status %d, port %u)\n",
454                         child->tk_pid, status, map->r_port);
455
456         map->r_status = status;
457 }
458
459 /*
460  * XDR functions for rpcbind
461  */
462
463 static int rpcb_encode_mapping(struct rpc_rqst *req, __be32 *p,
464                                struct rpcbind_args *rpcb)
465 {
466         dprintk("RPC:       rpcb_encode_mapping(%u, %u, %d, %u)\n",
467                         rpcb->r_prog, rpcb->r_vers, rpcb->r_prot, rpcb->r_port);
468         *p++ = htonl(rpcb->r_prog);
469         *p++ = htonl(rpcb->r_vers);
470         *p++ = htonl(rpcb->r_prot);
471         *p++ = htonl(rpcb->r_port);
472
473         req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
474         return 0;
475 }
476
477 static int rpcb_decode_getport(struct rpc_rqst *req, __be32 *p,
478                                unsigned short *portp)
479 {
480         *portp = (unsigned short) ntohl(*p++);
481         dprintk("RPC:       rpcb_decode_getport result %u\n",
482                         *portp);
483         return 0;
484 }
485
486 static int rpcb_decode_set(struct rpc_rqst *req, __be32 *p,
487                            unsigned int *boolp)
488 {
489         *boolp = (unsigned int) ntohl(*p++);
490         dprintk("RPC:       rpcb_decode_set: call %s\n",
491                         (*boolp ? "succeeded" : "failed"));
492         return 0;
493 }
494
495 static int rpcb_encode_getaddr(struct rpc_rqst *req, __be32 *p,
496                                struct rpcbind_args *rpcb)
497 {
498         dprintk("RPC:       rpcb_encode_getaddr(%u, %u, %s)\n",
499                         rpcb->r_prog, rpcb->r_vers, rpcb->r_addr);
500         *p++ = htonl(rpcb->r_prog);
501         *p++ = htonl(rpcb->r_vers);
502
503         p = xdr_encode_string(p, rpcb->r_netid);
504         p = xdr_encode_string(p, rpcb->r_addr);
505         p = xdr_encode_string(p, rpcb->r_owner);
506
507         req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
508
509         return 0;
510 }
511
512 static int rpcb_decode_getaddr(struct rpc_rqst *req, __be32 *p,
513                                unsigned short *portp)
514 {
515         char *addr;
516         u32 addr_len;
517         int c, i, f, first, val;
518
519         *portp = 0;
520         addr_len = ntohl(*p++);
521
522         /*
523          * Simple sanity check.  The smallest possible universal
524          * address is an IPv4 address string containing 11 bytes.
525          */
526         if (addr_len < 11 || addr_len > RPCBIND_MAXUADDRLEN)
527                 goto out_err;
528
529         /*
530          * Start at the end and walk backwards until the first dot
531          * is encountered.  When the second dot is found, we have
532          * both parts of the port number.
533          */
534         addr = (char *)p;
535         val = 0;
536         first = 1;
537         f = 1;
538         for (i = addr_len - 1; i > 0; i--) {
539                 c = addr[i];
540                 if (c >= '0' && c <= '9') {
541                         val += (c - '0') * f;
542                         f *= 10;
543                 } else if (c == '.') {
544                         if (first) {
545                                 *portp = val;
546                                 val = first = 0;
547                                 f = 1;
548                         } else {
549                                 *portp |= (val << 8);
550                                 break;
551                         }
552                 }
553         }
554
555         /*
556          * Simple sanity check.  If we never saw a dot in the reply,
557          * then this was probably just garbage.
558          */
559         if (first)
560                 goto out_err;
561
562         dprintk("RPC:       rpcb_decode_getaddr port=%u\n", *portp);
563         return 0;
564
565 out_err:
566         dprintk("RPC:       rpcbind server returned malformed reply\n");
567         return -EIO;
568 }
569
570 #define RPCB_program_sz         (1u)
571 #define RPCB_version_sz         (1u)
572 #define RPCB_protocol_sz        (1u)
573 #define RPCB_port_sz            (1u)
574 #define RPCB_boolean_sz         (1u)
575
576 #define RPCB_netid_sz           (1+XDR_QUADLEN(RPCBIND_MAXNETIDLEN))
577 #define RPCB_addr_sz            (1+XDR_QUADLEN(RPCBIND_MAXUADDRLEN))
578 #define RPCB_ownerstring_sz     (1+XDR_QUADLEN(RPCB_MAXOWNERLEN))
579
580 #define RPCB_mappingargs_sz     RPCB_program_sz+RPCB_version_sz+        \
581                                 RPCB_protocol_sz+RPCB_port_sz
582 #define RPCB_getaddrargs_sz     RPCB_program_sz+RPCB_version_sz+        \
583                                 RPCB_netid_sz+RPCB_addr_sz+             \
584                                 RPCB_ownerstring_sz
585
586 #define RPCB_setres_sz          RPCB_boolean_sz
587 #define RPCB_getportres_sz      RPCB_port_sz
588
589 /*
590  * Note that RFC 1833 does not put any size restrictions on the
591  * address string returned by the remote rpcbind database.
592  */
593 #define RPCB_getaddrres_sz      RPCB_addr_sz
594
595 #define PROC(proc, argtype, restype)                                    \
596         [RPCBPROC_##proc] = {                                           \
597                 .p_proc         = RPCBPROC_##proc,                      \
598                 .p_encode       = (kxdrproc_t) rpcb_encode_##argtype,   \
599                 .p_decode       = (kxdrproc_t) rpcb_decode_##restype,   \
600                 .p_arglen       = RPCB_##argtype##args_sz,              \
601                 .p_replen       = RPCB_##restype##res_sz,               \
602                 .p_statidx      = RPCBPROC_##proc,                      \
603                 .p_timer        = 0,                                    \
604                 .p_name         = #proc,                                \
605         }
606
607 /*
608  * Not all rpcbind procedures described in RFC 1833 are implemented
609  * since the Linux kernel RPC code requires only these.
610  */
611 static struct rpc_procinfo rpcb_procedures2[] = {
612         PROC(SET,               mapping,        set),
613         PROC(UNSET,             mapping,        set),
614         PROC(GETPORT,           mapping,        getport),
615 };
616
617 static struct rpc_procinfo rpcb_procedures3[] = {
618         PROC(SET,               getaddr,        set),
619         PROC(UNSET,             getaddr,        set),
620         PROC(GETADDR,           getaddr,        getaddr),
621 };
622
623 static struct rpc_procinfo rpcb_procedures4[] = {
624         PROC(SET,               getaddr,        set),
625         PROC(UNSET,             getaddr,        set),
626         PROC(GETADDR,           getaddr,        getaddr),
627         PROC(GETVERSADDR,       getaddr,        getaddr),
628 };
629
630 static struct rpcb_info rpcb_next_version[] = {
631         {
632                 .rpc_vers       = RPCBVERS_2,
633                 .rpc_proc       = &rpcb_procedures2[RPCBPROC_GETPORT],
634         },
635         {
636                 .rpc_proc       = NULL,
637         },
638 };
639
640 static struct rpcb_info rpcb_next_version6[] = {
641         {
642                 .rpc_vers       = RPCBVERS_4,
643                 .rpc_proc       = &rpcb_procedures4[RPCBPROC_GETADDR],
644         },
645         {
646                 .rpc_vers       = RPCBVERS_3,
647                 .rpc_proc       = &rpcb_procedures3[RPCBPROC_GETADDR],
648         },
649         {
650                 .rpc_proc       = NULL,
651         },
652 };
653
654 static struct rpc_version rpcb_version2 = {
655         .number         = RPCBVERS_2,
656         .nrprocs        = RPCB_HIGHPROC_2,
657         .procs          = rpcb_procedures2
658 };
659
660 static struct rpc_version rpcb_version3 = {
661         .number         = RPCBVERS_3,
662         .nrprocs        = RPCB_HIGHPROC_3,
663         .procs          = rpcb_procedures3
664 };
665
666 static struct rpc_version rpcb_version4 = {
667         .number         = RPCBVERS_4,
668         .nrprocs        = RPCB_HIGHPROC_4,
669         .procs          = rpcb_procedures4
670 };
671
672 static struct rpc_version *rpcb_version[] = {
673         NULL,
674         NULL,
675         &rpcb_version2,
676         &rpcb_version3,
677         &rpcb_version4
678 };
679
680 static struct rpc_stat rpcb_stats;
681
682 static struct rpc_program rpcb_program = {
683         .name           = "rpcbind",
684         .number         = RPCBIND_PROGRAM,
685         .nrvers         = ARRAY_SIZE(rpcb_version),
686         .version        = rpcb_version,
687         .stats          = &rpcb_stats,
688 };