[patch] Fix wrong behaviour of PPP/SLIP network interfaces in 2.2.14

From: Stanislav V. Voronyi (stas@esc.kharkov.com)
Date: Wed Feb 02 2000 - 18:00:13 EST


        I work at quite big ISP all running linux and after
upgrade from 2.0 to 2.2 kernel we found a problem: if pppd or
slcall was killed by SIGKILL for instance, network interface
still up and it is very bad for Radius server because Radius
decide that IP# which was used on this interface freed and can
be used further. But since interface still UP gated continued
to announce this address through OSPF.
        From other side if I would do ifconfig pppXX down or
ifconfig slXX down control programm (pppd or slcall) receive
no notification about it. If slip driver compiled with my
CONFIG_SLIP_SMART option and keepalive function activated
it will force hangup after keepalive timeout. For ppp or slip
without keepalive option activated control programm still
running until modem force hangup by inactivity timer.

        I've made small patch that fix both this problem.
This patch was tested on our modem pool on machine with
40 tty lines and several thousand calls a day and it work
without any problem.

        Here is the patch for clean 2.2.14 kernel:

diff -u --recursive work/v2.2/linux.dist/CREDITS linux-2.2.14/CREDITS
--- work/v2.2/linux.dist/CREDITS Tue Jan 4 20:12:10 2000
+++ linux-2.2.14/CREDITS Thu Jan 27 00:31:52 2000
@@ -2116,6 +2116,16 @@
 S: Moorhead, Minnesota 56560
 S: USA
 
+N: Stanislav Voronyi
+E: stas@esc.kharkov.com
+D: SLIP linefill/keepalive option
+D: SLIP/PPP interface behaviour fix
+D: Console driver hacks
+D: AWE 3DSE support
+W: http://esc.kharkov.com/stas/
+S: ap4, 5, Kashuby st.
+S: Kharkov, Ukraine, 61034
+
 N: Jos Vos
 E: jos@xos.nl
 W: http://www.xos.nl/
diff -u --recursive work/v2.2/linux.dist/drivers/net/ppp.c linux-2.2.14/drivers/net/ppp.c
--- work/v2.2/linux.dist/drivers/net/ppp.c Wed Oct 27 03:53:40 1999
+++ linux-2.2.14/drivers/net/ppp.c Sun Jan 30 13:45:25 2000
@@ -421,6 +421,10 @@
  * Called when the line discipline is changed to something
  * else, the tty is closed, or the tty detects a hangup.
  */
+/*
+ * Sane behaviour on interface down / line discipline change
+ * -- Stanislav Voronyi (VSV).
+ */
 
 static void
 ppp_tty_close (struct tty_struct *tty)
@@ -439,6 +443,7 @@
                 ppp->tty = ppp->backup_tty = 0;
                 return;
         }
+
         if (tty == ppp->backup_tty)
                 ppp->backup_tty = 0;
         if (tty != ppp->tty)
@@ -457,6 +462,14 @@
 
                 ppp_async_release(ppp);
                 ppp_release(ppp);
+
+ /* down interface if it is still UP */
+ if (ppp2dev(ppp)->start) {
+ dev_close(ppp2dev(ppp));
+ unregister_netdevice(ppp2dev(ppp));
+ }
+ /* VSV end */
+
                 MOD_DEC_USE_COUNT;
         }
 }
@@ -1532,6 +1545,8 @@
                 printk(KERN_ERR "ppp: %s not active\n", dev->name);
                 return -ENXIO;
         }
+ dev->tbusy = 0;
+ dev->start = 1;
 
         MOD_INC_USE_COUNT;
 
@@ -1548,6 +1563,13 @@
         struct ppp *ppp = dev2ppp (dev);
 
         CHECK_PPP_MAGIC(ppp);
+ dev->tbusy = 1;
+ dev->start = 0;
+
+ /* if interface going down first -> force hangup
+ -- Stanislav Voronyi. */
+ if (ppp->tty)
+ tty_hangup(ppp->tty);
 
         MOD_DEC_USE_COUNT;
 
Only in linux-2.2.14/drivers/net/sk98lin: .depend
diff -u --recursive work/v2.2/linux.dist/drivers/net/slip.c linux-2.2.14/drivers/net/slip.c
--- work/v2.2/linux.dist/drivers/net/slip.c Wed Oct 27 03:53:40 1999
+++ linux-2.2.14/drivers/net/slip.c Sun Jan 30 13:05:16 2000
@@ -52,6 +52,7 @@
  * have been ported to Linux SLIP driver.
  * Vitaly E. Lavrov : Sane behaviour on tty hangup.
  * Alexey Kuznetsov : Cleanup interfaces to tty&netdevice modules.
+ * Stanislav Voronyi : Sane behaviour on interface down / line discipline change
  */
 
 #define SL_CHECK_TRANSMIT
@@ -550,6 +551,10 @@
         sl->rcount = 0;
         sl->xleft = 0;
         end_bh_atomic();
+ /* If netdevice going down first -> force hangup
+ -- Stanislav Voronyi */
+ if (sl->tty)
+ tty_hangup(sl->tty);
 
         MOD_DEC_USE_COUNT;
         return 0;
@@ -924,6 +929,14 @@
    I see no way to make more with current tty code. --ANK
  */
 
+/*
+ I found that this function called from tty_set_ldisc()
+ and tty_hangup() before setting new discipline.
+ So we can close netdevice if line discipline was changed.
+ -- Stanislav Voronyi.
+*/
+
+
 /*
  * Close down a SLIP channel.
  * This means flushing out any pending queues, and then restoring the
@@ -943,6 +956,14 @@
         sl->tty = NULL;
         if (!sl->leased)
                 sl->line = 0;
+
+ /* VSV down interface if it is active
+ we do it after sl->tty = NULL; to prevent loop */
+ if ( sl->dev->start ){
+ dev_close(sl->dev);
+ unregister_netdevice(sl->dev);
+ }
+ /* VSV end */
 
         /* VSV = very important to remove timers */
 #ifdef CONFIG_SLIP_SMART

-- 
Stanislav V. Voroniy                            |Tel. +380 (572) 128302
Head of System Administration Department        |                210901
Centre of Information Technologies "Vostok" Ltd.|Fax. +380 (572) 213117

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Feb 07 2000 - 21:00:08 EST