[PATCH] Fix PPTP connections drop

Christoph Biedl <[email protected]> Thu, 7 Feb 2013 00:38:47 +0100
Newsgroups gmane.network.poptop
Message-ID <[email protected]>
Description: Fix PPTP connections drop
Origin: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=692129#22
Author: Maximiliano Curia <[email protected]>
Bug-Debian: http://bugs.debian.org/629129

--- a/pptpgre.c
+++ b/pptpgre.c
@@ -443,6 +443,7 @@
 		unsigned char buffer[PACKET_MAX + sizeof(struct pptp_gre_header)];
 	} u;
 	unsigned header_len;
+	ssize_t status;
 #ifdef HAVE_WRITEV
 	struct iovec iovec[2];
 #endif
@@ -493,12 +494,18 @@
 	iovec[0].iov_len = header_len;
 	iovec[1].iov_base = pack;
 	iovec[1].iov_len = len;
-	return writev(fd, iovec, 2);
+	status = writev(fd, iovec, 2); 
 #else
 	/* copy payload into buffer */
 	memcpy(u.buffer + header_len, pack, len);
 	/* record and increment sequence numbers */
 	/* write this baby out to the net */
-	return write(fd, u.buffer, header_len + len);
+	status = write(fd, u.buffer, header_len + len);
 #endif
+	if ((status >= 0) || (errno != ENOBUFS)) {
+		return status;
+	}
+	// if ENOBUFS, do not close the connection
+	gre.seq_sent--;
+	return 0;
 }

------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb