]> Pileus Git - ~andy/linux/blobdiff - include/linux/sunrpc/svc.h
sendfile: convert nfsd to splice_direct_to_actor()
[~andy/linux] / include / linux / sunrpc / svc.h
index 64f3d60c72af2e918de63c2a28469176a1248dff..129d50f2225c02b8bb94505de60dc579b9a87427 100644 (file)
@@ -11,6 +11,7 @@
 #define SUNRPC_SVC_H
 
 #include <linux/in.h>
+#include <linux/in6.h>
 #include <linux/sunrpc/types.h>
 #include <linux/sunrpc/xdr.h>
 #include <linux/sunrpc/auth.h>
@@ -191,7 +192,11 @@ static inline void svc_putu32(struct kvec *iov, __be32 val)
        iov->iov_len += sizeof(__be32);
 }
 
-       
+union svc_addr_u {
+    struct in_addr     addr;
+    struct in6_addr    addr6;
+};
+
 /*
  * The context of a single thread, including the request currently being
  * processed.
@@ -200,8 +205,8 @@ struct svc_rqst {
        struct list_head        rq_list;        /* idle list */
        struct list_head        rq_all;         /* all threads list */
        struct svc_sock *       rq_sock;        /* socket */
-       struct sockaddr_in      rq_addr;        /* peer address */
-       int                     rq_addrlen;
+       struct sockaddr_storage rq_addr;        /* peer address */
+       size_t                  rq_addrlen;
 
        struct svc_serv *       rq_server;      /* RPC service definition */
        struct svc_pool *       rq_pool;        /* thread pool */
@@ -227,8 +232,8 @@ struct svc_rqst {
        unsigned short
                                rq_secure  : 1; /* secure port */
 
-
-       __be32                  rq_daddr;       /* dest addr of request - reply from here */
+       union svc_addr_u        rq_daddr;       /* dest addr of request
+                                                *  - reply from here */
 
        void *                  rq_argp;        /* decoded arguments */
        void *                  rq_resp;        /* xdr'd results */
@@ -248,13 +253,31 @@ struct svc_rqst {
                                                 * determine what device number
                                                 * to report (real or virtual)
                                                 */
-       int                     rq_sendfile_ok; /* turned off in gss privacy
+       int                     rq_splice_ok;   /* turned off in gss privacy
                                                 * to prevent encrypting page
                                                 * cache pages */
        wait_queue_head_t       rq_wait;        /* synchronization */
        struct task_struct      *rq_task;       /* service thread */
 };
 
+/*
+ * Rigorous type checking on sockaddr type conversions
+ */
+static inline struct sockaddr_in *svc_addr_in(struct svc_rqst *rqst)
+{
+       return (struct sockaddr_in *) &rqst->rq_addr;
+}
+
+static inline struct sockaddr_in6 *svc_addr_in6(struct svc_rqst *rqst)
+{
+       return (struct sockaddr_in6 *) &rqst->rq_addr;
+}
+
+static inline struct sockaddr *svc_addr(struct svc_rqst *rqst)
+{
+       return (struct sockaddr *) &rqst->rq_addr;
+}
+
 /*
  * Check buffer bounds after decoding arguments
  */
@@ -292,9 +315,10 @@ static inline void svc_free_res_pages(struct svc_rqst *rqstp)
 
 struct svc_deferred_req {
        u32                     prot;   /* protocol (UDP or TCP) */
-       struct sockaddr_in      addr;
-       struct svc_sock         *svsk;  /* where reply must go */
-       __be32                  daddr;  /* where reply must come from */
+       struct svc_sock         *svsk;
+       struct sockaddr_storage addr;   /* where reply must go */
+       size_t                  addrlen;
+       union svc_addr_u        daddr;  /* where reply must come from */
        struct cache_deferred_req handle;
        int                     argslen;
        __be32                  args[0];
@@ -368,5 +392,27 @@ int                   svc_register(struct svc_serv *, int, unsigned short);
 void              svc_wake_up(struct svc_serv *);
 void              svc_reserve(struct svc_rqst *rqstp, int space);
 struct svc_pool *  svc_pool_for_cpu(struct svc_serv *serv, int cpu);
+char *            svc_print_addr(struct svc_rqst *, char *, size_t);
+
+#define        RPC_MAX_ADDRBUFLEN      (63U)
+
+/*
+ * When we want to reduce the size of the reserved space in the response
+ * buffer, we need to take into account the size of any checksum data that
+ * may be at the end of the packet. This is difficult to determine exactly
+ * for all cases without actually generating the checksum, so we just use a
+ * static value.
+ */
+static inline void
+svc_reserve_auth(struct svc_rqst *rqstp, int space)
+{
+       int                     added_space = 0;
+
+       switch(rqstp->rq_authop->flavour) {
+               case RPC_AUTH_GSS:
+                       added_space = RPC_MAX_AUTH_SIZE;
+       }
+       return svc_reserve(rqstp, space + added_space);
+}
 
 #endif /* SUNRPC_SVC_H */