aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2010-12-14 09:59:29 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-12-16 12:37:25 -0500
commitbf2695516db982e90a22fc94f93491b481796bb1 (patch)
tree367bf134ef892bfc3fcd2c4fe676b14102d97467 /net
parent9f06c719f474be7003763284a990bed6377bb0d4 (diff)
SUNRPC: New xdr_streams XDR decoder API
Now that all client-side XDR decoder routines use xdr_streams, there should be no need to support the legacy calling sequence [rpc_rqst *, __be32 *, RPC res *] anywhere. We can construct an xdr_stream in the generic RPC code, instead of in each decoder function. This is a refactoring change. It should not cause different behavior. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Tested-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/auth.c14
-rw-r--r--net/sunrpc/auth_gss/auth_gss.c13
-rw-r--r--net/sunrpc/clnt.c4
-rw-r--r--net/sunrpc/rpcb_clnt.c46
4 files changed, 45 insertions, 32 deletions
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index 651c9da703cb..67e31276682a 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -587,8 +587,18 @@ rpcauth_wrap_req(struct rpc_task *task, kxdreproc_t encode, void *rqstp,
587 return 0; 587 return 0;
588} 588}
589 589
590static int
591rpcauth_unwrap_req_decode(kxdrdproc_t decode, struct rpc_rqst *rqstp,
592 __be32 *data, void *obj)
593{
594 struct xdr_stream xdr;
595
596 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, data);
597 return decode(rqstp, &xdr, obj);
598}
599
590int 600int
591rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp, 601rpcauth_unwrap_resp(struct rpc_task *task, kxdrdproc_t decode, void *rqstp,
592 __be32 *data, void *obj) 602 __be32 *data, void *obj)
593{ 603{
594 struct rpc_cred *cred = task->tk_rqstp->rq_cred; 604 struct rpc_cred *cred = task->tk_rqstp->rq_cred;
@@ -599,7 +609,7 @@ rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp,
599 return cred->cr_ops->crunwrap_resp(task, decode, rqstp, 609 return cred->cr_ops->crunwrap_resp(task, decode, rqstp,
600 data, obj); 610 data, obj);
601 /* By default, we decode the arguments normally. */ 611 /* By default, we decode the arguments normally. */
602 return decode(rqstp, data, obj); 612 return rpcauth_unwrap_req_decode(decode, rqstp, data, obj);
603} 613}
604 614
605int 615int
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 42b46f9a670a..45dbf1521b9a 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -1503,10 +1503,19 @@ gss_unwrap_resp_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx,
1503 return 0; 1503 return 0;
1504} 1504}
1505 1505
1506static int
1507gss_unwrap_req_decode(kxdrdproc_t decode, struct rpc_rqst *rqstp,
1508 __be32 *p, void *obj)
1509{
1510 struct xdr_stream xdr;
1511
1512 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
1513 return decode(rqstp, &xdr, obj);
1514}
1506 1515
1507static int 1516static int
1508gss_unwrap_resp(struct rpc_task *task, 1517gss_unwrap_resp(struct rpc_task *task,
1509 kxdrproc_t decode, void *rqstp, __be32 *p, void *obj) 1518 kxdrdproc_t decode, void *rqstp, __be32 *p, void *obj)
1510{ 1519{
1511 struct rpc_cred *cred = task->tk_rqstp->rq_cred; 1520 struct rpc_cred *cred = task->tk_rqstp->rq_cred;
1512 struct gss_cred *gss_cred = container_of(cred, struct gss_cred, 1521 struct gss_cred *gss_cred = container_of(cred, struct gss_cred,
@@ -1537,7 +1546,7 @@ gss_unwrap_resp(struct rpc_task *task,
1537 cred->cr_auth->au_rslack = cred->cr_auth->au_verfsize + (p - savedp) 1546 cred->cr_auth->au_rslack = cred->cr_auth->au_verfsize + (p - savedp)
1538 + (savedlen - head->iov_len); 1547 + (savedlen - head->iov_len);
1539out_decode: 1548out_decode:
1540 status = decode(rqstp, p, obj); 1549 status = gss_unwrap_req_decode(decode, rqstp, p, obj);
1541out: 1550out:
1542 gss_put_ctx(ctx); 1551 gss_put_ctx(ctx);
1543 dprintk("RPC: %5u gss_unwrap_resp returning %d\n", task->tk_pid, 1552 dprintk("RPC: %5u gss_unwrap_resp returning %d\n", task->tk_pid,
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index d446a32be667..4e8210dcda72 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -1535,7 +1535,7 @@ call_decode(struct rpc_task *task)
1535{ 1535{
1536 struct rpc_clnt *clnt = task->tk_client; 1536 struct rpc_clnt *clnt = task->tk_client;
1537 struct rpc_rqst *req = task->tk_rqstp; 1537 struct rpc_rqst *req = task->tk_rqstp;
1538 kxdrproc_t decode = task->tk_msg.rpc_proc->p_decode; 1538 kxdrdproc_t decode = task->tk_msg.rpc_proc->p_decode;
1539 __be32 *p; 1539 __be32 *p;
1540 1540
1541 dprintk("RPC: %5u call_decode (status %d)\n", 1541 dprintk("RPC: %5u call_decode (status %d)\n",
@@ -1780,7 +1780,7 @@ static void rpcproc_encode_null(void *rqstp, struct xdr_stream *xdr, void *obj)
1780{ 1780{
1781} 1781}
1782 1782
1783static int rpcproc_decode_null(void *rqstp, __be32 *data, void *obj) 1783static int rpcproc_decode_null(void *rqstp, struct xdr_stream *xdr, void *obj)
1784{ 1784{
1785 return 0; 1785 return 0;
1786} 1786}
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c
index 63912a1a2983..c652e4cc9fe9 100644
--- a/net/sunrpc/rpcb_clnt.c
+++ b/net/sunrpc/rpcb_clnt.c
@@ -706,18 +706,16 @@ static void rpcb_enc_mapping(struct rpc_rqst *req, struct xdr_stream *xdr,
706 *p = cpu_to_be32(rpcb->r_port); 706 *p = cpu_to_be32(rpcb->r_port);
707} 707}
708 708
709static int rpcb_dec_getport(struct rpc_rqst *req, __be32 *p, 709static int rpcb_dec_getport(struct rpc_rqst *req, struct xdr_stream *xdr,
710 struct rpcbind_args *rpcb) 710 struct rpcbind_args *rpcb)
711{ 711{
712 struct rpc_task *task = req->rq_task; 712 struct rpc_task *task = req->rq_task;
713 struct xdr_stream xdr;
714 unsigned long port; 713 unsigned long port;
715 714 __be32 *p;
716 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
717 715
718 rpcb->r_port = 0; 716 rpcb->r_port = 0;
719 717
720 p = xdr_inline_decode(&xdr, 4); 718 p = xdr_inline_decode(xdr, 4);
721 if (unlikely(p == NULL)) 719 if (unlikely(p == NULL))
722 return -EIO; 720 return -EIO;
723 721
@@ -731,20 +729,18 @@ static int rpcb_dec_getport(struct rpc_rqst *req, __be32 *p,
731 return 0; 729 return 0;
732} 730}
733 731
734static int rpcb_dec_set(struct rpc_rqst *req, __be32 *p, 732static int rpcb_dec_set(struct rpc_rqst *req, struct xdr_stream *xdr,
735 unsigned int *boolp) 733 unsigned int *boolp)
736{ 734{
737 struct rpc_task *task = req->rq_task; 735 struct rpc_task *task = req->rq_task;
738 struct xdr_stream xdr; 736 __be32 *p;
739
740 xdr_init_decode(&xdr, &req->rq_rcv_buf, p);
741 737
742 p = xdr_inline_decode(&xdr, 4); 738 p = xdr_inline_decode(xdr, 4);
743 if (unlikely(p == NULL)) 739 if (unlikely(p == NULL))
744 return -EIO; 740 return -EIO;
745 741
746 *boolp = 0; 742 *boolp = 0;
747 if (*p) 743 if (*p != xdr_zero)
748 *boolp = 1; 744 *boolp = 1;
749 745
750 dprintk("RPC: %5u RPCB_%s call %s\n", 746 dprintk("RPC: %5u RPCB_%s call %s\n",
@@ -785,20 +781,18 @@ static void rpcb_enc_getaddr(struct rpc_rqst *req, struct xdr_stream *xdr,
785 encode_rpcb_string(xdr, rpcb->r_owner, RPCB_MAXOWNERLEN); 781 encode_rpcb_string(xdr, rpcb->r_owner, RPCB_MAXOWNERLEN);
786} 782}
787 783
788static int rpcb_dec_getaddr(struct rpc_rqst *req, __be32 *p, 784static int rpcb_dec_getaddr(struct rpc_rqst *req, struct xdr_stream *xdr,
789 struct rpcbind_args *rpcb) 785 struct rpcbind_args *rpcb)
790{ 786{
791 struct sockaddr_storage address; 787 struct sockaddr_storage address;
792 struct sockaddr *sap = (struct sockaddr *)&address; 788 struct sockaddr *sap = (struct sockaddr *)&address;
793 struct rpc_task *task = req->rq_task; 789 struct rpc_task *task = req->rq_task;
794 struct xdr_stream xdr; 790 __be32 *p;
795 u32 len; 791 u32 len;
796 792
797 rpcb->r_port = 0; 793 rpcb->r_port = 0;
798 794
799 xdr_init_decode(&xdr, &req->rq_rcv_buf, p); 795 p = xdr_inline_decode(xdr, 4);
800
801 p = xdr_inline_decode(&xdr, 4);
802 if (unlikely(p == NULL)) 796 if (unlikely(p == NULL))
803 goto out_fail; 797 goto out_fail;
804 len = be32_to_cpup(p); 798 len = be32_to_cpup(p);
@@ -816,7 +810,7 @@ static int rpcb_dec_getaddr(struct rpc_rqst *req, __be32 *p,
816 if (unlikely(len > RPCBIND_MAXUADDRLEN)) 810 if (unlikely(len > RPCBIND_MAXUADDRLEN))
817 goto out_fail; 811 goto out_fail;
818 812
819 p = xdr_inline_decode(&xdr, len); 813 p = xdr_inline_decode(xdr, len);
820 if (unlikely(p == NULL)) 814 if (unlikely(p == NULL))
821 goto out_fail; 815 goto out_fail;
822 dprintk("RPC: %5u RPCB_%s reply: %s\n", task->tk_pid, 816 dprintk("RPC: %5u RPCB_%s reply: %s\n", task->tk_pid,
@@ -843,7 +837,7 @@ static struct rpc_procinfo rpcb_procedures2[] = {
843 [RPCBPROC_SET] = { 837 [RPCBPROC_SET] = {
844 .p_proc = RPCBPROC_SET, 838 .p_proc = RPCBPROC_SET,
845 .p_encode = (kxdreproc_t)rpcb_enc_mapping, 839 .p_encode = (kxdreproc_t)rpcb_enc_mapping,
846 .p_decode = (kxdrproc_t)rpcb_dec_set, 840 .p_decode = (kxdrdproc_t)rpcb_dec_set,
847 .p_arglen = RPCB_mappingargs_sz, 841 .p_arglen = RPCB_mappingargs_sz,
848 .p_replen = RPCB_setres_sz, 842 .p_replen = RPCB_setres_sz,
849 .p_statidx = RPCBPROC_SET, 843 .p_statidx = RPCBPROC_SET,
@@ -853,7 +847,7 @@ static struct rpc_procinfo rpcb_procedures2[] = {
853 [RPCBPROC_UNSET] = { 847 [RPCBPROC_UNSET] = {
854 .p_proc = RPCBPROC_UNSET, 848 .p_proc = RPCBPROC_UNSET,
855 .p_encode = (kxdreproc_t)rpcb_enc_mapping, 849 .p_encode = (kxdreproc_t)rpcb_enc_mapping,
856 .p_decode = (kxdrproc_t)rpcb_dec_set, 850 .p_decode = (kxdrdproc_t)rpcb_dec_set,
857 .p_arglen = RPCB_mappingargs_sz, 851 .p_arglen = RPCB_mappingargs_sz,
858 .p_replen = RPCB_setres_sz, 852 .p_replen = RPCB_setres_sz,
859 .p_statidx = RPCBPROC_UNSET, 853 .p_statidx = RPCBPROC_UNSET,
@@ -863,7 +857,7 @@ static struct rpc_procinfo rpcb_procedures2[] = {
863 [RPCBPROC_GETPORT] = { 857 [RPCBPROC_GETPORT] = {
864 .p_proc = RPCBPROC_GETPORT, 858 .p_proc = RPCBPROC_GETPORT,
865 .p_encode = (kxdreproc_t)rpcb_enc_mapping, 859 .p_encode = (kxdreproc_t)rpcb_enc_mapping,
866 .p_decode = (kxdrproc_t)rpcb_dec_getport, 860 .p_decode = (kxdrdproc_t)rpcb_dec_getport,
867 .p_arglen = RPCB_mappingargs_sz, 861 .p_arglen = RPCB_mappingargs_sz,
868 .p_replen = RPCB_getportres_sz, 862 .p_replen = RPCB_getportres_sz,
869 .p_statidx = RPCBPROC_GETPORT, 863 .p_statidx = RPCBPROC_GETPORT,
@@ -876,7 +870,7 @@ static struct rpc_procinfo rpcb_procedures3[] = {
876 [RPCBPROC_SET] = { 870 [RPCBPROC_SET] = {
877 .p_proc = RPCBPROC_SET, 871 .p_proc = RPCBPROC_SET,
878 .p_encode = (kxdreproc_t)rpcb_enc_getaddr, 872 .p_encode = (kxdreproc_t)rpcb_enc_getaddr,
879 .p_decode = (kxdrproc_t)rpcb_dec_set, 873 .p_decode = (kxdrdproc_t)rpcb_dec_set,
880 .p_arglen = RPCB_getaddrargs_sz, 874 .p_arglen = RPCB_getaddrargs_sz,
881 .p_replen = RPCB_setres_sz, 875 .p_replen = RPCB_setres_sz,
882 .p_statidx = RPCBPROC_SET, 876 .p_statidx = RPCBPROC_SET,
@@ -886,7 +880,7 @@ static struct rpc_procinfo rpcb_procedures3[] = {
886 [RPCBPROC_UNSET] = { 880 [RPCBPROC_UNSET] = {
887 .p_proc = RPCBPROC_UNSET, 881 .p_proc = RPCBPROC_UNSET,
888 .p_encode = (kxdreproc_t)rpcb_enc_getaddr, 882 .p_encode = (kxdreproc_t)rpcb_enc_getaddr,
889 .p_decode = (kxdrproc_t)rpcb_dec_set, 883 .p_decode = (kxdrdproc_t)rpcb_dec_set,
890 .p_arglen = RPCB_getaddrargs_sz, 884 .p_arglen = RPCB_getaddrargs_sz,
891 .p_replen = RPCB_setres_sz, 885 .p_replen = RPCB_setres_sz,
892 .p_statidx = RPCBPROC_UNSET, 886 .p_statidx = RPCBPROC_UNSET,
@@ -896,7 +890,7 @@ static struct rpc_procinfo rpcb_procedures3[] = {
896 [RPCBPROC_GETADDR] = { 890 [RPCBPROC_GETADDR] = {
897 .p_proc = RPCBPROC_GETADDR, 891 .p_proc = RPCBPROC_GETADDR,
898 .p_encode = (kxdreproc_t)rpcb_enc_getaddr, 892 .p_encode = (kxdreproc_t)rpcb_enc_getaddr,
899 .p_decode = (kxdrproc_t)rpcb_dec_getaddr, 893 .p_decode = (kxdrdproc_t)rpcb_dec_getaddr,
900 .p_arglen = RPCB_getaddrargs_sz, 894 .p_arglen = RPCB_getaddrargs_sz,
901 .p_replen = RPCB_getaddrres_sz, 895 .p_replen = RPCB_getaddrres_sz,
902 .p_statidx = RPCBPROC_GETADDR, 896 .p_statidx = RPCBPROC_GETADDR,
@@ -909,7 +903,7 @@ static struct rpc_procinfo rpcb_procedures4[] = {
909 [RPCBPROC_SET] = { 903 [RPCBPROC_SET] = {
910 .p_proc = RPCBPROC_SET, 904 .p_proc = RPCBPROC_SET,
911 .p_encode = (kxdreproc_t)rpcb_enc_getaddr, 905 .p_encode = (kxdreproc_t)rpcb_enc_getaddr,
912 .p_decode = (kxdrproc_t)rpcb_dec_set, 906 .p_decode = (kxdrdproc_t)rpcb_dec_set,
913 .p_arglen = RPCB_getaddrargs_sz, 907 .p_arglen = RPCB_getaddrargs_sz,
914 .p_replen = RPCB_setres_sz, 908 .p_replen = RPCB_setres_sz,
915 .p_statidx = RPCBPROC_SET, 909 .p_statidx = RPCBPROC_SET,
@@ -919,7 +913,7 @@ static struct rpc_procinfo rpcb_procedures4[] = {
919 [RPCBPROC_UNSET] = { 913 [RPCBPROC_UNSET] = {
920 .p_proc = RPCBPROC_UNSET, 914 .p_proc = RPCBPROC_UNSET,
921 .p_encode = (kxdreproc_t)rpcb_enc_getaddr, 915 .p_encode = (kxdreproc_t)rpcb_enc_getaddr,
922 .p_decode = (kxdrproc_t)rpcb_dec_set, 916 .p_decode = (kxdrdproc_t)rpcb_dec_set,
923 .p_arglen = RPCB_getaddrargs_sz, 917 .p_arglen = RPCB_getaddrargs_sz,
924 .p_replen = RPCB_setres_sz, 918 .p_replen = RPCB_setres_sz,
925 .p_statidx = RPCBPROC_UNSET, 919 .p_statidx = RPCBPROC_UNSET,
@@ -929,7 +923,7 @@ static struct rpc_procinfo rpcb_procedures4[] = {
929 [RPCBPROC_GETADDR] = { 923 [RPCBPROC_GETADDR] = {
930 .p_proc = RPCBPROC_GETADDR, 924 .p_proc = RPCBPROC_GETADDR,
931 .p_encode = (kxdreproc_t)rpcb_enc_getaddr, 925 .p_encode = (kxdreproc_t)rpcb_enc_getaddr,
932 .p_decode = (kxdrproc_t)rpcb_dec_getaddr, 926 .p_decode = (kxdrdproc_t)rpcb_dec_getaddr,
933 .p_arglen = RPCB_getaddrargs_sz, 927 .p_arglen = RPCB_getaddrargs_sz,
934 .p_replen = RPCB_getaddrres_sz, 928 .p_replen = RPCB_getaddrres_sz,
935 .p_statidx = RPCBPROC_GETADDR, 929 .p_statidx = RPCBPROC_GETADDR,