diff options
author | Tom Tucker <tom@opengridcomputing.com> | 2007-12-30 22:07:23 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@citi.umich.edu> | 2008-02-01 16:42:08 -0500 |
commit | 5d137990f5860451a6e0428e0903f62933d05287 (patch) | |
tree | 71f57e8a13138530c8c82f9de19067687d0b428d | |
parent | 490231558e058547da4ffab6d8ce8e28771749cc (diff) |
svc: Move sk_sendto and sk_recvfrom to svc_xprt_class
The sk_sendto and sk_recvfrom are function pointers that allow svc_sock
to be used for both UDP and TCP. Move these function pointers to the
svc_xprt_ops structure.
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 | 2 | ||||
-rw-r--r-- | include/linux/sunrpc/svcsock.h | 3 | ||||
-rw-r--r-- | net/sunrpc/svcsock.c | 12 |
3 files changed, 8 insertions, 9 deletions
diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h index 187dc4e2e202..7ae6c857b05d 100644 --- a/include/linux/sunrpc/svc_xprt.h +++ b/include/linux/sunrpc/svc_xprt.h | |||
@@ -10,6 +10,8 @@ | |||
10 | #include <linux/sunrpc/svc.h> | 10 | #include <linux/sunrpc/svc.h> |
11 | 11 | ||
12 | struct svc_xprt_ops { | 12 | struct svc_xprt_ops { |
13 | int (*xpo_recvfrom)(struct svc_rqst *); | ||
14 | int (*xpo_sendto)(struct svc_rqst *); | ||
13 | }; | 15 | }; |
14 | 16 | ||
15 | struct svc_xprt_class { | 17 | struct svc_xprt_class { |
diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h index 1878cbe1aa4f..08e78d0a364f 100644 --- a/include/linux/sunrpc/svcsock.h +++ b/include/linux/sunrpc/svcsock.h | |||
@@ -45,9 +45,6 @@ struct svc_sock { | |||
45 | * be revisted */ | 45 | * be revisted */ |
46 | struct mutex sk_mutex; /* to serialize sending data */ | 46 | struct mutex sk_mutex; /* to serialize sending data */ |
47 | 47 | ||
48 | int (*sk_recvfrom)(struct svc_rqst *rqstp); | ||
49 | int (*sk_sendto)(struct svc_rqst *rqstp); | ||
50 | |||
51 | /* We keep the old state_change and data_ready CB's here */ | 48 | /* We keep the old state_change and data_ready CB's here */ |
52 | void (*sk_ostate)(struct sock *); | 49 | void (*sk_ostate)(struct sock *); |
53 | void (*sk_odata)(struct sock *, int bytes); | 50 | void (*sk_odata)(struct sock *, int bytes); |
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index c507f6f8ee54..7817c7eea753 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c | |||
@@ -901,6 +901,8 @@ svc_udp_sendto(struct svc_rqst *rqstp) | |||
901 | } | 901 | } |
902 | 902 | ||
903 | static struct svc_xprt_ops svc_udp_ops = { | 903 | static struct svc_xprt_ops svc_udp_ops = { |
904 | .xpo_recvfrom = svc_udp_recvfrom, | ||
905 | .xpo_sendto = svc_udp_sendto, | ||
904 | }; | 906 | }; |
905 | 907 | ||
906 | static struct svc_xprt_class svc_udp_class = { | 908 | static struct svc_xprt_class svc_udp_class = { |
@@ -918,8 +920,6 @@ svc_udp_init(struct svc_sock *svsk) | |||
918 | svc_xprt_init(&svc_udp_class, &svsk->sk_xprt); | 920 | svc_xprt_init(&svc_udp_class, &svsk->sk_xprt); |
919 | svsk->sk_sk->sk_data_ready = svc_udp_data_ready; | 921 | svsk->sk_sk->sk_data_ready = svc_udp_data_ready; |
920 | svsk->sk_sk->sk_write_space = svc_write_space; | 922 | svsk->sk_sk->sk_write_space = svc_write_space; |
921 | svsk->sk_recvfrom = svc_udp_recvfrom; | ||
922 | svsk->sk_sendto = svc_udp_sendto; | ||
923 | 923 | ||
924 | /* initialise setting must have enough space to | 924 | /* initialise setting must have enough space to |
925 | * receive and respond to one request. | 925 | * receive and respond to one request. |
@@ -1355,6 +1355,8 @@ svc_tcp_sendto(struct svc_rqst *rqstp) | |||
1355 | } | 1355 | } |
1356 | 1356 | ||
1357 | static struct svc_xprt_ops svc_tcp_ops = { | 1357 | static struct svc_xprt_ops svc_tcp_ops = { |
1358 | .xpo_recvfrom = svc_tcp_recvfrom, | ||
1359 | .xpo_sendto = svc_tcp_sendto, | ||
1358 | }; | 1360 | }; |
1359 | 1361 | ||
1360 | static struct svc_xprt_class svc_tcp_class = { | 1362 | static struct svc_xprt_class svc_tcp_class = { |
@@ -1382,8 +1384,6 @@ svc_tcp_init(struct svc_sock *svsk) | |||
1382 | struct tcp_sock *tp = tcp_sk(sk); | 1384 | struct tcp_sock *tp = tcp_sk(sk); |
1383 | 1385 | ||
1384 | svc_xprt_init(&svc_tcp_class, &svsk->sk_xprt); | 1386 | svc_xprt_init(&svc_tcp_class, &svsk->sk_xprt); |
1385 | svsk->sk_recvfrom = svc_tcp_recvfrom; | ||
1386 | svsk->sk_sendto = svc_tcp_sendto; | ||
1387 | 1387 | ||
1388 | if (sk->sk_state == TCP_LISTEN) { | 1388 | if (sk->sk_state == TCP_LISTEN) { |
1389 | dprintk("setting up TCP socket for listening\n"); | 1389 | dprintk("setting up TCP socket for listening\n"); |
@@ -1531,7 +1531,7 @@ svc_recv(struct svc_rqst *rqstp, long timeout) | |||
1531 | 1531 | ||
1532 | dprintk("svc: server %p, pool %u, socket %p, inuse=%d\n", | 1532 | dprintk("svc: server %p, pool %u, socket %p, inuse=%d\n", |
1533 | rqstp, pool->sp_id, svsk, atomic_read(&svsk->sk_inuse)); | 1533 | rqstp, pool->sp_id, svsk, atomic_read(&svsk->sk_inuse)); |
1534 | len = svsk->sk_recvfrom(rqstp); | 1534 | len = svsk->sk_xprt.xpt_ops->xpo_recvfrom(rqstp); |
1535 | dprintk("svc: got len=%d\n", len); | 1535 | dprintk("svc: got len=%d\n", len); |
1536 | 1536 | ||
1537 | /* No data, incomplete (TCP) read, or accept() */ | 1537 | /* No data, incomplete (TCP) read, or accept() */ |
@@ -1591,7 +1591,7 @@ svc_send(struct svc_rqst *rqstp) | |||
1591 | if (test_bit(SK_DEAD, &svsk->sk_flags)) | 1591 | if (test_bit(SK_DEAD, &svsk->sk_flags)) |
1592 | len = -ENOTCONN; | 1592 | len = -ENOTCONN; |
1593 | else | 1593 | else |
1594 | len = svsk->sk_sendto(rqstp); | 1594 | len = svsk->sk_xprt.xpt_ops->xpo_sendto(rqstp); |
1595 | mutex_unlock(&svsk->sk_mutex); | 1595 | mutex_unlock(&svsk->sk_mutex); |
1596 | svc_sock_release(rqstp); | 1596 | svc_sock_release(rqstp); |
1597 | 1597 | ||