Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (C) Jonathan Naylor G4KLX (g4klx@g4klx.demon.co.uk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2002 Ralf Baechle DO1GRB (ralf@gnu.org)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/socket.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/in.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/jiffies.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/sockios.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/net.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <net/ax25.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/inet.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <net/sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <net/tcp_states.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/fcntl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <net/netrom.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) static void nr_heartbeat_expiry(struct timer_list *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) static void nr_t1timer_expiry(struct timer_list *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) static void nr_t2timer_expiry(struct timer_list *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) static void nr_t4timer_expiry(struct timer_list *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) static void nr_idletimer_expiry(struct timer_list *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) void nr_init_timers(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	struct nr_sock *nr = nr_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	timer_setup(&nr->t1timer, nr_t1timer_expiry, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	timer_setup(&nr->t2timer, nr_t2timer_expiry, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	timer_setup(&nr->t4timer, nr_t4timer_expiry, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	timer_setup(&nr->idletimer, nr_idletimer_expiry, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	/* initialized by sock_init_data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	sk->sk_timer.function = nr_heartbeat_expiry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) void nr_start_t1timer(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	struct nr_sock *nr = nr_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	sk_reset_timer(sk, &nr->t1timer, jiffies + nr->t1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) void nr_start_t2timer(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	struct nr_sock *nr = nr_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	sk_reset_timer(sk, &nr->t2timer, jiffies + nr->t2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) void nr_start_t4timer(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	struct nr_sock *nr = nr_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	sk_reset_timer(sk, &nr->t4timer, jiffies + nr->t4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) void nr_start_idletimer(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	struct nr_sock *nr = nr_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	if (nr->idle > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		sk_reset_timer(sk, &nr->idletimer, jiffies + nr->idle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) void nr_start_heartbeat(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	sk_reset_timer(sk, &sk->sk_timer, jiffies + 5 * HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) void nr_stop_t1timer(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	sk_stop_timer(sk, &nr_sk(sk)->t1timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) void nr_stop_t2timer(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	sk_stop_timer(sk, &nr_sk(sk)->t2timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) void nr_stop_t4timer(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	sk_stop_timer(sk, &nr_sk(sk)->t4timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) void nr_stop_idletimer(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	sk_stop_timer(sk, &nr_sk(sk)->idletimer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) void nr_stop_heartbeat(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	sk_stop_timer(sk, &sk->sk_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) int nr_t1timer_running(struct sock *sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	return timer_pending(&nr_sk(sk)->t1timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) static void nr_heartbeat_expiry(struct timer_list *t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	struct sock *sk = from_timer(sk, t, sk_timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	struct nr_sock *nr = nr_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	bh_lock_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	switch (nr->state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	case NR_STATE_0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		/* Magic here: If we listen() and a new link dies before it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		   is accepted() it isn't 'dead' so doesn't get removed. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		if (sock_flag(sk, SOCK_DESTROY) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		    (sk->sk_state == TCP_LISTEN && sock_flag(sk, SOCK_DEAD))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 			bh_unlock_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 			nr_destroy_socket(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	case NR_STATE_3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		 * Check for the state of the receive buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		if (atomic_read(&sk->sk_rmem_alloc) < (sk->sk_rcvbuf / 2) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		    (nr->condition & NR_COND_OWN_RX_BUSY)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 			nr->condition &= ~NR_COND_OWN_RX_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 			nr->condition &= ~NR_COND_ACK_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 			nr->vl         = nr->vr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 			nr_write_internal(sk, NR_INFOACK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	nr_start_heartbeat(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	bh_unlock_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	sock_put(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) static void nr_t2timer_expiry(struct timer_list *t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	struct nr_sock *nr = from_timer(nr, t, t2timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	struct sock *sk = &nr->sock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	bh_lock_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	if (nr->condition & NR_COND_ACK_PENDING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		nr->condition &= ~NR_COND_ACK_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		nr_enquiry_response(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	bh_unlock_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	sock_put(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) static void nr_t4timer_expiry(struct timer_list *t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	struct nr_sock *nr = from_timer(nr, t, t4timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	struct sock *sk = &nr->sock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	bh_lock_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	nr_sk(sk)->condition &= ~NR_COND_PEER_RX_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	bh_unlock_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	sock_put(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) static void nr_idletimer_expiry(struct timer_list *t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	struct nr_sock *nr = from_timer(nr, t, idletimer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	struct sock *sk = &nr->sock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	bh_lock_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	nr_clear_queues(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	nr->n2count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	nr_write_internal(sk, NR_DISCREQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	nr->state = NR_STATE_2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	nr_start_t1timer(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	nr_stop_t2timer(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	nr_stop_t4timer(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	sk->sk_state     = TCP_CLOSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	sk->sk_err       = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	sk->sk_shutdown |= SEND_SHUTDOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	if (!sock_flag(sk, SOCK_DEAD)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		sk->sk_state_change(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		sock_set_flag(sk, SOCK_DEAD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	bh_unlock_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	sock_put(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) static void nr_t1timer_expiry(struct timer_list *t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	struct nr_sock *nr = from_timer(nr, t, t1timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	struct sock *sk = &nr->sock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	bh_lock_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	switch (nr->state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	case NR_STATE_1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		if (nr->n2count == nr->n2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 			nr_disconnect(sk, ETIMEDOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 			nr->n2count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 			nr_write_internal(sk, NR_CONNREQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	case NR_STATE_2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		if (nr->n2count == nr->n2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 			nr_disconnect(sk, ETIMEDOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 			nr->n2count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 			nr_write_internal(sk, NR_DISCREQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	case NR_STATE_3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		if (nr->n2count == nr->n2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 			nr_disconnect(sk, ETIMEDOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 			nr->n2count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 			nr_requeue_frames(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	nr_start_t1timer(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	bh_unlock_sock(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	sock_put(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) }