diff options
Diffstat (limited to 'net/sunrpc/rpcb_clnt.c')
-rw-r--r-- | net/sunrpc/rpcb_clnt.c | 420 |
1 files changed, 280 insertions, 140 deletions
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c index beee6da33035..830faf4d9997 100644 --- a/net/sunrpc/rpcb_clnt.c +++ b/net/sunrpc/rpcb_clnt.c | |||
@@ -75,6 +75,37 @@ enum { | |||
75 | #define RPCB_OWNER_STRING "0" | 75 | #define RPCB_OWNER_STRING "0" |
76 | #define RPCB_MAXOWNERLEN sizeof(RPCB_OWNER_STRING) | 76 | #define RPCB_MAXOWNERLEN sizeof(RPCB_OWNER_STRING) |
77 | 77 | ||
78 | /* | ||
79 | * XDR data type sizes | ||
80 | */ | ||
81 | #define RPCB_program_sz (1) | ||
82 | #define RPCB_version_sz (1) | ||
83 | #define RPCB_protocol_sz (1) | ||
84 | #define RPCB_port_sz (1) | ||
85 | #define RPCB_boolean_sz (1) | ||
86 | |||
87 | #define RPCB_netid_sz (1 + XDR_QUADLEN(RPCBIND_MAXNETIDLEN)) | ||
88 | #define RPCB_addr_sz (1 + XDR_QUADLEN(RPCBIND_MAXUADDRLEN)) | ||
89 | #define RPCB_ownerstring_sz (1 + XDR_QUADLEN(RPCB_MAXOWNERLEN)) | ||
90 | |||
91 | /* | ||
92 | * XDR argument and result sizes | ||
93 | */ | ||
94 | #define RPCB_mappingargs_sz (RPCB_program_sz + RPCB_version_sz + \ | ||
95 | RPCB_protocol_sz + RPCB_port_sz) | ||
96 | #define RPCB_getaddrargs_sz (RPCB_program_sz + RPCB_version_sz + \ | ||
97 | RPCB_netid_sz + RPCB_addr_sz + \ | ||
98 | RPCB_ownerstring_sz) | ||
99 | |||
100 | #define RPCB_getportres_sz RPCB_port_sz | ||
101 | #define RPCB_setres_sz RPCB_boolean_sz | ||
102 | |||
103 | /* | ||
104 | * Note that RFC 1833 does not put any size restrictions on the | ||
105 | * address string returned by the remote rpcbind database. | ||
106 | */ | ||
107 | #define RPCB_getaddrres_sz RPCB_addr_sz | ||
108 | |||
78 | static void rpcb_getport_done(struct rpc_task *, void *); | 109 | static void rpcb_getport_done(struct rpc_task *, void *); |
79 | static void rpcb_map_release(void *data); | 110 | static void rpcb_map_release(void *data); |
80 | static struct rpc_program rpcb_program; | 111 | static struct rpc_program rpcb_program; |
@@ -122,6 +153,7 @@ static void rpcb_map_release(void *data) | |||
122 | 153 | ||
123 | rpcb_wake_rpcbind_waiters(map->r_xprt, map->r_status); | 154 | rpcb_wake_rpcbind_waiters(map->r_xprt, map->r_status); |
124 | xprt_put(map->r_xprt); | 155 | xprt_put(map->r_xprt); |
156 | kfree(map->r_addr); | ||
125 | kfree(map); | 157 | kfree(map); |
126 | } | 158 | } |
127 | 159 | ||
@@ -268,12 +300,9 @@ static int rpcb_register_inet4(const struct sockaddr *sap, | |||
268 | const struct sockaddr_in *sin = (const struct sockaddr_in *)sap; | 300 | const struct sockaddr_in *sin = (const struct sockaddr_in *)sap; |
269 | struct rpcbind_args *map = msg->rpc_argp; | 301 | struct rpcbind_args *map = msg->rpc_argp; |
270 | unsigned short port = ntohs(sin->sin_port); | 302 | unsigned short port = ntohs(sin->sin_port); |
271 | char buf[32]; | 303 | int result; |
272 | 304 | ||
273 | /* Construct AF_INET universal address */ | 305 | map->r_addr = rpc_sockaddr2uaddr(sap); |
274 | snprintf(buf, sizeof(buf), "%pI4.%u.%u", | ||
275 | &sin->sin_addr.s_addr, port >> 8, port & 0xff); | ||
276 | map->r_addr = buf; | ||
277 | 306 | ||
278 | dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with " | 307 | dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with " |
279 | "local rpcbind\n", (port ? "" : "un"), | 308 | "local rpcbind\n", (port ? "" : "un"), |
@@ -284,7 +313,9 @@ static int rpcb_register_inet4(const struct sockaddr *sap, | |||
284 | if (port) | 313 | if (port) |
285 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; | 314 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; |
286 | 315 | ||
287 | return rpcb_register_call(RPCBVERS_4, msg); | 316 | result = rpcb_register_call(RPCBVERS_4, msg); |
317 | kfree(map->r_addr); | ||
318 | return result; | ||
288 | } | 319 | } |
289 | 320 | ||
290 | /* | 321 | /* |
@@ -296,16 +327,9 @@ static int rpcb_register_inet6(const struct sockaddr *sap, | |||
296 | const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)sap; | 327 | const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)sap; |
297 | struct rpcbind_args *map = msg->rpc_argp; | 328 | struct rpcbind_args *map = msg->rpc_argp; |
298 | unsigned short port = ntohs(sin6->sin6_port); | 329 | unsigned short port = ntohs(sin6->sin6_port); |
299 | char buf[64]; | 330 | int result; |
300 | 331 | ||
301 | /* Construct AF_INET6 universal address */ | 332 | map->r_addr = rpc_sockaddr2uaddr(sap); |
302 | if (ipv6_addr_any(&sin6->sin6_addr)) | ||
303 | snprintf(buf, sizeof(buf), "::.%u.%u", | ||
304 | port >> 8, port & 0xff); | ||
305 | else | ||
306 | snprintf(buf, sizeof(buf), "%pI6.%u.%u", | ||
307 | &sin6->sin6_addr, port >> 8, port & 0xff); | ||
308 | map->r_addr = buf; | ||
309 | 333 | ||
310 | dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with " | 334 | dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with " |
311 | "local rpcbind\n", (port ? "" : "un"), | 335 | "local rpcbind\n", (port ? "" : "un"), |
@@ -316,7 +340,9 @@ static int rpcb_register_inet6(const struct sockaddr *sap, | |||
316 | if (port) | 340 | if (port) |
317 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; | 341 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; |
318 | 342 | ||
319 | return rpcb_register_call(RPCBVERS_4, msg); | 343 | result = rpcb_register_call(RPCBVERS_4, msg); |
344 | kfree(map->r_addr); | ||
345 | return result; | ||
320 | } | 346 | } |
321 | 347 | ||
322 | static int rpcb_unregister_all_protofamilies(struct rpc_message *msg) | 348 | static int rpcb_unregister_all_protofamilies(struct rpc_message *msg) |
@@ -428,7 +454,7 @@ int rpcb_getport_sync(struct sockaddr_in *sin, u32 prog, u32 vers, int prot) | |||
428 | struct rpc_message msg = { | 454 | struct rpc_message msg = { |
429 | .rpc_proc = &rpcb_procedures2[RPCBPROC_GETPORT], | 455 | .rpc_proc = &rpcb_procedures2[RPCBPROC_GETPORT], |
430 | .rpc_argp = &map, | 456 | .rpc_argp = &map, |
431 | .rpc_resp = &map.r_port, | 457 | .rpc_resp = &map, |
432 | }; | 458 | }; |
433 | struct rpc_clnt *rpcb_clnt; | 459 | struct rpc_clnt *rpcb_clnt; |
434 | int status; | 460 | int status; |
@@ -458,7 +484,7 @@ static struct rpc_task *rpcb_call_async(struct rpc_clnt *rpcb_clnt, struct rpcbi | |||
458 | struct rpc_message msg = { | 484 | struct rpc_message msg = { |
459 | .rpc_proc = proc, | 485 | .rpc_proc = proc, |
460 | .rpc_argp = map, | 486 | .rpc_argp = map, |
461 | .rpc_resp = &map->r_port, | 487 | .rpc_resp = map, |
462 | }; | 488 | }; |
463 | struct rpc_task_setup task_setup_data = { | 489 | struct rpc_task_setup task_setup_data = { |
464 | .rpc_client = rpcb_clnt, | 490 | .rpc_client = rpcb_clnt, |
@@ -539,6 +565,7 @@ void rpcb_getport_async(struct rpc_task *task) | |||
539 | goto bailout_nofree; | 565 | goto bailout_nofree; |
540 | } | 566 | } |
541 | 567 | ||
568 | /* Parent transport's destination address */ | ||
542 | salen = rpc_peeraddr(clnt, sap, sizeof(addr)); | 569 | salen = rpc_peeraddr(clnt, sap, sizeof(addr)); |
543 | 570 | ||
544 | /* Don't ever use rpcbind v2 for AF_INET6 requests */ | 571 | /* Don't ever use rpcbind v2 for AF_INET6 requests */ |
@@ -589,11 +616,22 @@ void rpcb_getport_async(struct rpc_task *task) | |||
589 | map->r_prot = xprt->prot; | 616 | map->r_prot = xprt->prot; |
590 | map->r_port = 0; | 617 | map->r_port = 0; |
591 | map->r_xprt = xprt_get(xprt); | 618 | map->r_xprt = xprt_get(xprt); |
592 | map->r_netid = rpc_peeraddr2str(clnt, RPC_DISPLAY_NETID); | ||
593 | map->r_addr = rpc_peeraddr2str(rpcb_clnt, RPC_DISPLAY_UNIVERSAL_ADDR); | ||
594 | map->r_owner = ""; | ||
595 | map->r_status = -EIO; | 619 | map->r_status = -EIO; |
596 | 620 | ||
621 | switch (bind_version) { | ||
622 | case RPCBVERS_4: | ||
623 | case RPCBVERS_3: | ||
624 | map->r_netid = rpc_peeraddr2str(clnt, RPC_DISPLAY_NETID); | ||
625 | map->r_addr = rpc_sockaddr2uaddr(sap); | ||
626 | map->r_owner = ""; | ||
627 | break; | ||
628 | case RPCBVERS_2: | ||
629 | map->r_addr = NULL; | ||
630 | break; | ||
631 | default: | ||
632 | BUG(); | ||
633 | } | ||
634 | |||
597 | child = rpcb_call_async(rpcb_clnt, map, proc); | 635 | child = rpcb_call_async(rpcb_clnt, map, proc); |
598 | rpc_release_client(rpcb_clnt); | 636 | rpc_release_client(rpcb_clnt); |
599 | if (IS_ERR(child)) { | 637 | if (IS_ERR(child)) { |
@@ -656,176 +694,278 @@ static void rpcb_getport_done(struct rpc_task *child, void *data) | |||
656 | * XDR functions for rpcbind | 694 | * XDR functions for rpcbind |
657 | */ | 695 | */ |
658 | 696 | ||
659 | static int rpcb_encode_mapping(struct rpc_rqst *req, __be32 *p, | 697 | static int rpcb_enc_mapping(struct rpc_rqst *req, __be32 *p, |
660 | struct rpcbind_args *rpcb) | 698 | const struct rpcbind_args *rpcb) |
661 | { | 699 | { |
662 | dprintk("RPC: encoding rpcb request (%u, %u, %d, %u)\n", | 700 | struct rpc_task *task = req->rq_task; |
701 | struct xdr_stream xdr; | ||
702 | |||
703 | dprintk("RPC: %5u encoding PMAP_%s call (%u, %u, %d, %u)\n", | ||
704 | task->tk_pid, task->tk_msg.rpc_proc->p_name, | ||
663 | rpcb->r_prog, rpcb->r_vers, rpcb->r_prot, rpcb->r_port); | 705 | rpcb->r_prog, rpcb->r_vers, rpcb->r_prot, rpcb->r_port); |
706 | |||
707 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | ||
708 | |||
709 | p = xdr_reserve_space(&xdr, sizeof(__be32) * RPCB_mappingargs_sz); | ||
710 | if (unlikely(p == NULL)) | ||
711 | return -EIO; | ||
712 | |||
664 | *p++ = htonl(rpcb->r_prog); | 713 | *p++ = htonl(rpcb->r_prog); |
665 | *p++ = htonl(rpcb->r_vers); | 714 | *p++ = htonl(rpcb->r_vers); |
666 | *p++ = htonl(rpcb->r_prot); | 715 | *p++ = htonl(rpcb->r_prot); |
667 | *p++ = htonl(rpcb->r_port); | 716 | *p = htonl(rpcb->r_port); |
668 | 717 | ||
669 | req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); | ||
670 | return 0; | 718 | return 0; |
671 | } | 719 | } |
672 | 720 | ||
673 | static int rpcb_decode_getport(struct rpc_rqst *req, __be32 *p, | 721 | static int rpcb_dec_getport(struct rpc_rqst *req, __be32 *p, |
674 | unsigned short *portp) | 722 | struct rpcbind_args *rpcb) |
675 | { | 723 | { |
676 | *portp = (unsigned short) ntohl(*p++); | 724 | struct rpc_task *task = req->rq_task; |
677 | dprintk("RPC: rpcb getport result: %u\n", | 725 | struct xdr_stream xdr; |
678 | *portp); | 726 | unsigned long port; |
727 | |||
728 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); | ||
729 | |||
730 | rpcb->r_port = 0; | ||
731 | |||
732 | p = xdr_inline_decode(&xdr, sizeof(__be32)); | ||
733 | if (unlikely(p == NULL)) | ||
734 | return -EIO; | ||
735 | |||
736 | port = ntohl(*p); | ||
737 | dprintk("RPC: %5u PMAP_%s result: %lu\n", task->tk_pid, | ||
738 | task->tk_msg.rpc_proc->p_name, port); | ||
739 | if (unlikely(port > USHORT_MAX)) | ||
740 | return -EIO; | ||
741 | |||
742 | rpcb->r_port = port; | ||
679 | return 0; | 743 | return 0; |
680 | } | 744 | } |
681 | 745 | ||
682 | static int rpcb_decode_set(struct rpc_rqst *req, __be32 *p, | 746 | static int rpcb_dec_set(struct rpc_rqst *req, __be32 *p, |
683 | unsigned int *boolp) | 747 | unsigned int *boolp) |
684 | { | 748 | { |
685 | *boolp = (unsigned int) ntohl(*p++); | 749 | struct rpc_task *task = req->rq_task; |
686 | dprintk("RPC: rpcb set/unset call %s\n", | 750 | struct xdr_stream xdr; |
751 | |||
752 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); | ||
753 | |||
754 | p = xdr_inline_decode(&xdr, sizeof(__be32)); | ||
755 | if (unlikely(p == NULL)) | ||
756 | return -EIO; | ||
757 | |||
758 | *boolp = 0; | ||
759 | if (*p) | ||
760 | *boolp = 1; | ||
761 | |||
762 | dprintk("RPC: %5u RPCB_%s call %s\n", | ||
763 | task->tk_pid, task->tk_msg.rpc_proc->p_name, | ||
687 | (*boolp ? "succeeded" : "failed")); | 764 | (*boolp ? "succeeded" : "failed")); |
688 | return 0; | 765 | return 0; |
689 | } | 766 | } |
690 | 767 | ||
691 | static int rpcb_encode_getaddr(struct rpc_rqst *req, __be32 *p, | 768 | static int encode_rpcb_string(struct xdr_stream *xdr, const char *string, |
692 | struct rpcbind_args *rpcb) | 769 | const u32 maxstrlen) |
693 | { | 770 | { |
694 | dprintk("RPC: encoding rpcb request (%u, %u, %s)\n", | 771 | u32 len; |
695 | rpcb->r_prog, rpcb->r_vers, rpcb->r_addr); | 772 | __be32 *p; |
696 | *p++ = htonl(rpcb->r_prog); | ||
697 | *p++ = htonl(rpcb->r_vers); | ||
698 | 773 | ||
699 | p = xdr_encode_string(p, rpcb->r_netid); | 774 | if (unlikely(string == NULL)) |
700 | p = xdr_encode_string(p, rpcb->r_addr); | 775 | return -EIO; |
701 | p = xdr_encode_string(p, rpcb->r_owner); | 776 | len = strlen(string); |
777 | if (unlikely(len > maxstrlen)) | ||
778 | return -EIO; | ||
702 | 779 | ||
703 | req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); | 780 | p = xdr_reserve_space(xdr, sizeof(__be32) + len); |
781 | if (unlikely(p == NULL)) | ||
782 | return -EIO; | ||
783 | xdr_encode_opaque(p, string, len); | ||
704 | 784 | ||
705 | return 0; | 785 | return 0; |
706 | } | 786 | } |
707 | 787 | ||
708 | static int rpcb_decode_getaddr(struct rpc_rqst *req, __be32 *p, | 788 | static int rpcb_enc_getaddr(struct rpc_rqst *req, __be32 *p, |
709 | unsigned short *portp) | 789 | const struct rpcbind_args *rpcb) |
710 | { | 790 | { |
711 | char *addr; | 791 | struct rpc_task *task = req->rq_task; |
712 | u32 addr_len; | 792 | struct xdr_stream xdr; |
713 | int c, i, f, first, val; | ||
714 | 793 | ||
715 | *portp = 0; | 794 | dprintk("RPC: %5u encoding RPCB_%s call (%u, %u, '%s', '%s')\n", |
716 | addr_len = ntohl(*p++); | 795 | task->tk_pid, task->tk_msg.rpc_proc->p_name, |
796 | rpcb->r_prog, rpcb->r_vers, | ||
797 | rpcb->r_netid, rpcb->r_addr); | ||
717 | 798 | ||
718 | if (addr_len == 0) { | 799 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
719 | dprintk("RPC: rpcb_decode_getaddr: " | ||
720 | "service is not registered\n"); | ||
721 | return 0; | ||
722 | } | ||
723 | 800 | ||
724 | /* | 801 | p = xdr_reserve_space(&xdr, |
725 | * Simple sanity check. | 802 | sizeof(__be32) * (RPCB_program_sz + RPCB_version_sz)); |
726 | */ | 803 | if (unlikely(p == NULL)) |
727 | if (addr_len > RPCBIND_MAXUADDRLEN) | 804 | return -EIO; |
728 | goto out_err; | 805 | *p++ = htonl(rpcb->r_prog); |
729 | 806 | *p = htonl(rpcb->r_vers); | |
730 | /* | ||
731 | * Start at the end and walk backwards until the first dot | ||
732 | * is encountered. When the second dot is found, we have | ||
733 | * both parts of the port number. | ||
734 | */ | ||
735 | addr = (char *)p; | ||
736 | val = 0; | ||
737 | first = 1; | ||
738 | f = 1; | ||
739 | for (i = addr_len - 1; i > 0; i--) { | ||
740 | c = addr[i]; | ||
741 | if (c >= '0' && c <= '9') { | ||
742 | val += (c - '0') * f; | ||
743 | f *= 10; | ||
744 | } else if (c == '.') { | ||
745 | if (first) { | ||
746 | *portp = val; | ||
747 | val = first = 0; | ||
748 | f = 1; | ||
749 | } else { | ||
750 | *portp |= (val << 8); | ||
751 | break; | ||
752 | } | ||
753 | } | ||
754 | } | ||
755 | 807 | ||
756 | /* | 808 | if (encode_rpcb_string(&xdr, rpcb->r_netid, RPCBIND_MAXNETIDLEN)) |
757 | * Simple sanity check. If we never saw a dot in the reply, | 809 | return -EIO; |
758 | * then this was probably just garbage. | 810 | if (encode_rpcb_string(&xdr, rpcb->r_addr, RPCBIND_MAXUADDRLEN)) |
759 | */ | 811 | return -EIO; |
760 | if (first) | 812 | if (encode_rpcb_string(&xdr, rpcb->r_owner, RPCB_MAXOWNERLEN)) |
761 | goto out_err; | 813 | return -EIO; |
762 | 814 | ||
763 | dprintk("RPC: rpcb_decode_getaddr port=%u\n", *portp); | ||
764 | return 0; | 815 | return 0; |
765 | |||
766 | out_err: | ||
767 | dprintk("RPC: rpcbind server returned malformed reply\n"); | ||
768 | return -EIO; | ||
769 | } | 816 | } |
770 | 817 | ||
771 | #define RPCB_program_sz (1u) | 818 | static int rpcb_dec_getaddr(struct rpc_rqst *req, __be32 *p, |
772 | #define RPCB_version_sz (1u) | 819 | struct rpcbind_args *rpcb) |
773 | #define RPCB_protocol_sz (1u) | 820 | { |
774 | #define RPCB_port_sz (1u) | 821 | struct sockaddr_storage address; |
775 | #define RPCB_boolean_sz (1u) | 822 | struct sockaddr *sap = (struct sockaddr *)&address; |
823 | struct rpc_task *task = req->rq_task; | ||
824 | struct xdr_stream xdr; | ||
825 | u32 len; | ||
776 | 826 | ||
777 | #define RPCB_netid_sz (1+XDR_QUADLEN(RPCBIND_MAXNETIDLEN)) | 827 | rpcb->r_port = 0; |
778 | #define RPCB_addr_sz (1+XDR_QUADLEN(RPCBIND_MAXUADDRLEN)) | ||
779 | #define RPCB_ownerstring_sz (1+XDR_QUADLEN(RPCB_MAXOWNERLEN)) | ||
780 | 828 | ||
781 | #define RPCB_mappingargs_sz RPCB_program_sz+RPCB_version_sz+ \ | 829 | xdr_init_decode(&xdr, &req->rq_rcv_buf, p); |
782 | RPCB_protocol_sz+RPCB_port_sz | ||
783 | #define RPCB_getaddrargs_sz RPCB_program_sz+RPCB_version_sz+ \ | ||
784 | RPCB_netid_sz+RPCB_addr_sz+ \ | ||
785 | RPCB_ownerstring_sz | ||
786 | 830 | ||
787 | #define RPCB_setres_sz RPCB_boolean_sz | 831 | p = xdr_inline_decode(&xdr, sizeof(__be32)); |
788 | #define RPCB_getportres_sz RPCB_port_sz | 832 | if (unlikely(p == NULL)) |
789 | 833 | goto out_fail; | |
790 | /* | 834 | len = ntohl(*p); |
791 | * Note that RFC 1833 does not put any size restrictions on the | ||
792 | * address string returned by the remote rpcbind database. | ||
793 | */ | ||
794 | #define RPCB_getaddrres_sz RPCB_addr_sz | ||
795 | 835 | ||
796 | #define PROC(proc, argtype, restype) \ | 836 | /* |
797 | [RPCBPROC_##proc] = { \ | 837 | * If the returned universal address is a null string, |
798 | .p_proc = RPCBPROC_##proc, \ | 838 | * the requested RPC service was not registered. |
799 | .p_encode = (kxdrproc_t) rpcb_encode_##argtype, \ | 839 | */ |
800 | .p_decode = (kxdrproc_t) rpcb_decode_##restype, \ | 840 | if (len == 0) { |
801 | .p_arglen = RPCB_##argtype##args_sz, \ | 841 | dprintk("RPC: %5u RPCB reply: program not registered\n", |
802 | .p_replen = RPCB_##restype##res_sz, \ | 842 | task->tk_pid); |
803 | .p_statidx = RPCBPROC_##proc, \ | 843 | return 0; |
804 | .p_timer = 0, \ | ||
805 | .p_name = #proc, \ | ||
806 | } | 844 | } |
807 | 845 | ||
846 | if (unlikely(len > RPCBIND_MAXUADDRLEN)) | ||
847 | goto out_fail; | ||
848 | |||
849 | p = xdr_inline_decode(&xdr, len); | ||
850 | if (unlikely(p == NULL)) | ||
851 | goto out_fail; | ||
852 | dprintk("RPC: %5u RPCB_%s reply: %s\n", task->tk_pid, | ||
853 | task->tk_msg.rpc_proc->p_name, (char *)p); | ||
854 | |||
855 | if (rpc_uaddr2sockaddr((char *)p, len, sap, sizeof(address)) == 0) | ||
856 | goto out_fail; | ||
857 | rpcb->r_port = rpc_get_port(sap); | ||
858 | |||
859 | return 0; | ||
860 | |||
861 | out_fail: | ||
862 | dprintk("RPC: %5u malformed RPCB_%s reply\n", | ||
863 | task->tk_pid, task->tk_msg.rpc_proc->p_name); | ||
864 | return -EIO; | ||
865 | } | ||
866 | |||
808 | /* | 867 | /* |
809 | * Not all rpcbind procedures described in RFC 1833 are implemented | 868 | * Not all rpcbind procedures described in RFC 1833 are implemented |
810 | * since the Linux kernel RPC code requires only these. | 869 | * since the Linux kernel RPC code requires only these. |
811 | */ | 870 | */ |
871 | |||
812 | static struct rpc_procinfo rpcb_procedures2[] = { | 872 | static struct rpc_procinfo rpcb_procedures2[] = { |
813 | PROC(SET, mapping, set), | 873 | [RPCBPROC_SET] = { |
814 | PROC(UNSET, mapping, set), | 874 | .p_proc = RPCBPROC_SET, |
815 | PROC(GETPORT, mapping, getport), | 875 | .p_encode = (kxdrproc_t)rpcb_enc_mapping, |
876 | .p_decode = (kxdrproc_t)rpcb_dec_set, | ||
877 | .p_arglen = RPCB_mappingargs_sz, | ||
878 | .p_replen = RPCB_setres_sz, | ||
879 | .p_statidx = RPCBPROC_SET, | ||
880 | .p_timer = 0, | ||
881 | .p_name = "SET", | ||
882 | }, | ||
883 | [RPCBPROC_UNSET] = { | ||
884 | .p_proc = RPCBPROC_UNSET, | ||
885 | .p_encode = (kxdrproc_t)rpcb_enc_mapping, | ||
886 | .p_decode = (kxdrproc_t)rpcb_dec_set, | ||
887 | .p_arglen = RPCB_mappingargs_sz, | ||
888 | .p_replen = RPCB_setres_sz, | ||
889 | .p_statidx = RPCBPROC_UNSET, | ||
890 | .p_timer = 0, | ||
891 | .p_name = "UNSET", | ||
892 | }, | ||
893 | [RPCBPROC_GETPORT] = { | ||
894 | .p_proc = RPCBPROC_GETPORT, | ||
895 | .p_encode = (kxdrproc_t)rpcb_enc_mapping, | ||
896 | .p_decode = (kxdrproc_t)rpcb_dec_getport, | ||
897 | .p_arglen = RPCB_mappingargs_sz, | ||
898 | .p_replen = RPCB_getportres_sz, | ||
899 | .p_statidx = RPCBPROC_GETPORT, | ||
900 | .p_timer = 0, | ||
901 | .p_name = "GETPORT", | ||
902 | }, | ||
816 | }; | 903 | }; |
817 | 904 | ||
818 | static struct rpc_procinfo rpcb_procedures3[] = { | 905 | static struct rpc_procinfo rpcb_procedures3[] = { |
819 | PROC(SET, getaddr, set), | 906 | [RPCBPROC_SET] = { |
820 | PROC(UNSET, getaddr, set), | 907 | .p_proc = RPCBPROC_SET, |
821 | PROC(GETADDR, getaddr, getaddr), | 908 | .p_encode = (kxdrproc_t)rpcb_enc_getaddr, |
909 | .p_decode = (kxdrproc_t)rpcb_dec_set, | ||
910 | .p_arglen = RPCB_getaddrargs_sz, | ||
911 | .p_replen = RPCB_setres_sz, | ||
912 | .p_statidx = RPCBPROC_SET, | ||
913 | .p_timer = 0, | ||
914 | .p_name = "SET", | ||
915 | }, | ||
916 | [RPCBPROC_UNSET] = { | ||
917 | .p_proc = RPCBPROC_UNSET, | ||
918 | .p_encode = (kxdrproc_t)rpcb_enc_getaddr, | ||
919 | .p_decode = (kxdrproc_t)rpcb_dec_set, | ||
920 | .p_arglen = RPCB_getaddrargs_sz, | ||
921 | .p_replen = RPCB_setres_sz, | ||
922 | .p_statidx = RPCBPROC_UNSET, | ||
923 | .p_timer = 0, | ||
924 | .p_name = "UNSET", | ||
925 | }, | ||
926 | [RPCBPROC_GETADDR] = { | ||
927 | .p_proc = RPCBPROC_GETADDR, | ||
928 | .p_encode = (kxdrproc_t)rpcb_enc_getaddr, | ||
929 | .p_decode = (kxdrproc_t)rpcb_dec_getaddr, | ||
930 | .p_arglen = RPCB_getaddrargs_sz, | ||
931 | .p_replen = RPCB_getaddrres_sz, | ||
932 | .p_statidx = RPCBPROC_GETADDR, | ||
933 | .p_timer = 0, | ||
934 | .p_name = "GETADDR", | ||
935 | }, | ||
822 | }; | 936 | }; |
823 | 937 | ||
824 | static struct rpc_procinfo rpcb_procedures4[] = { | 938 | static struct rpc_procinfo rpcb_procedures4[] = { |
825 | PROC(SET, getaddr, set), | 939 | [RPCBPROC_SET] = { |
826 | PROC(UNSET, getaddr, set), | 940 | .p_proc = RPCBPROC_SET, |
827 | PROC(GETADDR, getaddr, getaddr), | 941 | .p_encode = (kxdrproc_t)rpcb_enc_getaddr, |
828 | PROC(GETVERSADDR, getaddr, getaddr), | 942 | .p_decode = (kxdrproc_t)rpcb_dec_set, |
943 | .p_arglen = RPCB_getaddrargs_sz, | ||
944 | .p_replen = RPCB_setres_sz, | ||
945 | .p_statidx = RPCBPROC_SET, | ||
946 | .p_timer = 0, | ||
947 | .p_name = "SET", | ||
948 | }, | ||
949 | [RPCBPROC_UNSET] = { | ||
950 | .p_proc = RPCBPROC_UNSET, | ||
951 | .p_encode = (kxdrproc_t)rpcb_enc_getaddr, | ||
952 | .p_decode = (kxdrproc_t)rpcb_dec_set, | ||
953 | .p_arglen = RPCB_getaddrargs_sz, | ||
954 | .p_replen = RPCB_setres_sz, | ||
955 | .p_statidx = RPCBPROC_UNSET, | ||
956 | .p_timer = 0, | ||
957 | .p_name = "UNSET", | ||
958 | }, | ||
959 | [RPCBPROC_GETADDR] = { | ||
960 | .p_proc = RPCBPROC_GETADDR, | ||
961 | .p_encode = (kxdrproc_t)rpcb_enc_getaddr, | ||
962 | .p_decode = (kxdrproc_t)rpcb_dec_getaddr, | ||
963 | .p_arglen = RPCB_getaddrargs_sz, | ||
964 | .p_replen = RPCB_getaddrres_sz, | ||
965 | .p_statidx = RPCBPROC_GETADDR, | ||
966 | .p_timer = 0, | ||
967 | .p_name = "GETADDR", | ||
968 | }, | ||
829 | }; | 969 | }; |
830 | 970 | ||
831 | static struct rpcb_info rpcb_next_version[] = { | 971 | static struct rpcb_info rpcb_next_version[] = { |