netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sendfile() and UDP socket
@ 2008-09-14 10:25 Johann Baudy
  2008-09-16  4:17 ` Simon Horman
                   ` (2 more replies)
  0 siblings, 3 replies; 29+ messages in thread
From: Johann Baudy @ 2008-09-14 10:25 UTC (permalink / raw)
  To: netdev; +Cc: David Miller

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 };



^ permalink raw reply related	[flat|nested] 29+ messages in thread
* [PATCH] sendfile() and UDP socket
@ 2008-09-10 12:39 Johann Baudy
  2008-09-10 20:16 ` David Miller
  0 siblings, 1 reply; 29+ messages in thread
From: Johann Baudy @ 2008-09-10 12:39 UTC (permalink / raw)
  To: netdev; +Cc: Evgeniy Polyakov

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 56fcda3..d019e13 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 };

^ permalink raw reply related	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2008-10-14  7:10 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-14 10:25 [PATCH] sendfile() and UDP socket Johann Baudy
2008-09-16  4:17 ` Simon Horman
2008-09-16  4:24   ` Simon Horman
2008-09-16 12:01 ` Hirokazu Takahashi
2008-09-18 17:31   ` Rémi Denis-Courmont
2008-09-19 12:28     ` Hirokazu Takahashi
2008-09-19 13:14       ` Rémi Denis-Courmont
2008-09-21  8:04 ` David Miller
2008-09-22  0:21   ` Evgeniy Polyakov
2008-09-22  0:44     ` David Miller
2008-09-22  1:08       ` Evgeniy Polyakov
2008-09-22  2:07         ` David Miller
2008-09-22  4:19           ` Evgeniy Polyakov
2008-09-22  4:27             ` David Miller
2008-09-22  4:40               ` Evgeniy Polyakov
2008-09-22  5:06                 ` David Miller
2008-09-22  5:49                   ` Evgeniy Polyakov
2008-09-22  6:54                     ` David Miller
2008-09-22  7:04                       ` Evgeniy Polyakov
2008-09-23  4:54                         ` Herbert Xu
2008-09-23  6:27                           ` Evgeniy Polyakov
2008-09-23  7:01                             ` Herbert Xu
2008-09-23  7:07                               ` Evgeniy Polyakov
2008-09-24  4:53                               ` Bill Fink
     [not found]                                 ` <7e0dd21a0810140009k49c8876ax66f744d0a3a4931b@mail.gmail.com>
2008-10-14  7:10                                   ` Johann Baudy
2008-09-25 13:03             ` Using skb_get() to recycle skbs Ram.Natarajan
2008-09-25 14:28               ` Evgeniy Polyakov
  -- strict thread matches above, loose matches on Subject: below --
2008-09-10 12:39 [PATCH] sendfile() and UDP socket Johann Baudy
2008-09-10 20:16 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).