diff options
author | Tom Tucker <tom@opengridcomputing.com> | 2007-12-30 22:07:29 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@citi.umich.edu> | 2008-02-01 16:42:08 -0500 |
commit | e831fe65b10199e1e301a7316c66d6ced133712d (patch) | |
tree | 33436ef94e099e854c4824e78cd62f341e5f357a | |
parent | 755cceaba7555027e61dfa79f1e55bdfc6906633 (diff) |
svc: Add xpo_prep_reply_hdr
Some transports add fields to the RPC header for replies, e.g. the TCP
record length. This function is called when preparing the reply header
to allow each transport to add whatever fields it requires.
Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
Acked-by: Neil Brown <neilb@suse.de>
Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: Greg Banks <gnb@sgi.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
-rw-r--r-- | include/linux/sunrpc/svc_xprt.h | 1 | ||||
-rw-r--r-- | net/sunrpc/svc.c | 6 | ||||
-rw-r--r-- | net/sunrpc/svcsock.c | 17 |
3 files changed, 21 insertions, 3 deletions
diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h index f032fb6b32e9..199cfcb9860b 100644 --- a/include/linux/sunrpc/svc_xprt.h +++ b/include/linux/sunrpc/svc_xprt.h | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | struct svc_xprt_ops { | 12 | struct svc_xprt_ops { |
13 | int (*xpo_recvfrom)(struct svc_rqst *); | 13 | int (*xpo_recvfrom)(struct svc_rqst *); |
14 | void (*xpo_prep_reply_hdr)(struct svc_rqst *); | ||
14 | int (*xpo_sendto)(struct svc_rqst *); | 15 | int (*xpo_sendto)(struct svc_rqst *); |
15 | void (*xpo_release_rqst)(struct svc_rqst *); | 16 | void (*xpo_release_rqst)(struct svc_rqst *); |
16 | void (*xpo_detach)(struct svc_xprt *); | 17 | void (*xpo_detach)(struct svc_xprt *); |
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index 94eed9b80038..8281a0402652 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c | |||
@@ -840,9 +840,9 @@ svc_process(struct svc_rqst *rqstp) | |||
840 | rqstp->rq_res.tail[0].iov_len = 0; | 840 | rqstp->rq_res.tail[0].iov_len = 0; |
841 | /* Will be turned off only in gss privacy case: */ | 841 | /* Will be turned off only in gss privacy case: */ |
842 | rqstp->rq_splice_ok = 1; | 842 | rqstp->rq_splice_ok = 1; |
843 | /* tcp needs a space for the record length... */ | 843 | |
844 | if (rqstp->rq_prot == IPPROTO_TCP) | 844 | /* Setup reply header */ |
845 | svc_putnl(resv, 0); | 845 | rqstp->rq_xprt->xpt_ops->xpo_prep_reply_hdr(rqstp); |
846 | 846 | ||
847 | rqstp->rq_xid = svc_getu32(argv); | 847 | rqstp->rq_xid = svc_getu32(argv); |
848 | svc_putu32(resv, rqstp->rq_xid); | 848 | svc_putu32(resv, rqstp->rq_xid); |
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 44a729d6efea..492a1dc544f3 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c | |||
@@ -893,12 +893,17 @@ svc_udp_sendto(struct svc_rqst *rqstp) | |||
893 | return error; | 893 | return error; |
894 | } | 894 | } |
895 | 895 | ||
896 | static void svc_udp_prep_reply_hdr(struct svc_rqst *rqstp) | ||
897 | { | ||
898 | } | ||
899 | |||
896 | static struct svc_xprt_ops svc_udp_ops = { | 900 | static struct svc_xprt_ops svc_udp_ops = { |
897 | .xpo_recvfrom = svc_udp_recvfrom, | 901 | .xpo_recvfrom = svc_udp_recvfrom, |
898 | .xpo_sendto = svc_udp_sendto, | 902 | .xpo_sendto = svc_udp_sendto, |
899 | .xpo_release_rqst = svc_release_skb, | 903 | .xpo_release_rqst = svc_release_skb, |
900 | .xpo_detach = svc_sock_detach, | 904 | .xpo_detach = svc_sock_detach, |
901 | .xpo_free = svc_sock_free, | 905 | .xpo_free = svc_sock_free, |
906 | .xpo_prep_reply_hdr = svc_udp_prep_reply_hdr, | ||
902 | }; | 907 | }; |
903 | 908 | ||
904 | static struct svc_xprt_class svc_udp_class = { | 909 | static struct svc_xprt_class svc_udp_class = { |
@@ -1350,12 +1355,24 @@ svc_tcp_sendto(struct svc_rqst *rqstp) | |||
1350 | return sent; | 1355 | return sent; |
1351 | } | 1356 | } |
1352 | 1357 | ||
1358 | /* | ||
1359 | * Setup response header. TCP has a 4B record length field. | ||
1360 | */ | ||
1361 | static void svc_tcp_prep_reply_hdr(struct svc_rqst *rqstp) | ||
1362 | { | ||
1363 | struct kvec *resv = &rqstp->rq_res.head[0]; | ||
1364 | |||
1365 | /* tcp needs a space for the record length... */ | ||
1366 | svc_putnl(resv, 0); | ||
1367 | } | ||
1368 | |||
1353 | static struct svc_xprt_ops svc_tcp_ops = { | 1369 | static struct svc_xprt_ops svc_tcp_ops = { |
1354 | .xpo_recvfrom = svc_tcp_recvfrom, | 1370 | .xpo_recvfrom = svc_tcp_recvfrom, |
1355 | .xpo_sendto = svc_tcp_sendto, | 1371 | .xpo_sendto = svc_tcp_sendto, |
1356 | .xpo_release_rqst = svc_release_skb, | 1372 | .xpo_release_rqst = svc_release_skb, |
1357 | .xpo_detach = svc_sock_detach, | 1373 | .xpo_detach = svc_sock_detach, |
1358 | .xpo_free = svc_sock_free, | 1374 | .xpo_free = svc_sock_free, |
1375 | .xpo_prep_reply_hdr = svc_tcp_prep_reply_hdr, | ||
1359 | }; | 1376 | }; |
1360 | 1377 | ||
1361 | static struct svc_xprt_class svc_tcp_class = { | 1378 | static struct svc_xprt_class svc_tcp_class = { |