AX25/socket kernel PATCHes

From: Henk de Groot (cqm@oce.cz)
Date: Fri Dec 28 2001 - 22:57:32 EET

  • Next message: Alan Cox: "Re: AX25/socket kernel PATCHes"

    Hello all,

    I just downloaded the latest 2.4.17 kernel and I still do not see the
    patches of Jeroen Vreeken, PE1RXQ, applied. Anybody know the reason why?

    Without these patches the 2.4 kernel completely locks-up my machine as soon
    as I start the FBB AX.25 BBS. Also other unrelated AX.25 tools do this,
    although they can run for a while until this happens. With the patches
    applied it is again rock solid as it was with earlier kernels.

    I don't want credit for this, Jeroen Vreeken, PE1RXQ, found the problems
    and designed these patches, but I would like to have this - or another fix
    for the kernel lockup with AX.25 - in the stock kernel so everybody will
    benefit. I just assembled the patches, made them work (they were somewhat
    damaged) and adjusted them for the 2.4.17 kernel.

    Kind regards,

    Henk.

    P.S. I'm not subscribed to linux-kernel, please forward if posting by
    non-members is not permitted.

    diff -ruN linux/net/ax25/af_ax25.c linux/net/ax25/af_ax25.c
    --- linux/net/ax25/af_ax25.c Fri Dec 28 21:25:36 2001
    +++ linux/net/ax25/af_ax25.c Fri Dec 28 21:26:35 2001
    @@ -102,6 +102,7 @@
       * Joerg(DL1BKE) Added support for SO_BINDTODEVICE
       * Arnaldo C. Melo s/suser/capable(CAP_NET_ADMIN)/, some more cleanups
       * Michal Ostrowski Module initialization cleanup.
    + * Jeroen(PE1RXQ) Use sock_orphan to set sk->dead.
       */

      #include <linux/config.h>
    @@ -423,7 +424,7 @@
              if (ax25->sk != NULL) {
                      while ((skb = skb_dequeue(&ax25->sk->receive_queue)) != NULL) {
                              if (skb->sk != ax25->sk) { /* A pending connection */
    - skb->sk->dead = 1; /* Queue the unaccepted socket for death */
    + sock_orphan(skb->sk); /* Queue the unaccepted socket for death */
                                      ax25_start_heartbeat(skb->sk->protinfo.ax25);
                                      skb->sk->protinfo.ax25->state = AX25_STATE_0;
                              }
    @@ -1018,7 +1019,7 @@
                                      sk->state = TCP_CLOSE;
                                      sk->shutdown |= SEND_SHUTDOWN;
                                      sk->state_change(sk);
    - sk->dead = 1;
    + sock_orphan(sk);
                                      sk->destroy = 1;
                                      break;

    @@ -1029,7 +1030,7 @@
                      sk->state = TCP_CLOSE;
                      sk->shutdown |= SEND_SHUTDOWN;
                      sk->state_change(sk);
    - sk->dead = 1;
    + sock_orphan(sk);
                      ax25_destroy_socket(sk->protinfo.ax25);
              }

    diff -ruN linux/net/core/datagram.c linux/net/core/datagram.c
    --- linux/net/core/datagram.c Fri Dec 28 21:25:36 2001
    +++ linux/net/core/datagram.c Fri Dec 28 21:26:35 2001
    @@ -442,7 +442,8 @@
              if (sock_writeable(sk))
                      mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
              else
    - set_bit(SOCK_ASYNC_NOSPACE, &sk->socket->flags);
    + if(sk->socket)
    + set_bit(SOCK_ASYNC_NOSPACE, &sk->socket->flags);

              return mask;
      }
    diff -ruN linux/net/ax25/ax25_ds_timer.c linux/net/ax25/ax25_ds_timer.c
    --- linux/net/ax25/ax25_ds_timer.c Fri Dec 28 21:25:36 2001
    +++ linux/net/ax25/ax25_ds_timer.c Fri Dec 28 21:26:35 2001
    @@ -162,7 +162,7 @@
                      ax25->sk->shutdown |= SEND_SHUTDOWN;
                      if (!ax25->sk->dead)
                              ax25->sk->state_change(ax25->sk);
    - ax25->sk->dead = 1;
    + sock_orphan(ax25->sk);
              }
      }

    diff -ruN linux/net/ax25/ax25_std_timer.c linux/net/ax25/ax25_std_timer.c
    --- linux/net/ax25/ax25_std_timer.c Fri Dec 28 21:25:36 2001
    +++ linux/net/ax25/ax25_std_timer.c Fri Dec 28 21:26:35 2001
    @@ -109,7 +109,7 @@
                      ax25->sk->shutdown |= SEND_SHUTDOWN;
                      if (!ax25->sk->dead)
                              ax25->sk->state_change(ax25->sk);
    - ax25->sk->dead = 1;
    + sock_orphan(ax25->sk);
              }
      }

    diff -ruN linux/net/ax25/ax25_subr.c linux/net/ax25/ax25_subr.c
    --- linux/net/ax25/ax25_subr.c Fri Dec 28 21:25:36 2001
    +++ linux/net/ax25/ax25_subr.c Fri Dec 28 21:26:35 2001
    @@ -310,6 +310,6 @@
                      ax25->sk->shutdown |= SEND_SHUTDOWN;
                      if (!ax25->sk->dead)
                              ax25->sk->state_change(ax25->sk);
    - ax25->sk->dead = 1;
    + sock_orphan(ax25->sk);
              }
      }
    diff -ruN linux/net/netrom/af_netrom.c linux/net/netrom/af_netrom.c
    --- linux/net/netrom/af_netrom.c Fri Dec 28 21:25:36 2001
    +++ linux/net/netrom/af_netrom.c Fri Dec 28 21:26:35 2001
    @@ -31,6 +31,7 @@
       * NET/ROM 007 Jonathan(G4KLX) New timer architecture.
       * Impmented Idle timer.
       * Arnaldo C. Melo s/suser/capable/, micro cleanups
    + * Jeroen (PE1RXQ) Use sock_orphan to set sk->dead.
       */

      #include <linux/config.h>
    @@ -316,7 +317,7 @@

              while ((skb = skb_dequeue(&sk->receive_queue)) != NULL) {
                      if (skb->sk != sk) { /* A pending connection */
    - skb->sk->dead = 1; /* Queue the unaccepted socket for death */
    + sock_orphan(skb->sk); /* Queue the unaccepted socket for death */
                              nr_start_heartbeat(skb->sk);
                              skb->sk->protinfo.nr->state = NR_STATE_0;
                      }
    @@ -572,9 +573,8 @@
                              sk->state = TCP_CLOSE;
                              sk->shutdown |= SEND_SHUTDOWN;
                              sk->state_change(sk);
    - sk->dead = 1;
    + sock_orphan(sk);
                              sk->destroy = 1;
    - sk->socket = NULL;
                              break;

                      default:
    diff -ruN linux/net/netrom/nr_subr.c linux/net/netrom/nr_subr.c
    --- linux/net/netrom/nr_subr.c Fri Dec 28 21:25:36 2001
    +++ linux/net/netrom/nr_subr.c Fri Dec 28 21:26:35 2001
    @@ -284,5 +284,5 @@
              if (!sk->dead)
                      sk->state_change(sk);

    - sk->dead = 1;
    + sock_orphan(sk);
      }
    diff -ruN linux/net/netrom/nr_timer.c linux/net/netrom/nr_timer.c
    --- linux/net/netrom/nr_timer.c Fri Dec 28 21:25:37 2001
    +++ linux/net/netrom/nr_timer.c Fri Dec 28 21:26:35 2001
    @@ -201,7 +201,7 @@
              if (!sk->dead)
                      sk->state_change(sk);

    - sk->dead = 1;
    + sock_orphan(sk);
      }

      static void nr_t1timer_expiry(unsigned long param)
    diff -ruN linux/net/core/sock.c linux/net/core/sock.c
    --- linux/net/core/sock.c Fri Dec 28 21:25:37 2001
    +++ linux/net/core/sock.c Fri Dec 28 21:26:35 2001
    @@ -81,6 +81,7 @@
       * Andi Kleen : Fix write_space callback
       * Chris Evans : Security fixes - signedness again
       * Arnaldo C. Melo : cleanups, use skb_queue_purge
    + * Jeroen Vreeken : Add check for sk->dead in sock_def_write_space
       *
       * To Fix:
       *
    @@ -1146,7 +1147,7 @@
              /* Do not wake up a writer until he can make "significant"
               * progress. --DaveM
               */
    - if((atomic_read(&sk->wmem_alloc) << 1) <= sk->sndbuf) {
    + if(!sk->dead && (atomic_read(&sk->wmem_alloc) << 1) <= sk->sndbuf) {
                      if (sk->sleep && waitqueue_active(sk->sleep))
                              wake_up_interruptible(sk->sleep);

    -
    To unsubscribe from this list: send the line "unsubscribe linux-hams" in
    the body of a message to kom.ncon@nadoma.net
    More majordomo info at http://vger.kernel.org/majordomo-info.html



    This archive was generated by hypermail 2b30 : Fri Dec 28 2001 - 23:02:28 EET