Re: PPP and 1.3.66

Leonard N. Zubkoff (lnz@dandelion.com)
Mon, 19 Feb 1996 11:13:16 -0800


Date: Mon, 19 Feb 1996 02:25:49 -0500 (EST)
From: Jon Lewis <jlewis@inorganic5.fdt.net>

On Sun, 18 Feb 1996 d-seaman@ukans.edu wrote:

> Today when my PPP connection died because my modem hung up (which happens
> a lot) I got these messages in my log (which has never happened before):
>
> Feb 18 14:22:48 hobbes pppd[395]: Hangup (SIGHUP)
> Feb 18 14:22:48 hobbes pppd[395]: ioctl(PPPIOCSASYNCMAP): I/O error
> Feb 18 14:22:48 hobbes pppd[395]: ioctl(PPPIOCGDEBUG): I/O error
> Feb 18 14:22:48 hobbes pppd[395]: ioctl(TIOCSETD): I/O error
> Feb 18 14:22:48 hobbes pppd[395]: ioctl(TIOCNXCL): I/O error
> Feb 18 14:22:48 hobbes pppd[395]: Exit.
>
> Nothing major, since the link was dead anyway, but these I/O error have
> never appeared. And this is the first time my PPP link has died under

What planet do you usually run pppd on? I've always gotten exactly
those messages since I started using pppd and Linux. I'd assumed they
were normal. I get them just the same on every linux box I've run pppd
on...though I've not tried pppd 2.2 or pppd+1.3.x yet.

I used to also, until I got annoyed with them filling up my log files. The
following patch against ppp-2.1.2d should correct that, along with allowing
pppd to run out of inittab cleanly. It also makes sure to reset the terminal
modes correctly.

Leonard

--- ppp-2.1.2d/pppd/sys-linux.c- Fri May 26 22:37:37 1995
+++ ppp-2.1.2d/pppd/sys-linux.c Sat Jun 3 23:46:42 1995
@@ -133,6 +133,8 @@
int x;
char *s;

+ if (ioctl(fd, TIOCGETD, &x) < 0 || x != N_PPP) return;
+
if (initdisc >= 0) {
set_kdebugflag (prev_kdebugflag);
/*
@@ -218,6 +220,8 @@
{
u_int x;
struct ifreq ifr;
+
+ if (ioctl(fd, TIOCGETD, &x) < 0 || x != N_PPP) return;

MAINDEBUG ((LOG_DEBUG, "send_config: mtu = %d\n", mtu));
strncpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
@@ -270,6 +274,8 @@
{
u_int x;

+ if (ioctl(fd, TIOCGETD, &x) < 0 || x != N_PPP) return;
+
MAINDEBUG ((LOG_DEBUG, "recv_config: mru = %d\n", mru));
if (ioctl(fd, PPPIOCSMRU, (caddr_t) &mru) < 0)
syslog(LOG_ERR, "ioctl(PPPIOCSMRU): %m");
@@ -644,6 +650,7 @@
{
struct rtentry rt;

+ memset (&rt, '\0', sizeof (rt));
SET_SA_FAMILY (rt.rt_dst, AF_INET);
SET_SA_FAMILY (rt.rt_gateway, AF_INET);
((struct sockaddr_in *) &rt.rt_gateway)->sin_addr.s_addr = gateway;
--- ppp-2.1.2d/pppd/ipcp.c- Fri May 26 22:37:37 1995
+++ ppp-2.1.2d/pppd/ipcp.c Sat Jun 3 23:27:29 1995
@@ -995,8 +995,18 @@
return;
}

+#ifdef VERBOSE
syslog(LOG_NOTICE, "local IP address %s", ip_ntoa(go->ouraddr));
syslog(LOG_NOTICE, "remote IP address %s", ip_ntoa(ho->hisaddr));
+#else
+ {
+ char OurAddress[64], HisAddress[64];
+ strcpy(OurAddress, ip_ntoa(go->ouraddr));
+ strcpy(HisAddress, ip_ntoa(ho->hisaddr));
+ syslog(LOG_NOTICE, "IPCP: %s (local) <--> %s (remote)",
+ OurAddress, HisAddress);
+ }
+#endif

/*
* Set IP addresses and (if specified) netmask.
--- ppp-2.1.2d/pppd/main.c- Fri May 26 22:39:58 1995
+++ ppp-2.1.2d/pppd/main.c Tue Jun 13 20:25:57 1995
@@ -39,7 +39,7 @@
* /etc/ppp/options exists.
*/
#ifndef REQ_SYSOPTIONS
-#define REQ_SYSOPTIONS 1
+#define REQ_SYSOPTIONS 0
#endif

#ifdef SGTTY
@@ -217,6 +217,7 @@

pid = getpid();
uid = getuid();
+ pgrpid = getpgrp();

if (!ppp_available()) {
fprintf(stderr, "Sorry - PPP is not available on this system\n");
@@ -404,17 +405,22 @@
/* drop dtr to hang up in case modem is off hook */
if (!default_device && modem) {
setdtr(fd, FALSE);
- sleep(1);
+ sleep(2);
setdtr(fd, TRUE);
+ sleep(2);
}

if (device_script(connector, fd, fd) < 0) {
+#ifdef VERBOSE
syslog(LOG_ERR, "could not set up connection");
+#endif
setdtr(fd, FALSE);
die(1);
}

+#ifdef VERBOSE
syslog(LOG_INFO, "Connected...");
+#endif
sleep(1); /* give it time to set up its terminal */
}

@@ -424,7 +430,9 @@
/* set up the serial device as a ppp interface */
establish_ppp();

+#ifdef VERBOSE
syslog(LOG_INFO, "Using interface ppp%d", ifunit);
+#endif
(void) sprintf(ifname, "ppp%d", ifunit);

/* write pid to file */
@@ -500,7 +508,9 @@
die(1);
}

+#ifdef VERBOSE
syslog(LOG_INFO, "Disconnected...");
+#endif
}

quit();
@@ -752,7 +762,9 @@
int status;
{
cleanup(0, NULL);
+#ifdef VERBOSE
syslog(LOG_INFO, "Exit.");
+#endif
exit(status);
}

@@ -778,8 +790,14 @@

if (restore_term) {
#ifndef SGTTY
- if (tcsetattr(fd, TCSAFLUSH, &inittermios) < 0)
- syslog(LOG_WARNING, "tcsetattr: %m");
+ if (tcsetattr(fd, TCSAFLUSH, &inittermios) < 0) {
+ close(fd);
+ /* Reopen device if hangup disassociated it. */
+ if ((fd = open(devname, O_RDWR | O_NDELAY)) < 0)
+ syslog(LOG_ERR, "open(%s): %m", devname);
+ if (tcsetattr(fd, TCSAFLUSH, &inittermios) < 0)
+ syslog(LOG_WARNING, "tcsetattr: %m");
+ }
#else
if (ioctl(fd, TIOCSETP, &initsgttyb) < 0)
syslog(LOG_WARNING, "ioctl(TIOCSETP): %m");
@@ -961,7 +979,7 @@
hup(sig)
int sig;
{
- syslog(LOG_INFO, "Hangup (SIGHUP)");
+ syslog(LOG_INFO, "Hangup on %s (SIGHUP)", ifname);

hungup = 1; /* they hung up on us! */
persist = 0; /* don't try to restart */
@@ -980,7 +998,9 @@
term(sig)
int sig;
{
+#ifdef VERBOSE
syslog(LOG_INFO, "Terminating link.");
+#endif
persist = 0; /* don't try to restart */
adjtimeout(); /* Adjust timeouts */
lcp_close(0); /* Close connection */