Skip to content

Commit

Permalink
net/x25: fix restart request/confirm handling
Browse files Browse the repository at this point in the history
We have to take the actual link state into account to handle
restart requests/confirms well.

Signed-off-by: Martin Schiller <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
sch-m authored and kuba-moo committed Nov 28, 2020
1 parent 62480b9 commit d023b2b
Showing 1 changed file with 33 additions and 8 deletions.
41 changes: 33 additions & 8 deletions net/x25/x25_link.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,43 @@ void x25_link_control(struct sk_buff *skb, struct x25_neigh *nb,

switch (frametype) {
case X25_RESTART_REQUEST:
confirm = !x25_t20timer_pending(nb);
x25_stop_t20timer(nb);
nb->state = X25_LINK_STATE_3;
if (confirm)
switch (nb->state) {
case X25_LINK_STATE_2:
confirm = !x25_t20timer_pending(nb);
x25_stop_t20timer(nb);
nb->state = X25_LINK_STATE_3;
if (confirm)
x25_transmit_restart_confirmation(nb);
break;
case X25_LINK_STATE_3:
/* clear existing virtual calls */
x25_kill_by_neigh(nb);

x25_transmit_restart_confirmation(nb);
break;
}
break;

case X25_RESTART_CONFIRMATION:
x25_stop_t20timer(nb);
nb->state = X25_LINK_STATE_3;
switch (nb->state) {
case X25_LINK_STATE_2:
if (x25_t20timer_pending(nb)) {
x25_stop_t20timer(nb);
nb->state = X25_LINK_STATE_3;
} else {
x25_transmit_restart_request(nb);
x25_start_t20timer(nb);
}
break;
case X25_LINK_STATE_3:
/* clear existing virtual calls */
x25_kill_by_neigh(nb);

x25_transmit_restart_request(nb);
nb->state = X25_LINK_STATE_2;
x25_start_t20timer(nb);
break;
}
break;

case X25_DIAGNOSTIC:
Expand Down Expand Up @@ -214,8 +241,6 @@ void x25_link_established(struct x25_neigh *nb)
{
switch (nb->state) {
case X25_LINK_STATE_0:
nb->state = X25_LINK_STATE_2;
break;
case X25_LINK_STATE_1:
x25_transmit_restart_request(nb);
nb->state = X25_LINK_STATE_2;
Expand Down

0 comments on commit d023b2b

Please sign in to comment.