diff options
author | J. Bruce Fields <bfields@redhat.com> | 2012-12-03 16:11:13 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2012-12-04 07:47:23 -0500 |
commit | cc248d4b1ddf05fefc1373d9d7a4dd1df71b6190 (patch) | |
tree | 3ca18b5b45e666ff307ed440c5a1b6e38fc7b33b /net/sunrpc | |
parent | 6c1e82a4b74ad0c8b45c833a4409f153199d9be4 (diff) |
svcrpc: don't byte-swap sk_reclen in place
Byte-swapping in place is always a little dubious.
Let's instead define this field to always be big-endian, and do the
swapping on demand where we need it.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'net/sunrpc')
-rw-r--r-- | net/sunrpc/svcsock.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 03827cef1fa7..d50de2b95036 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c | |||
@@ -950,8 +950,7 @@ static int svc_tcp_recv_record(struct svc_sock *svsk, struct svc_rqst *rqstp) | |||
950 | return -EAGAIN; | 950 | return -EAGAIN; |
951 | } | 951 | } |
952 | 952 | ||
953 | svsk->sk_reclen = ntohl(svsk->sk_reclen); | 953 | if (!(svc_sock_final_rec(svsk))) { |
954 | if (!(svsk->sk_reclen & RPC_LAST_STREAM_FRAGMENT)) { | ||
955 | /* FIXME: technically, a record can be fragmented, | 954 | /* FIXME: technically, a record can be fragmented, |
956 | * and non-terminal fragments will not have the top | 955 | * and non-terminal fragments will not have the top |
957 | * bit set in the fragment length header. | 956 | * bit set in the fragment length header. |
@@ -961,21 +960,18 @@ static int svc_tcp_recv_record(struct svc_sock *svsk, struct svc_rqst *rqstp) | |||
961 | goto err_delete; | 960 | goto err_delete; |
962 | } | 961 | } |
963 | 962 | ||
964 | svsk->sk_reclen &= RPC_FRAGMENT_SIZE_MASK; | 963 | dprintk("svc: TCP record, %d bytes\n", svc_sock_reclen(svsk)); |
965 | dprintk("svc: TCP record, %d bytes\n", svsk->sk_reclen); | 964 | if (svc_sock_reclen(svsk) > serv->sv_max_mesg) { |
966 | if (svsk->sk_reclen > serv->sv_max_mesg) { | ||
967 | net_notice_ratelimited("RPC: fragment too large: 0x%08lx\n", | 965 | net_notice_ratelimited("RPC: fragment too large: 0x%08lx\n", |
968 | (unsigned long)svsk->sk_reclen); | 966 | (unsigned long)svc_sock_reclen(svsk)); |
969 | goto err_delete; | 967 | goto err_delete; |
970 | } | 968 | } |
971 | } | 969 | } |
972 | 970 | ||
973 | if (svsk->sk_reclen < 8) | 971 | if (svc_sock_reclen(svsk) < 8) |
974 | goto err_delete; /* client is nuts. */ | 972 | goto err_delete; /* client is nuts. */ |
975 | 973 | ||
976 | len = svsk->sk_reclen; | 974 | return svc_sock_reclen(svsk); |
977 | |||
978 | return len; | ||
979 | error: | 975 | error: |
980 | dprintk("RPC: TCP recv_record got %d\n", len); | 976 | dprintk("RPC: TCP recv_record got %d\n", len); |
981 | return len; | 977 | return len; |
@@ -1019,7 +1015,7 @@ static int receive_cb_reply(struct svc_sock *svsk, struct svc_rqst *rqstp) | |||
1019 | if (dst->iov_len < src->iov_len) | 1015 | if (dst->iov_len < src->iov_len) |
1020 | return -EAGAIN; /* whatever; just giving up. */ | 1016 | return -EAGAIN; /* whatever; just giving up. */ |
1021 | memcpy(dst->iov_base, src->iov_base, src->iov_len); | 1017 | memcpy(dst->iov_base, src->iov_base, src->iov_len); |
1022 | xprt_complete_rqst(req->rq_task, svsk->sk_reclen); | 1018 | xprt_complete_rqst(req->rq_task, rqstp->rq_arg.len); |
1023 | rqstp->rq_arg.len = 0; | 1019 | rqstp->rq_arg.len = 0; |
1024 | return 0; | 1020 | return 0; |
1025 | } | 1021 | } |
@@ -1064,12 +1060,12 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp) | |||
1064 | goto error; | 1060 | goto error; |
1065 | 1061 | ||
1066 | base = svc_tcp_restore_pages(svsk, rqstp); | 1062 | base = svc_tcp_restore_pages(svsk, rqstp); |
1067 | want = svsk->sk_reclen - base; | 1063 | want = svc_sock_reclen(svsk) - base; |
1068 | 1064 | ||
1069 | vec = rqstp->rq_vec; | 1065 | vec = rqstp->rq_vec; |
1070 | 1066 | ||
1071 | pnum = copy_pages_to_kvecs(&vec[0], &rqstp->rq_pages[0], | 1067 | pnum = copy_pages_to_kvecs(&vec[0], &rqstp->rq_pages[0], |
1072 | svsk->sk_reclen); | 1068 | svc_sock_reclen(svsk)); |
1073 | 1069 | ||
1074 | rqstp->rq_respages = &rqstp->rq_pages[pnum]; | 1070 | rqstp->rq_respages = &rqstp->rq_pages[pnum]; |
1075 | 1071 | ||
@@ -1082,11 +1078,11 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp) | |||
1082 | if (len < 0 && len != -EAGAIN) | 1078 | if (len < 0 && len != -EAGAIN) |
1083 | goto err_other; | 1079 | goto err_other; |
1084 | dprintk("svc: incomplete TCP record (%d of %d)\n", | 1080 | dprintk("svc: incomplete TCP record (%d of %d)\n", |
1085 | svsk->sk_tcplen, svsk->sk_reclen); | 1081 | svsk->sk_tcplen, svc_sock_reclen(svsk)); |
1086 | goto err_noclose; | 1082 | goto err_noclose; |
1087 | } | 1083 | } |
1088 | 1084 | ||
1089 | rqstp->rq_arg.len = svsk->sk_reclen; | 1085 | rqstp->rq_arg.len = svc_sock_reclen(svsk); |
1090 | rqstp->rq_arg.page_base = 0; | 1086 | rqstp->rq_arg.page_base = 0; |
1091 | if (rqstp->rq_arg.len <= rqstp->rq_arg.head[0].iov_len) { | 1087 | if (rqstp->rq_arg.len <= rqstp->rq_arg.head[0].iov_len) { |
1092 | rqstp->rq_arg.head[0].iov_len = rqstp->rq_arg.len; | 1088 | rqstp->rq_arg.head[0].iov_len = rqstp->rq_arg.len; |