Re: Recent 2.4.x PPP bug? (PPPIOCDETACH file->f_count=3)

From: Herbert Xu (herbert@gondor.apana.org.au)
Date: Wed Jan 01 2003 - 03:50:46 EST


Marek Michalkiewicz <marekm@amelek.gda.pl> wrote:
>
> Starting with recent 2.4.19 and 2.4.20 kernels, when any
> one (or both) of my two permanent PPP connections goes
> down (usually due to the ISP rebooting their equipment),
> quite often something bad happens.
>
> Dec 31 16:31:52 alf kernel: PPPIOCDETACH file->f_count=3
> Dec 31 16:31:52 alf kernel: PPPIOCDETACH file->f_count=3

I don't know the cause of this, but this patch should let
pppd continue to work:

-- 
Debian GNU/Linux 3.0 is out! ( http://www.debian.org/ )
Email:  Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
Index: sys-linux.c
===================================================================
RCS file: /var/cvs/snwb/packages/ppp/pppd/sys-linux.c,v
retrieving revision 1.1.1.1
retrieving revision 1.6
diff -u -r1.1.1.1 -r1.6
--- sys-linux.c	2002/07/25 03:42:01	1.1.1.1
+++ sys-linux.c	2002/10/14 01:53:01	1.6
@@ -531,10 +531,21 @@
     if (new_style_driver) {
 	close(ppp_fd);
 	ppp_fd = -1;
-	if (!looped && ifunit >= 0 && ioctl(ppp_dev_fd, PPPIOCDETACH) < 0)
-	    error("Couldn't release PPP unit: %m");
 	if (!multilink)
 	    remove_fd(ppp_dev_fd);
+	if (!looped && ifunit >= 0 && ioctl(ppp_dev_fd, PPPIOCDETACH) < 0) {
+	    int flags;
+
+	    error("Couldn't release PPP unit: %m");
+	    close(ppp_dev_fd);
+	    ppp_dev_fd = open("/dev/ppp", O_RDWR);
+	    if (ppp_dev_fd < 0)
+		fatal("Couldn't open /dev/ppp: %m");
+	    flags = fcntl(ppp_dev_fd, F_GETFL);
+	    if (flags == -1
+		|| fcntl(ppp_dev_fd, F_SETFL, flags | O_NONBLOCK) == -1)
+		warn("Couldn't set /dev/ppp to nonblock: %m");
+	}
     }
 }
 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Jan 07 2003 - 22:00:14 EST