Skip to content

Commit

Permalink
AX.25: Close socket connection on session completion
Browse files Browse the repository at this point in the history
A socket connection made in ax.25 is not closed when session is
completed.  The heartbeat timer is stopped prematurely and this is
where the socket gets closed. Allow heatbeat timer to run to close
socket. Symptom occurs in kernels >= 4.2.0

Originally sent 6/15/2016. Resend with distribution list matching
scripts/maintainer.pl output.

Signed-off-by: Basil Gunn <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
n7nix authored and davem330 committed Jun 19, 2016
1 parent 3bb549a commit 4a7d99e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion net/ax25/af_ax25.c
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,8 @@ static int ax25_release(struct socket *sock)
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:
Expand Down
5 changes: 4 additions & 1 deletion net/ax25/ax25_ds_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ void ax25_ds_heartbeat_expiry(ax25_cb *ax25)
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) ||
Expand All @@ -111,6 +112,7 @@ void ax25_ds_heartbeat_expiry(ax25_cb *ax25)
sock_hold(sk);
ax25_destroy_socket(ax25);
bh_unlock_sock(sk);
/* Ungrab socket and destroy it */
sock_put(sk);
} else
ax25_destroy_socket(ax25);
Expand Down Expand Up @@ -213,7 +215,8 @@ void ax25_ds_t1_timeout(ax25_cb *ax25)
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++;
Expand Down
5 changes: 4 additions & 1 deletion net/ax25/ax25_std_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void ax25_std_heartbeat_expiry(ax25_cb *ax25)

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) ||
Expand All @@ -47,6 +48,7 @@ void ax25_std_heartbeat_expiry(ax25_cb *ax25)
sock_hold(sk);
ax25_destroy_socket(ax25);
bh_unlock_sock(sk);
/* Ungrab socket and destroy it */
sock_put(sk);
} else
ax25_destroy_socket(ax25);
Expand Down Expand Up @@ -144,7 +146,8 @@ void ax25_std_t1timer_expiry(ax25_cb *ax25)
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++;
Expand Down
3 changes: 2 additions & 1 deletion net/ax25/ax25_subr.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ void ax25_disconnect(ax25_cb *ax25, int reason)
{
ax25_clear_queues(ax25);

ax25_stop_heartbeat(ax25);
if (!sock_flag(ax25->sk, SOCK_DESTROY))
ax25_stop_heartbeat(ax25);
ax25_stop_t1timer(ax25);
ax25_stop_t2timer(ax25);
ax25_stop_t3timer(ax25);
Expand Down

0 comments on commit 4a7d99e

Please sign in to comment.