michael@75: Index: linux/2.2/tun.c michael@75: --- linux/2.2/tun.c.orig 2006-10-10 14:45:00.338589000 +0200 michael@75: +++ linux/2.2/tun.c 2006-10-10 14:44:05.695404000 +0200 michael@75: @@ -178,10 +178,22 @@ michael@75: michael@75: DBG( KERN_INFO "%s: tun_chr_poll\n", tun->name); michael@75: michael@75: + /* Data written to the /dev/tunX device is immediately placed into a socket buffer, making it michael@75: + * available to networking code at the tunX interface. Writes never block. michael@75: + * Likewise, data flows from the network stack, through the tunX interface and into the /dev/tun* device, michael@75: + * where it is queued, making it available for read(). michael@75: + * Thus the character device /dev/tunX is: michael@75: + * - readable if data was "transmitted" to the tunX interface and is now queued at the /dev/tunX device. michael@75: + * - always writable. michael@75: + * Everything written here is equally true of taps. michael@75: + * The author made a mistake when implementing this routine; he forgot that the device is always writable. michael@75: + * -jeff stearns 22-Dec-2005 michael@75: + */ michael@75: + michael@75: poll_wait(file, &tun->read_wait, wait); michael@75: michael@75: if( skb_queue_len(&tun->txq) ) michael@75: - return POLLIN | POLLRDNORM; michael@75: + return POLLIN | POLLRDNORM | POLLOUT | POLLWRNORM; michael@75: michael@75: return POLLOUT | POLLWRNORM; michael@75: } michael@75: Index: linux/2.4/tun.c michael@75: --- linux/2.4/tun.c.orig 2006-10-10 14:41:57.910408000 +0200 michael@75: +++ linux/2.4/tun.c 2006-10-10 14:43:40.067700000 +0200 michael@75: @@ -176,9 +176,21 @@ michael@75: DBG(KERN_INFO "%s: tun_chr_poll\n", tun->name); michael@75: michael@75: poll_wait(file, &tun->read_wait, wait); michael@75: + michael@75: + /* Data written to the /dev/tunX device is immediately placed into a socket buffer, making it michael@75: + * available to networking code at the tunX interface. Writes never block. michael@75: + * Likewise, data flows from the network stack, through the tunX interface and into the /dev/tun* device, michael@75: + * where it is queued, making it available for read(). michael@75: + * Thus the character device /dev/tunX is: michael@75: + * - readable if data was "transmitted" to the tunX interface and is now queued at the /dev/tunX device. michael@75: + * - always writable. michael@75: + * Everything written here is equally true of taps. michael@75: + * The author made a mistake when implementing this routine; he forgot that the device is always writable. michael@75: + * -jeff stearns 22-Dec-2005 michael@75: + */ michael@75: michael@75: if (skb_queue_len(&tun->txq)) michael@75: - return POLLIN | POLLRDNORM; michael@75: + return POLLIN | POLLRDNORM | POLLOUT | POLLWRNORM; michael@75: michael@75: return POLLOUT | POLLWRNORM; michael@75: }