aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc
diff options
context:
space:
mode:
authorTom Tucker <tom@opengridcomputing.com>2007-12-30 22:07:17 -0500
committerJ. Bruce Fields <bfields@citi.umich.edu>2008-02-01 16:42:07 -0500
commit360d873864c8903a650b227758b49dd50e6ecc9f (patch)
tree806631491e4848b194abd539293f124b366a49de /net/sunrpc
parent1d8206b97a09e7ff2fbef17d8d1ea008d764eeaa (diff)
svc: Make svc_sock the tcp/udp transport
Make TCP and UDP svc_sock transports, and register them with the svc transport core. A transport type (svc_sock) has an svc_xprt as its first member, and calls svc_xprt_init to initialize this field. 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>
Diffstat (limited to 'net/sunrpc')
-rw-r--r--net/sunrpc/sunrpc_syms.c4
-rw-r--r--net/sunrpc/svcsock.c32
2 files changed, 34 insertions, 2 deletions
diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c
index ef7dc78e2c7b..11b309817b8f 100644
--- a/net/sunrpc/sunrpc_syms.c
+++ b/net/sunrpc/sunrpc_syms.c
@@ -85,7 +85,8 @@ init_sunrpc(void)
85#endif 85#endif
86 cache_register(&ip_map_cache); 86 cache_register(&ip_map_cache);
87 cache_register(&unix_gid_cache); 87 cache_register(&unix_gid_cache);
88 init_socket_xprt(); 88 svc_init_xprt_sock(); /* svc sock transport */
89 init_socket_xprt(); /* clnt sock transport */
89 rpcauth_init_module(); 90 rpcauth_init_module();
90out: 91out:
91 return err; 92 return err;
@@ -96,6 +97,7 @@ cleanup_sunrpc(void)
96{ 97{
97 rpcauth_remove_module(); 98 rpcauth_remove_module();
98 cleanup_socket_xprt(); 99 cleanup_socket_xprt();
100 svc_cleanup_xprt_sock();
99 unregister_rpc_pipefs(); 101 unregister_rpc_pipefs();
100 rpc_destroy_mempool(); 102 rpc_destroy_mempool();
101 cache_unregister(&ip_map_cache); 103 cache_unregister(&ip_map_cache);
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index c75bffeb89eb..54f1b3d993a6 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -75,7 +75,7 @@
75 * 75 *
76 */ 76 */
77 77
78#define RPCDBG_FACILITY RPCDBG_SVCSOCK 78#define RPCDBG_FACILITY RPCDBG_SVCXPRT
79 79
80 80
81static struct svc_sock *svc_setup_socket(struct svc_serv *, struct socket *, 81static struct svc_sock *svc_setup_socket(struct svc_serv *, struct socket *,
@@ -900,12 +900,21 @@ svc_udp_sendto(struct svc_rqst *rqstp)
900 return error; 900 return error;
901} 901}
902 902
903static struct svc_xprt_ops svc_udp_ops = {
904};
905
906static struct svc_xprt_class svc_udp_class = {
907 .xcl_name = "udp",
908 .xcl_ops = &svc_udp_ops,
909};
910
903static void 911static void
904svc_udp_init(struct svc_sock *svsk) 912svc_udp_init(struct svc_sock *svsk)
905{ 913{
906 int one = 1; 914 int one = 1;
907 mm_segment_t oldfs; 915 mm_segment_t oldfs;
908 916
917 svc_xprt_init(&svc_udp_class, &svsk->sk_xprt);
909 svsk->sk_sk->sk_data_ready = svc_udp_data_ready; 918 svsk->sk_sk->sk_data_ready = svc_udp_data_ready;
910 svsk->sk_sk->sk_write_space = svc_write_space; 919 svsk->sk_sk->sk_write_space = svc_write_space;
911 svsk->sk_recvfrom = svc_udp_recvfrom; 920 svsk->sk_recvfrom = svc_udp_recvfrom;
@@ -1344,12 +1353,33 @@ svc_tcp_sendto(struct svc_rqst *rqstp)
1344 return sent; 1353 return sent;
1345} 1354}
1346 1355
1356static struct svc_xprt_ops svc_tcp_ops = {
1357};
1358
1359static struct svc_xprt_class svc_tcp_class = {
1360 .xcl_name = "tcp",
1361 .xcl_ops = &svc_tcp_ops,
1362};
1363
1364void svc_init_xprt_sock(void)
1365{
1366 svc_reg_xprt_class(&svc_tcp_class);
1367 svc_reg_xprt_class(&svc_udp_class);
1368}
1369
1370void svc_cleanup_xprt_sock(void)
1371{
1372 svc_unreg_xprt_class(&svc_tcp_class);
1373 svc_unreg_xprt_class(&svc_udp_class);
1374}
1375
1347static void 1376static void
1348svc_tcp_init(struct svc_sock *svsk) 1377svc_tcp_init(struct svc_sock *svsk)
1349{ 1378{
1350 struct sock *sk = svsk->sk_sk; 1379 struct sock *sk = svsk->sk_sk;
1351 struct tcp_sock *tp = tcp_sk(sk); 1380 struct tcp_sock *tp = tcp_sk(sk);
1352 1381
1382 svc_xprt_init(&svc_tcp_class, &svsk->sk_xprt);
1353 svsk->sk_recvfrom = svc_tcp_recvfrom; 1383 svsk->sk_recvfrom = svc_tcp_recvfrom;
1354 svsk->sk_sendto = svc_tcp_sendto; 1384 svsk->sk_sendto = svc_tcp_sendto;
1355 1385