]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/sunrpc/svc.c
svc: Add a max payload value to the transport
[linux-2.6-omap-h63xx.git] / net / sunrpc / svc.c
index e673ef9939043edc4a2d7aac1bf0c745ebd22917..94eed9b800382321b1732d06b3e98d16bc615616 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/mm.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
+#include <linux/sched.h>
 
 #include <linux/sunrpc/types.h>
 #include <linux/sunrpc/xdr.h>
@@ -776,6 +777,30 @@ svc_register(struct svc_serv *serv, int proto, unsigned short port)
        return error;
 }
 
+/*
+ * Printk the given error with the address of the client that caused it.
+ */
+static int
+__attribute__ ((format (printf, 2, 3)))
+svc_printk(struct svc_rqst *rqstp, const char *fmt, ...)
+{
+       va_list args;
+       int     r;
+       char    buf[RPC_MAX_ADDRBUFLEN];
+
+       if (!net_ratelimit())
+               return 0;
+
+       printk(KERN_WARNING "svc: %s: ",
+               svc_print_addr(rqstp, buf, sizeof(buf)));
+
+       va_start(args, fmt);
+       r = vprintk(fmt, args);
+       va_end(args);
+
+       return r;
+}
+
 /*
  * Process the RPC request.
  */
@@ -814,7 +839,7 @@ svc_process(struct svc_rqst *rqstp)
        rqstp->rq_res.tail[0].iov_base = NULL;
        rqstp->rq_res.tail[0].iov_len = 0;
        /* Will be turned off only in gss privacy case: */
-       rqstp->rq_sendfile_ok = 1;
+       rqstp->rq_splice_ok = 1;
        /* tcp needs a space for the record length... */
        if (rqstp->rq_prot == IPPROTO_TCP)
                svc_putnl(resv, 0);
@@ -963,14 +988,13 @@ svc_process(struct svc_rqst *rqstp)
        return 0;
 
 err_short_len:
-       if (net_ratelimit())
-               printk("svc: short len %Zd, dropping request\n", argv->iov_len);
+       svc_printk(rqstp, "short len %Zd, dropping request\n",
+                       argv->iov_len);
 
        goto dropit;                    /* drop request */
 
 err_bad_dir:
-       if (net_ratelimit())
-               printk("svc: bad direction %d, dropping request\n", dir);
+       svc_printk(rqstp, "bad direction %d, dropping request\n", dir);
 
        serv->sv_stats->rpcbadfmt++;
        goto dropit;                    /* drop request */
@@ -1000,8 +1024,7 @@ err_bad_prog:
        goto sendit;
 
 err_bad_vers:
-       if (net_ratelimit())
-               printk("svc: unknown version (%d for prog %d, %s)\n",
+       svc_printk(rqstp, "unknown version (%d for prog %d, %s)\n",
                       vers, prog, progp->pg_name);
 
        serv->sv_stats->rpcbadfmt++;
@@ -1011,16 +1034,14 @@ err_bad_vers:
        goto sendit;
 
 err_bad_proc:
-       if (net_ratelimit())
-               printk("svc: unknown procedure (%d)\n", proc);
+       svc_printk(rqstp, "unknown procedure (%d)\n", proc);
 
        serv->sv_stats->rpcbadfmt++;
        svc_putnl(resv, RPC_PROC_UNAVAIL);
        goto sendit;
 
 err_garbage:
-       if (net_ratelimit())
-               printk("svc: failed to decode args\n");
+       svc_printk(rqstp, "failed to decode args\n");
 
        rpc_stat = rpc_garbage_args;
 err_bad:
@@ -1034,10 +1055,8 @@ err_bad:
  */
 u32 svc_max_payload(const struct svc_rqst *rqstp)
 {
-       int max = RPCSVC_MAXPAYLOAD_TCP;
+       u32 max = rqstp->rq_xprt->xpt_class->xcl_max_payload;
 
-       if (rqstp->rq_sock->sk_sock->type == SOCK_DGRAM)
-               max = RPCSVC_MAXPAYLOAD_UDP;
        if (rqstp->rq_server->sv_max_payload < max)
                max = rqstp->rq_server->sv_max_payload;
        return max;