]> nv-tegra.nvidia Code Review - linux-3.10.git/commitdiff
svc: Move sk_sendto and sk_recvfrom to svc_xprt_class
authorTom Tucker <tom@opengridcomputing.com>
Mon, 31 Dec 2007 03:07:23 +0000 (21:07 -0600)
committerJ. Bruce Fields <bfields@citi.umich.edu>
Fri, 1 Feb 2008 21:42:08 +0000 (16:42 -0500)
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>
include/linux/sunrpc/svc_xprt.h
include/linux/sunrpc/svcsock.h
net/sunrpc/svcsock.c

index 187dc4e2e2022e6ac00e33d05ed3c1fb2cc30eac..7ae6c857b05dad784ac2442d91aab85ef476931c 100644 (file)
@@ -10,6 +10,8 @@
 #include <linux/sunrpc/svc.h>
 
 struct svc_xprt_ops {
+       int             (*xpo_recvfrom)(struct svc_rqst *);
+       int             (*xpo_sendto)(struct svc_rqst *);
 };
 
 struct svc_xprt_class {
index 1878cbe1aa4f3b280af0b9bef96f01faf7f03401..08e78d0a364f4100a840ccc853b3674be5af4115 100644 (file)
@@ -45,9 +45,6 @@ struct svc_sock {
                                                 * be revisted */
        struct mutex            sk_mutex;       /* to serialize sending data */
 
-       int                     (*sk_recvfrom)(struct svc_rqst *rqstp);
-       int                     (*sk_sendto)(struct svc_rqst *rqstp);
-
        /* We keep the old state_change and data_ready CB's here */
        void                    (*sk_ostate)(struct sock *);
        void                    (*sk_odata)(struct sock *, int bytes);
index c507f6f8ee545c116be598cd673d71420296bcf0..7817c7eea7531167c517a1a9f222535fd2bc0647 100644 (file)
@@ -901,6 +901,8 @@ svc_udp_sendto(struct svc_rqst *rqstp)
 }
 
 static struct svc_xprt_ops svc_udp_ops = {
+       .xpo_recvfrom = svc_udp_recvfrom,
+       .xpo_sendto = svc_udp_sendto,
 };
 
 static struct svc_xprt_class svc_udp_class = {
@@ -918,8 +920,6 @@ svc_udp_init(struct svc_sock *svsk)
        svc_xprt_init(&svc_udp_class, &svsk->sk_xprt);
        svsk->sk_sk->sk_data_ready = svc_udp_data_ready;
        svsk->sk_sk->sk_write_space = svc_write_space;
-       svsk->sk_recvfrom = svc_udp_recvfrom;
-       svsk->sk_sendto = svc_udp_sendto;
 
        /* initialise setting must have enough space to
         * receive and respond to one request.
@@ -1355,6 +1355,8 @@ svc_tcp_sendto(struct svc_rqst *rqstp)
 }
 
 static struct svc_xprt_ops svc_tcp_ops = {
+       .xpo_recvfrom = svc_tcp_recvfrom,
+       .xpo_sendto = svc_tcp_sendto,
 };
 
 static struct svc_xprt_class svc_tcp_class = {
@@ -1382,8 +1384,6 @@ svc_tcp_init(struct svc_sock *svsk)
        struct tcp_sock *tp = tcp_sk(sk);
 
        svc_xprt_init(&svc_tcp_class, &svsk->sk_xprt);
-       svsk->sk_recvfrom = svc_tcp_recvfrom;
-       svsk->sk_sendto = svc_tcp_sendto;
 
        if (sk->sk_state == TCP_LISTEN) {
                dprintk("setting up TCP socket for listening\n");
@@ -1531,7 +1531,7 @@ svc_recv(struct svc_rqst *rqstp, long timeout)
 
        dprintk("svc: server %p, pool %u, socket %p, inuse=%d\n",
                 rqstp, pool->sp_id, svsk, atomic_read(&svsk->sk_inuse));
-       len = svsk->sk_recvfrom(rqstp);
+       len = svsk->sk_xprt.xpt_ops->xpo_recvfrom(rqstp);
        dprintk("svc: got len=%d\n", len);
 
        /* No data, incomplete (TCP) read, or accept() */
@@ -1591,7 +1591,7 @@ svc_send(struct svc_rqst *rqstp)
        if (test_bit(SK_DEAD, &svsk->sk_flags))
                len = -ENOTCONN;
        else
-               len = svsk->sk_sendto(rqstp);
+               len = svsk->sk_xprt.xpt_ops->xpo_sendto(rqstp);
        mutex_unlock(&svsk->sk_mutex);
        svc_sock_release(rqstp);