Can only connect to RMS gateway once
Quoted 2 lines
Have you tried to disable smp (in grub, boot the kernel with the cmdline option nosmp)? Did then the problem still occur?
I disabled SMP and the problem of socket remains open after disconnect still occurs with kernels >= 4.2.
cat /boot/cmdline.txt
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes maxcpus=0 rootwait
I built a 4.1.21 kernel from the raspbian repo
https://github.com/raspberrypi/linux/tree/rpi-4.1.y
and the problem does NOT exist with that kernel.
I built a 4.2.8 kernel from the raspbian repo
https://github.com/raspberrypi/linux/tree/rpi-4.2.y
and the problem DOES exist with that kernel. Showing connection listening after final disconnect.
Active AX.25 sockets
Dest Source Device State Vr/Vs Send-Q Recv-Q N7NIX-0 N7NIX-11 ax0 LISTENING 001/004 0 0 * N7NIX-11 ax0 LISTENING 000/000 0 0
/Basil n7nix
Hey Basil,
Thanks for digging into this. Few things to check:
GOOD - the 4.1.21 kernel was released on 4/6/16
BAD - 4.2.8 kernel was released on 12/16/15
Can you try a vanilla kernel with:
- 4.2.7, released on 12/9/16 to see if that's OK
- 4.1.25, released on 5/23/16 to see if that's ok? (a worse case
4.1.x test)
If 4.1.25 is bad:
- Try 4.1.14, released on 12/9/15 to see if that's ok?
If that's ok, try:
- 4.1.15 released on 12/15/15
- 4.1.16 released on 1/23/16
--David
Quoted 26 lines · Basil Gunn
Quoted 2 lines
Have you tried to disable smp (in grub, boot the kernel with the cmdline option nosmp)? Did then the problem still occur?
I disabled SMP and the problem of socket remains open after disconnect still occurs with kernels >= 4.2.
cat
/boot/cmdline.txt
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes maxcpus=0 rootwaitI built a 4.1.21 kernel from the raspbian repo
https://github.com/raspberrypi/linux/tree/rpi-4.1.yand the problem does NOT exist with that kernel.
I built a 4.2.8 kernel from the raspbian repo
https://github.com/raspberrypi/linux/tree/rpi-4.2.yand the problem DOES exist with that kernel. Showing connection listening after final disconnect.
Active AX.25 sockets
Dest Source Device State Vr/Vs Send-Q Recv-Q N7NIX-0 N7NIX-11 ax0 LISTENING 001/004 0 0 * N7NIX-11 ax0 LISTENING 000/000 0 0
This isn't a final solution but the problem is in:
sock_set_flag(sk, SOCK_DESTROY);
in routine ax25_release() in file net/ax25/af_ax25.c which does what it is supposed to do in kernel 4.1.21 but NOT in kernels 4.2.8 & above. It should destroy & free the socket when disconnecting.
For my 4.2.8 kernel If I add this after the sock_set_flag() call in ax25_release() then the connection is released after disconnect & I can reconnect again.
release_sock(sk);
ax25_disconnect(ax25, 0);
lock_sock(sk);
ax25_destroy_socket(ax25);From the af_ax25 code in the 4.1.21 kernel, it expects sock_set_flag(sk, SOCK_DESTROY); to
ax25_destroy_socket
ax25_free_sock
Quoted 1 line
/Basil n7nix
+ David Miller for comments
I see a change on June 25, 2015, and a few others on that file that seem like they could be the issue:
https://github.com/torvalds/linux/commits/master/net/ax25/af_ax25.c
--David
Quoted 27 lines · Basil Gunn
This isn't a final solution but the problem is in:
sock_set_flag(sk, SOCK_DESTROY);in routine
ax25_release()in filenet/ax25/af_ax25.cwhich does what it is supposed to do in kernel 4.1.21 but NOT in kernels 4.2.8 & above. It should destroy & free the socket when disconnecting.For my 4.2.8 kernel If I add this after the
sock_set_flag()call inax25_release()then the connection is released after disconnect & I can reconnect again.release_sock(sk); ax25_disconnect(ax25, 0); lock_sock(sk); ax25_destroy_socket(ax25);Quoted 1 line
From the
af_ax25code in the 4.1.21 kernel, it expectssock_set_flag(sk, SOCK_DESTROY); to
ax25_destroy_socket
ax25_free_sockQuoted 1 line
/Basil n7nix
--
To unsubscribe from this list: send the line "unsubscribe linux-hams" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
It looks like the SOCK_DESTROY flag should be serviced off the ax25_ds_timer or ax25_std_timer but that's not happening.
/Basil
Quoted 37 lines · On Sat, 4 Jun 2016 13:57:17 -0700 David Ranch <[email protected]> wrote:
+ David Miller for comments
I see a change on June 25, 2015, and a few others on that file that seem like they could be the issue:
https://github.com/torvalds/linux/commits/master/net/ax25/af_ax25.c
--David
Quoted 23 lines · Basil Gunn
This isn't a final solution but the problem is in:
sock_set_flag(sk, SOCK_DESTROY);in routine
ax25_release()in filenet/ax25/af_ax25.cwhich does what it is supposed to do in kernel 4.1.21 but NOT in kernels 4.2.8 & above. It should destroy & free the socket when disconnecting.For my 4.2.8 kernel If I add this after the
sock_set_flag()call inax25_release()then the connection is released after disconnect & I can reconnect again.release_sock(sk); ax25_disconnect(ax25, 0); lock_sock(sk); ax25_destroy_socket(ax25);Quoted 2 lines
From the
af_ax25code in the 4.1.21 kernel, it expectssock_set_flag(sk, SOCK_DESTROY); to
ax25_destroy_socket
ax25_free_sockQuoted 1 line
/Basil n7nix
Below is a unified diff of the 4 files I changed in kernel 4.2.y from the Raspbian repo. At least for my case this fixed the problem of an open socket not getting closed & preventing anymore connections from the original connection callsign. In newer kernels (after 4.1.21) an ax25_ disconnect was occurring and stopping the heartbeat timer. The socket free code runs off the heartbeat timer.
/Basil Gunn n7nix
home/gunn/projects/rpi/rpi-4.2.y.dev/net/ax25/af_ax25.c renamed from af_ax25.c +3 -1
@@ -973,7 +973,9 @@release_sock (sk);ax25_disconnect (ax25,0 );lock_sock (sk); -ax25_destroy_socket (ax25); +if (!sock_flag (ax25->sk,SOCK_DESTROY )) { +ax25_destroy_socket (ax25); + }break ;case AX25_STATE_3 :
home/gunn/projects/rpi/rpi-4.2.y.dev/net/ax25/ax25_ds_timer.c renamed from ax25_ds_timer.c +4 -1
@@ -101,7 +101,8 @@switch (ax25->state) { -case AX25_STATE_0 : +case AX25_STATE_0 : +case AX25_STATE_2 :/* Magic here: If we listen() and a new link dies before it is accepted() it isn't 'dead' so doesn't get removed. */ if (!sk || sock_flag(sk, SOCK_DESTROY) ||
@@ -112,6 +113,8 @@ax25_destroy_socket (ax25);bh_unlock_sock (sk);sock_put (sk); +ax25_cb_put (sk_to_ax25 (sk)); + }else ax25_destroy_socket (ax25);return ;
home/gunn/projects/rpi/rpi-4.2.y.dev/net/ax25/ax25_std_timer.c renamed from ax25_std_timer.c +5 -1
@@ -38,6 +38,7 @@switch (ax25->state) {case AX25_STATE_0 : +case AX25_STATE_2 :/* Magic here: If we listen() and a new link dies before it is accepted() it isn't 'dead' so doesn't get removed. */ if (!sk || sock_flag(sk, SOCK_DESTROY) ||
@@ -48,6 +49,7 @@ax25_destroy_socket (ax25);bh_unlock_sock (sk);sock_put (sk); +ax25_cb_put (sk_to_ax25 (sk)); }else ax25_destroy_socket (ax25);return ;
@@ -144,7 +146,9 @@case AX25_STATE_2 :if (ax25->n2count == ax25->n2) {ax25_send_control (ax25,AX25_DISC ,AX25_POLLON ,AX25_COMMAND ); -ax25_disconnect (ax25,ETIMEDOUT ); + +if (!sock_flag (ax25->sk,SOCK_DESTROY )) +ax25_disconnect (ax25,ETIMEDOUT );return ; }else { ax25->n2count++;
home/gunn/projects/rpi/rpi-4.2.y.dev/net/ax25/ax25_subr.c renamed from ax25_subr.c +3 -2
@@ -262,9 +262,10 @@void ax25_disconnect (ax25_cb *ax25,int reason) { -ax25_clear_queues (ax25); -ax25_stop_heartbeat (ax25); +ax25_clear_queues (ax25); +if (!sock_flag (ax25->sk,SOCK_DESTROY )) +ax25_stop_heartbeat (ax25);ax25_stop_t1timer (ax25);ax25_stop_t2timer (ax25);ax25_stop_t3timer (ax25);
---------------------------------------
Quoted 4 lines · On Sat, 4 Jun 2016 14:32:14 -0700 Basil Gunn <[email protected]> wrote:
It looks like the
SOCK_DESTROYflag should be serviced off theax25_ds_timerorax25_std_timerbut that's not happening./Basil