Skip to contentSkip to conversation

be sure to close /dev/ppp when reconnecting

PATCH In review Marco d'Itri 2 participants 2 messages Aug 19, 2007 PPP protocol drivers and compressors

lore
Share & tools
lore
#0 lore raw

PATCH 3/14 be sure to close /dev/ppp when reconnecting

From: Simon Peter <[email protected]>
Subject: [patch 03/14] Bug#306261: pppd does not properly close /dev/ppp on persist

When using the kernel PPPoE driver, pppd never
closes /dev/ppp when the link has come down.

It opens superfluous fds to the device each time it re-opens the connection, with the unclosed ones falsely reported always ready for data by select().

This makes pppd eat up 100% CPU time after the first persist because of the always instantly returning select() on the unclosed fds.

The problem also occurs with the upstream version, but does not occur when a pty/tty device is used for the ppp connection.

pppd/sys-linux.c +7 -0
diff -u -r ppp-2.4.3/pppd/sys-linux.c ppp-2.4.3/pppd/sys-linux.c
@@ -455,6 +455,13 @@
     if (new_style_driver) {
 	int flags;
 
+        /* if a ppp_fd is already open, close it first */
+        if(ppp_fd > 0) {
+          close(ppp_fd);
+          remove_fd(ppp_fd);
+          ppp_fd = -1;
+        }
+
 	/* Open an instance of /dev/ppp and connect the channel to it */
 	if (ioctl(fd, PPPIOCGCHAN, &chindex) = -1) {
 	    error("Couldn't get channel number: %m");
Signature · 2 lines
ciao,
Marco
#1 lore raw
Quoted 5 lines · Marco d'Itri

From: Simon Peter <[email protected]>
Subject: [patch 03/14] Bug#306261: pppd does not properly close /dev/ppp on persist

When using the kernel PPPoE driver, pppd never
closes /dev/ppp when the link has come down.

If that's true, I'd rather find out where it should be closing things but isn't.

Quoted 6 lines

It opens superfluous fds to the device each time it re-opens the connection, with the unclosed ones falsely reported always ready for data by select().

This makes pppd eat up 100% CPU time after the first persist because of the always instantly returning select() on the unclosed fds.

I use pppd with the kernel pppoe driver and persist mode and I have never seen this problem, so there must be more to it than this.

Paul.