[PATCH] sendfile() and UDP socket

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Johann Baudy
Date: Sunday, September 14, 2008 - 3:25 am

Hi All,

Sendfile() over UDP socket are currently limited to ~ 64KBytes file (max cork.length).
Indeed, if you run sendfile() with a file size > 64KBytes over UDP socket, system call will stop and return ~64KBytes without sending anything on the network.
This patch is pushing ongoing frames when frames buffer is full, to prevent overflow.

Signed-off-by: Johann Baudy <johann.baudy@gmail.com>

 net/ipv4/udp.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 8e42fbb..64e0857 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -743,7 +743,22 @@ int udp_sendpage(struct sock *sk, struct page *page, int offset,
 		 size_t size, int flags)
 {
 	struct udp_sock *up = udp_sk(sk);
+	struct inet_sock *inet = inet_sk(sk);
 	int ret;
+	int fragheaderlen;
+	struct ip_options *opt = NULL;
+
+	lock_sock(sk);
+	if (inet->cork.flags & IPCORK_OPT)
+		opt = inet->cork.opt;
+	fragheaderlen = sizeof(struct iphdr) + (opt ? opt->optlen : 0);
+
+	if (inet->cork.length + size >= 0xFFFF - fragheaderlen) {
+		ret = udp_push_pending_frames(sk);
+		if (ret)
+			goto out;
+	}
+	release_sock(sk);
 
 	if (!up->pending) {
 		struct msghdr msg = {	.msg_flags = flags|MSG_MORE };


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] sendfile() and UDP socket, Johann Baudy, (Sun Sep 14, 3:25 am)
Re: [PATCH] sendfile() and UDP socket, Simon Horman, (Mon Sep 15, 9:17 pm)
Re: [PATCH] sendfile() and UDP socket, Simon Horman, (Mon Sep 15, 9:24 pm)
Re: [PATCH] sendfile() and UDP socket, Hirokazu Takahashi, (Tue Sep 16, 5:01 am)
Re: [PATCH] sendfile() and UDP socket, Rémi Denis-Courmont, (Thu Sep 18, 10:31 am)
Re: [PATCH] sendfile() and UDP socket, Hirokazu Takahashi, (Fri Sep 19, 5:28 am)
Re: [PATCH] sendfile() and UDP socket, Rémi Denis-Courmont, (Fri Sep 19, 6:14 am)
Re: [PATCH] sendfile() and UDP socket, David Miller, (Sun Sep 21, 1:04 am)
Re: [PATCH] sendfile() and UDP socket, Evgeniy Polyakov, (Sun Sep 21, 5:21 pm)
Re: [PATCH] sendfile() and UDP socket, David Miller, (Sun Sep 21, 5:44 pm)
Re: [PATCH] sendfile() and UDP socket, Evgeniy Polyakov, (Sun Sep 21, 6:08 pm)
Re: [PATCH] sendfile() and UDP socket, David Miller, (Sun Sep 21, 7:07 pm)
Re: [PATCH] sendfile() and UDP socket, Evgeniy Polyakov, (Sun Sep 21, 9:19 pm)
Re: [PATCH] sendfile() and UDP socket, David Miller, (Sun Sep 21, 9:27 pm)
Re: [PATCH] sendfile() and UDP socket, Evgeniy Polyakov, (Sun Sep 21, 9:40 pm)
Re: [PATCH] sendfile() and UDP socket, David Miller, (Sun Sep 21, 10:06 pm)
Re: [PATCH] sendfile() and UDP socket, Evgeniy Polyakov, (Sun Sep 21, 10:49 pm)
Re: [PATCH] sendfile() and UDP socket, David Miller, (Sun Sep 21, 11:54 pm)
Re: [PATCH] sendfile() and UDP socket, Evgeniy Polyakov, (Mon Sep 22, 12:04 am)
Re: [PATCH] sendfile() and UDP socket, Herbert Xu, (Mon Sep 22, 9:54 pm)
Re: [PATCH] sendfile() and UDP socket, Evgeniy Polyakov, (Mon Sep 22, 11:27 pm)
Re: [PATCH] sendfile() and UDP socket, Herbert Xu, (Tue Sep 23, 12:01 am)
Re: [PATCH] sendfile() and UDP socket, Evgeniy Polyakov, (Tue Sep 23, 12:07 am)
Re: [PATCH] sendfile() and UDP socket, Bill Fink, (Tue Sep 23, 9:53 pm)
Using skb_get() to recycle skbs, Ram.Natarajan, (Thu Sep 25, 6:03 am)
Re: Using skb_get() to recycle skbs, Evgeniy Polyakov, (Thu Sep 25, 7:28 am)