Skip to content

Commit f8fc57e

Browse files
sch-mdavem330
authored andcommitted
net/x25: add new state X25_STATE_5
This is needed, because if the flag X25_ACCPT_APPRV_FLAG is not set on a socket (manual call confirmation) and the channel is cleared by remote before the manual call confirmation was sent, this situation needs to be handled. Signed-off-by: Martin Schiller <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 65cb139 commit f8fc57e

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

include/net/x25.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ enum {
6262
X25_STATE_1, /* Awaiting Call Accepted */
6363
X25_STATE_2, /* Awaiting Clear Confirmation */
6464
X25_STATE_3, /* Data Transfer */
65-
X25_STATE_4 /* Awaiting Reset Confirmation */
65+
X25_STATE_4, /* Awaiting Reset Confirmation */
66+
X25_STATE_5 /* Call Accepted / Call Connected pending */
6667
};
6768

6869
enum {

net/x25/af_x25.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,12 @@ static int x25_release(struct socket *sock)
659659
sock_set_flag(sk, SOCK_DEAD);
660660
sock_set_flag(sk, SOCK_DESTROY);
661661
break;
662+
663+
case X25_STATE_5:
664+
x25_write_internal(sk, X25_CLEAR_REQUEST);
665+
x25_disconnect(sk, 0, 0, 0);
666+
__x25_destroy_socket(sk);
667+
goto out;
662668
}
663669

664670
sock_orphan(sk);
@@ -1054,6 +1060,8 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb,
10541060
if (test_bit(X25_ACCPT_APPRV_FLAG, &makex25->flags)) {
10551061
x25_write_internal(make, X25_CALL_ACCEPTED);
10561062
makex25->state = X25_STATE_3;
1063+
} else {
1064+
makex25->state = X25_STATE_5;
10571065
}
10581066

10591067
/*

net/x25/x25_in.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,35 @@ static int x25_state4_machine(struct sock *sk, struct sk_buff *skb, int frametyp
382382
return 0;
383383
}
384384

385+
/*
386+
* State machine for state 5, Call Accepted / Call Connected pending (X25_ACCPT_APPRV_FLAG).
387+
* The handling of the timer(s) is in file x25_timer.c
388+
* Handling of state 0 and connection release is in af_x25.c.
389+
*/
390+
static int x25_state5_machine(struct sock *sk, struct sk_buff *skb, int frametype)
391+
{
392+
struct x25_sock *x25 = x25_sk(sk);
393+
394+
switch (frametype) {
395+
case X25_CLEAR_REQUEST:
396+
if (!pskb_may_pull(skb, X25_STD_MIN_LEN + 2)) {
397+
x25_write_internal(sk, X25_CLEAR_REQUEST);
398+
x25->state = X25_STATE_2;
399+
x25_start_t23timer(sk);
400+
return 0;
401+
}
402+
403+
x25_write_internal(sk, X25_CLEAR_CONFIRMATION);
404+
x25_disconnect(sk, 0, skb->data[3], skb->data[4]);
405+
break;
406+
407+
default:
408+
break;
409+
}
410+
411+
return 0;
412+
}
413+
385414
/* Higher level upcall for a LAPB frame */
386415
int x25_process_rx_frame(struct sock *sk, struct sk_buff *skb)
387416
{
@@ -406,6 +435,9 @@ int x25_process_rx_frame(struct sock *sk, struct sk_buff *skb)
406435
case X25_STATE_4:
407436
queued = x25_state4_machine(sk, skb, frametype);
408437
break;
438+
case X25_STATE_5:
439+
queued = x25_state5_machine(sk, skb, frametype);
440+
break;
409441
}
410442

411443
x25_kick(sk);

0 commit comments

Comments
 (0)