2 * llc_conn.c - Driver routines for connection component.
4 * Copyright (c) 1997 by Procom Technology, Inc.
5 * 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
7 * This program can be redistributed or modified under the terms of the
8 * GNU General Public License as published by the Free Software Foundation.
9 * This program is distributed without any warranty or implied warranty
10 * of merchantability or fitness for a particular purpose.
12 * See the GNU General Public License for more details.
15 #include <linux/init.h>
16 #include <net/llc_sap.h>
17 #include <net/llc_conn.h>
19 #include <linux/tcp.h>
20 #include <net/llc_c_ev.h>
21 #include <net/llc_c_ac.h>
22 #include <net/llc_c_st.h>
23 #include <net/llc_pdu.h>
26 #define dprintk(args...) printk(KERN_DEBUG args)
28 #define dprintk(args...)
31 static int llc_find_offset(int state, int ev_type);
32 static void llc_conn_send_pdus(struct sock *sk);
33 static int llc_conn_service(struct sock *sk, struct sk_buff *skb);
34 static int llc_exec_conn_trans_actions(struct sock *sk,
35 struct llc_conn_state_trans *trans,
37 static struct llc_conn_state_trans *llc_qualify_conn_ev(struct sock *sk,
40 /* Offset table on connection states transition diagram */
41 static int llc_offset_table[NBR_CONN_STATES][NBR_CONN_EV];
44 * llc_conn_state_process - sends event to connection state machine
46 * @skb: occurred event
48 * Sends an event to connection state machine. After processing event
49 * (executing it's actions and changing state), upper layer will be
50 * indicated or confirmed, if needed. Returns 0 for success, 1 for
51 * failure. The socket lock has to be held before calling this function.
53 int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
56 struct llc_sock *llc = llc_sk(sk);
57 struct llc_conn_state_ev *ev = llc_conn_ev(skb);
60 * We have to hold the skb, because llc_conn_service will kfree it in
61 * the sending path and we need to look at the skb->cb, where we encode
65 ev->ind_prim = ev->cfm_prim = 0;
66 rc = llc_conn_service(sk, skb); /* sending event to state machine */
68 printk(KERN_ERR "%s: llc_conn_service failed\n", __FUNCTION__);
72 if (!ev->ind_prim && !ev->cfm_prim) {
73 /* indicate or confirm not required */
79 if (ev->ind_prim && ev->cfm_prim) /* Paranoia */
82 switch (ev->ind_prim) {
84 llc_save_primitive(skb, LLC_DATA_PRIM);
85 if (sock_queue_rcv_skb(sk, skb)) {
89 printk(KERN_ERR "%s: sock_queue_rcv_skb failed!\n",
95 struct sock *parent = skb->sk;
98 skb_queue_tail(&parent->sk_receive_queue, skb);
99 sk->sk_state_change(parent);
104 if (sk->sk_type == SOCK_STREAM &&
105 sk->sk_state == TCP_ESTABLISHED) {
106 sk->sk_shutdown = SHUTDOWN_MASK;
107 sk->sk_socket->state = SS_UNCONNECTED;
108 sk->sk_state = TCP_CLOSE;
109 if (!sock_flag(sk, SOCK_DEAD)) {
110 sk->sk_state_change(sk);
111 sock_set_flag(sk, SOCK_DEAD);
120 * RESET is not being notified to upper layers for now
122 printk(KERN_INFO "%s: received a reset ind!\n", __FUNCTION__);
127 printk(KERN_INFO "%s: received unknown %d prim!\n",
128 __FUNCTION__, ev->ind_prim);
135 switch (ev->cfm_prim) {
137 if (!llc_data_accept_state(llc->state))
138 sk->sk_write_space(sk);
140 rc = llc->failed_data_req = 1;
143 if (sk->sk_type == SOCK_STREAM &&
144 sk->sk_state == TCP_SYN_SENT) {
146 sk->sk_socket->state = SS_UNCONNECTED;
147 sk->sk_state = TCP_CLOSE;
149 sk->sk_socket->state = SS_CONNECTED;
150 sk->sk_state = TCP_ESTABLISHED;
152 sk->sk_state_change(sk);
157 if (sk->sk_type == SOCK_STREAM && sk->sk_state == TCP_CLOSING) {
158 sk->sk_socket->state = SS_UNCONNECTED;
159 sk->sk_state = TCP_CLOSE;
160 sk->sk_state_change(sk);
167 * RESET is not being notified to upper layers for now
169 printk(KERN_INFO "%s: received a reset conf!\n", __FUNCTION__);
173 printk(KERN_INFO "%s: received unknown %d prim!\n",
174 __FUNCTION__, ev->cfm_prim);
177 goto out_skb_put; /* No confirmation */
186 void llc_conn_send_pdu(struct sock *sk, struct sk_buff *skb)
188 /* queue PDU to send to MAC layer */
189 skb_queue_tail(&sk->sk_write_queue, skb);
190 llc_conn_send_pdus(sk);
194 * llc_conn_rtn_pdu - sends received data pdu to upper layer
195 * @sk: Active connection
196 * @skb: Received data frame
198 * Sends received data pdu to upper layer (by using indicate function).
199 * Prepares service parameters (prim and prim_data). calling indication
200 * function will be done in llc_conn_state_process.
202 void llc_conn_rtn_pdu(struct sock *sk, struct sk_buff *skb)
204 struct llc_conn_state_ev *ev = llc_conn_ev(skb);
206 ev->ind_prim = LLC_DATA_PRIM;
210 * llc_conn_resend_i_pdu_as_cmd - resend all all unacknowledged I PDUs
211 * @sk: active connection
213 * @first_p_bit: p_bit value of first pdu
215 * Resend all unacknowledged I PDUs, starting with the NR; send first as
216 * command PDU with P bit equal first_p_bit; if more than one send
217 * subsequent as command PDUs with P bit equal zero (0).
219 void llc_conn_resend_i_pdu_as_cmd(struct sock *sk, u8 nr, u8 first_p_bit)
222 struct llc_pdu_sn *pdu;
224 struct llc_sock *llc;
225 u8 howmany_resend = 0;
227 llc_conn_remove_acked_pdus(sk, nr, &nbr_unack_pdus);
231 * Process unack PDUs only if unack queue is not empty; remove
232 * appropriate PDUs, fix them up, and put them on mac_pdu_q.
236 while ((skb = skb_dequeue(&llc->pdu_unack_q)) != NULL) {
237 pdu = llc_pdu_sn_hdr(skb);
238 llc_pdu_set_cmd_rsp(skb, LLC_PDU_CMD);
239 llc_pdu_set_pf_bit(skb, first_p_bit);
240 skb_queue_tail(&sk->sk_write_queue, skb);
242 llc->vS = LLC_I_GET_NS(pdu);
245 if (howmany_resend > 0)
246 llc->vS = (llc->vS + 1) % LLC_2_SEQ_NBR_MODULO;
247 /* any PDUs to re-send are queued up; start sending to MAC */
248 llc_conn_send_pdus(sk);
253 * llc_conn_resend_i_pdu_as_rsp - Resend all unacknowledged I PDUs
254 * @sk: active connection.
256 * @first_f_bit: f_bit value of first pdu.
258 * Resend all unacknowledged I PDUs, starting with the NR; send first as
259 * response PDU with F bit equal first_f_bit; if more than one send
260 * subsequent as response PDUs with F bit equal zero (0).
262 void llc_conn_resend_i_pdu_as_rsp(struct sock *sk, u8 nr, u8 first_f_bit)
266 struct llc_sock *llc = llc_sk(sk);
267 u8 howmany_resend = 0;
269 llc_conn_remove_acked_pdus(sk, nr, &nbr_unack_pdus);
273 * Process unack PDUs only if unack queue is not empty; remove
274 * appropriate PDUs, fix them up, and put them on mac_pdu_q
276 while ((skb = skb_dequeue(&llc->pdu_unack_q)) != NULL) {
277 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
279 llc_pdu_set_cmd_rsp(skb, LLC_PDU_RSP);
280 llc_pdu_set_pf_bit(skb, first_f_bit);
281 skb_queue_tail(&sk->sk_write_queue, skb);
283 llc->vS = LLC_I_GET_NS(pdu);
286 if (howmany_resend > 0)
287 llc->vS = (llc->vS + 1) % LLC_2_SEQ_NBR_MODULO;
288 /* any PDUs to re-send are queued up; start sending to MAC */
289 llc_conn_send_pdus(sk);
294 * llc_conn_remove_acked_pdus - Removes acknowledged pdus from tx queue
295 * @sk: active connection
297 * how_many_unacked: size of pdu_unack_q after removing acked pdus
299 * Removes acknowledged pdus from transmit queue (pdu_unack_q). Returns
300 * the number of pdus that removed from queue.
302 int llc_conn_remove_acked_pdus(struct sock *sk, u8 nr, u16 *how_many_unacked)
306 struct llc_pdu_sn *pdu;
308 struct llc_sock *llc = llc_sk(sk);
309 int q_len = skb_queue_len(&llc->pdu_unack_q);
313 skb = skb_peek(&llc->pdu_unack_q);
314 pdu = llc_pdu_sn_hdr(skb);
316 /* finding position of last acked pdu in queue */
317 pdu_pos = ((int)LLC_2_SEQ_NBR_MODULO + (int)nr -
318 (int)LLC_I_GET_NS(pdu)) % LLC_2_SEQ_NBR_MODULO;
320 for (i = 0; i < pdu_pos && i < q_len; i++) {
321 skb = skb_dequeue(&llc->pdu_unack_q);
327 *how_many_unacked = skb_queue_len(&llc->pdu_unack_q);
332 * llc_conn_send_pdus - Sends queued PDUs
333 * @sk: active connection
335 * Sends queued pdus to MAC layer for transmission.
337 static void llc_conn_send_pdus(struct sock *sk)
341 while ((skb = skb_dequeue(&sk->sk_write_queue)) != NULL) {
342 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
344 if (LLC_PDU_TYPE_IS_I(pdu) &&
345 !(skb->dev->flags & IFF_LOOPBACK)) {
346 struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
348 skb_queue_tail(&llc_sk(sk)->pdu_unack_q, skb);
358 * llc_conn_service - finds transition and changes state of connection
360 * @skb: happened event
362 * This function finds transition that matches with happened event, then
363 * executes related actions and finally changes state of connection.
364 * Returns 0 for success, 1 for failure.
366 static int llc_conn_service(struct sock *sk, struct sk_buff *skb)
369 struct llc_sock *llc = llc_sk(sk);
370 struct llc_conn_state_trans *trans;
372 if (llc->state > NBR_CONN_STATES)
375 trans = llc_qualify_conn_ev(sk, skb);
377 rc = llc_exec_conn_trans_actions(sk, trans, skb);
378 if (!rc && trans->next_state != NO_STATE_CHANGE) {
379 llc->state = trans->next_state;
380 if (!llc_data_accept_state(llc->state))
381 sk->sk_state_change(sk);
389 * llc_qualify_conn_ev - finds transition for event
391 * @skb: happened event
393 * This function finds transition that matches with happened event.
394 * Returns pointer to found transition on success, %NULL otherwise.
396 static struct llc_conn_state_trans *llc_qualify_conn_ev(struct sock *sk,
399 struct llc_conn_state_trans **next_trans;
400 llc_conn_ev_qfyr_t *next_qualifier;
401 struct llc_conn_state_ev *ev = llc_conn_ev(skb);
402 struct llc_sock *llc = llc_sk(sk);
403 struct llc_conn_state *curr_state =
404 &llc_conn_state_table[llc->state - 1];
406 /* search thru events for this state until
407 * list exhausted or until no more
409 for (next_trans = curr_state->transitions +
410 llc_find_offset(llc->state - 1, ev->type);
411 (*next_trans)->ev; next_trans++) {
412 if (!((*next_trans)->ev)(sk, skb)) {
413 /* got POSSIBLE event match; the event may require
414 * qualification based on the values of a number of
415 * state flags; if all qualifications are met (i.e.,
416 * if all qualifying functions return success, or 0,
417 * then this is THE event we're looking for
419 for (next_qualifier = (*next_trans)->ev_qualifiers;
420 next_qualifier && *next_qualifier &&
421 !(*next_qualifier)(sk, skb); next_qualifier++)
423 if (!next_qualifier || !*next_qualifier)
424 /* all qualifiers executed successfully; this is
425 * our transition; return it so we can perform
426 * the associated actions & change the state
435 * llc_exec_conn_trans_actions - executes related actions
437 * @trans: transition that it's actions must be performed
440 * Executes actions that is related to happened event. Returns 0 for
441 * success, 1 to indicate failure of at least one action.
443 static int llc_exec_conn_trans_actions(struct sock *sk,
444 struct llc_conn_state_trans *trans,
448 llc_conn_action_t *next_action;
450 for (next_action = trans->ev_actions;
451 next_action && *next_action; next_action++) {
452 int rc2 = (*next_action)(sk, skb);
464 * llc_lookup_established - Finds connection for the remote/local sap/mac
466 * @daddr: address of remote LLC (MAC + SAP)
467 * @laddr: address of local LLC (MAC + SAP)
469 * Search connection list of the SAP and finds connection using the remote
470 * mac, remote sap, local mac, and local sap. Returns pointer for
471 * connection found, %NULL otherwise.
473 struct sock *llc_lookup_established(struct llc_sap *sap, struct llc_addr *daddr,
474 struct llc_addr *laddr)
477 struct hlist_node *node;
479 read_lock_bh(&sap->sk_list.lock);
480 sk_for_each(rc, node, &sap->sk_list.list) {
481 struct llc_sock *llc = llc_sk(rc);
483 if (llc->laddr.lsap == laddr->lsap &&
484 llc->daddr.lsap == daddr->lsap &&
485 llc_mac_match(llc->laddr.mac, laddr->mac) &&
486 llc_mac_match(llc->daddr.mac, daddr->mac)) {
493 read_unlock_bh(&sap->sk_list.lock);
498 * llc_lookup_listener - Finds listener for local MAC + SAP
500 * @laddr: address of local LLC (MAC + SAP)
502 * Search connection list of the SAP and finds connection listening on
503 * local mac, and local sap. Returns pointer for parent socket found,
506 static struct sock *llc_lookup_listener(struct llc_sap *sap,
507 struct llc_addr *laddr)
510 struct hlist_node *node;
512 read_lock_bh(&sap->sk_list.lock);
513 sk_for_each(rc, node, &sap->sk_list.list) {
514 struct llc_sock *llc = llc_sk(rc);
516 if (rc->sk_type == SOCK_STREAM && rc->sk_state == TCP_LISTEN &&
517 llc->laddr.lsap == laddr->lsap &&
518 (llc_mac_match(llc->laddr.mac, laddr->mac) ||
519 llc_mac_null(llc->laddr.mac))) {
526 read_unlock_bh(&sap->sk_list.lock);
531 * llc_data_accept_state - designates if in this state data can be sent.
532 * @state: state of connection.
534 * Returns 0 if data can be sent, 1 otherwise.
536 u8 llc_data_accept_state(u8 state)
538 return state != LLC_CONN_STATE_NORMAL && state != LLC_CONN_STATE_BUSY &&
539 state != LLC_CONN_STATE_REJ;
543 * find_next_offset - finds offset for next category of transitions
544 * @state: state table.
545 * @offset: start offset.
547 * Finds offset of next category of transitions in transition table.
548 * Returns the start index of next category.
550 static u16 find_next_offset(struct llc_conn_state *state, u16 offset)
553 struct llc_conn_state_trans **next_trans;
555 for (next_trans = state->transitions + offset;
556 (*next_trans)->ev; next_trans++)
562 * llc_build_offset_table - builds offset table of connection
564 * Fills offset table of connection state transition table
565 * (llc_offset_table).
567 void __init llc_build_offset_table(void)
569 struct llc_conn_state *curr_state;
570 int state, ev_type, next_offset;
572 for (state = 0; state < NBR_CONN_STATES; state++) {
573 curr_state = &llc_conn_state_table[state];
575 for (ev_type = 0; ev_type < NBR_CONN_EV; ev_type++) {
576 llc_offset_table[state][ev_type] = next_offset;
577 next_offset += find_next_offset(curr_state,
584 * llc_find_offset - finds start offset of category of transitions
585 * @state: state of connection
586 * @ev_type: type of happened event
588 * Finds start offset of desired category of transitions. Returns the
589 * desired start offset.
591 static int llc_find_offset(int state, int ev_type)
594 /* at this stage, llc_offset_table[..][2] is not important. it is for
595 * init_pf_cycle and I don't know what is it.
598 case LLC_CONN_EV_TYPE_PRIM:
599 rc = llc_offset_table[state][0]; break;
600 case LLC_CONN_EV_TYPE_PDU:
601 rc = llc_offset_table[state][4]; break;
602 case LLC_CONN_EV_TYPE_SIMPLE:
603 rc = llc_offset_table[state][1]; break;
604 case LLC_CONN_EV_TYPE_P_TMR:
605 case LLC_CONN_EV_TYPE_ACK_TMR:
606 case LLC_CONN_EV_TYPE_REJ_TMR:
607 case LLC_CONN_EV_TYPE_BUSY_TMR:
608 rc = llc_offset_table[state][3]; break;
614 * llc_sap_add_socket - adds a socket to a SAP
618 * This function adds a socket to sk_list of a SAP.
620 void llc_sap_add_socket(struct llc_sap *sap, struct sock *sk)
622 write_lock_bh(&sap->sk_list.lock);
623 llc_sk(sk)->sap = sap;
624 sk_add_node(sk, &sap->sk_list.list);
625 write_unlock_bh(&sap->sk_list.lock);
629 * llc_sap_remove_socket - removes a socket from SAP
633 * This function removes a connection from sk_list.list of a SAP if
634 * the connection was in this list.
636 void llc_sap_remove_socket(struct llc_sap *sap, struct sock *sk)
638 write_lock_bh(&sap->sk_list.lock);
639 sk_del_node_init(sk);
640 write_unlock_bh(&sap->sk_list.lock);
644 * llc_conn_rcv - sends received pdus to the connection state machine
645 * @sk: current connection structure.
646 * @skb: received frame.
648 * Sends received pdus to the connection state machine.
650 static int llc_conn_rcv(struct sock* sk, struct sk_buff *skb)
652 struct llc_conn_state_ev *ev = llc_conn_ev(skb);
653 struct llc_sock *llc = llc_sk(sk);
657 ev->type = LLC_CONN_EV_TYPE_PDU;
659 return llc_conn_state_process(sk, skb);
662 void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb)
664 struct llc_addr saddr, daddr;
667 llc_pdu_decode_sa(skb, saddr.mac);
668 llc_pdu_decode_ssap(skb, &saddr.lsap);
669 llc_pdu_decode_da(skb, daddr.mac);
670 llc_pdu_decode_dsap(skb, &daddr.lsap);
672 sk = llc_lookup_established(sap, &saddr, &daddr);
675 * Didn't find an active connection; verify if there
676 * is a listening socket for this llc addr
678 struct llc_sock *llc;
679 struct sock *parent = llc_lookup_listener(sap, &daddr);
682 dprintk("llc_lookup_listener failed!\n");
686 sk = llc_sk_alloc(parent->sk_family, GFP_ATOMIC, parent->sk_prot);
692 memcpy(&llc->laddr, &daddr, sizeof(llc->laddr));
693 memcpy(&llc->daddr, &saddr, sizeof(llc->daddr));
694 llc_sap_add_socket(sap, sk);
701 if (!sock_owned_by_user(sk))
702 llc_conn_rcv(sk, skb);
704 dprintk("%s: adding to backlog...\n", __FUNCTION__);
705 llc_set_backlog_type(skb, LLC_PACKET);
706 sk_add_backlog(sk, skb);
715 #undef LLC_REFCNT_DEBUG
716 #ifdef LLC_REFCNT_DEBUG
717 static atomic_t llc_sock_nr;
721 * llc_release_sockets - releases all sockets in a sap
722 * @sap: sap to release its sockets
724 * Releases all connections of a sap. Returns 0 if all actions complete
725 * successfully, nonzero otherwise
727 int llc_release_sockets(struct llc_sap *sap)
731 struct hlist_node *node;
733 write_lock_bh(&sap->sk_list.lock);
735 sk_for_each(sk, node, &sap->sk_list.list) {
736 llc_sk(sk)->state = LLC_CONN_STATE_TEMP;
738 if (llc_send_disc(sk))
742 write_unlock_bh(&sap->sk_list.lock);
747 * llc_backlog_rcv - Processes rx frames and expired timers.
748 * @sk: LLC sock (p8022 connection)
749 * @skb: queued rx frame or event
751 * This function processes frames that has received and timers that has
752 * expired during sending an I pdu (refer to data_req_handler). frames
753 * queue by llc_rcv function (llc_mac.c) and timers queue by timer
754 * callback functions(llc_c_ac.c).
756 static int llc_backlog_rcv(struct sock *sk, struct sk_buff *skb)
759 struct llc_sock *llc = llc_sk(sk);
761 if (llc_backlog_type(skb) == LLC_PACKET) {
762 if (llc->state > 1) /* not closed */
763 rc = llc_conn_rcv(sk, skb);
766 } else if (llc_backlog_type(skb) == LLC_EVENT) {
767 /* timer expiration event */
768 if (llc->state > 1) /* not closed */
769 rc = llc_conn_state_process(sk, skb);
773 printk(KERN_ERR "%s: invalid skb in backlog\n", __FUNCTION__);
784 * llc_sk_init - Initializes a socket with default llc values.
785 * @sk: socket to initialize.
787 * Initializes a socket with default llc values.
789 static void llc_sk_init(struct sock* sk)
791 struct llc_sock *llc = llc_sk(sk);
793 llc->state = LLC_CONN_STATE_ADM;
794 llc->inc_cntr = llc->dec_cntr = 2;
795 llc->dec_step = llc->connect_step = 1;
797 init_timer(&llc->ack_timer.timer);
798 llc->ack_timer.expire = LLC_ACK_TIME;
799 llc->ack_timer.timer.data = (unsigned long)sk;
800 llc->ack_timer.timer.function = llc_conn_ack_tmr_cb;
802 init_timer(&llc->pf_cycle_timer.timer);
803 llc->pf_cycle_timer.expire = LLC_P_TIME;
804 llc->pf_cycle_timer.timer.data = (unsigned long)sk;
805 llc->pf_cycle_timer.timer.function = llc_conn_pf_cycle_tmr_cb;
807 init_timer(&llc->rej_sent_timer.timer);
808 llc->rej_sent_timer.expire = LLC_REJ_TIME;
809 llc->rej_sent_timer.timer.data = (unsigned long)sk;
810 llc->rej_sent_timer.timer.function = llc_conn_rej_tmr_cb;
812 init_timer(&llc->busy_state_timer.timer);
813 llc->busy_state_timer.expire = LLC_BUSY_TIME;
814 llc->busy_state_timer.timer.data = (unsigned long)sk;
815 llc->busy_state_timer.timer.function = llc_conn_busy_tmr_cb;
817 llc->n2 = 2; /* max retransmit */
818 llc->k = 2; /* tx win size, will adjust dynam */
819 llc->rw = 128; /* rx win size (opt and equal to
820 * tx_win of remote LLC) */
821 skb_queue_head_init(&llc->pdu_unack_q);
822 sk->sk_backlog_rcv = llc_backlog_rcv;
826 * llc_sk_alloc - Allocates LLC sock
827 * @family: upper layer protocol family
828 * @priority: for allocation (%GFP_KERNEL, %GFP_ATOMIC, etc)
830 * Allocates a LLC sock and initializes it. Returns the new LLC sock
831 * or %NULL if there's no memory available for one
833 struct sock *llc_sk_alloc(int family, int priority, struct proto *prot)
835 struct sock *sk = sk_alloc(family, priority, prot, 1);
840 sock_init_data(NULL, sk);
841 #ifdef LLC_REFCNT_DEBUG
842 atomic_inc(&llc_sock_nr);
843 printk(KERN_DEBUG "LLC socket %p created in %s, now we have %d alive\n", sk,
844 __FUNCTION__, atomic_read(&llc_sock_nr));
851 * llc_sk_free - Frees a LLC socket
852 * @sk - socket to free
856 void llc_sk_free(struct sock *sk)
858 struct llc_sock *llc = llc_sk(sk);
860 llc->state = LLC_CONN_OUT_OF_SVC;
861 /* Stop all (possibly) running timers */
862 llc_conn_ac_stop_all_timers(sk, NULL);
863 #ifdef DEBUG_LLC_CONN_ALLOC
864 printk(KERN_INFO "%s: unackq=%d, txq=%d\n", __FUNCTION__,
865 skb_queue_len(&llc->pdu_unack_q),
866 skb_queue_len(&sk->sk_write_queue));
868 skb_queue_purge(&sk->sk_receive_queue);
869 skb_queue_purge(&sk->sk_write_queue);
870 skb_queue_purge(&llc->pdu_unack_q);
871 #ifdef LLC_REFCNT_DEBUG
872 if (atomic_read(&sk->sk_refcnt) != 1) {
873 printk(KERN_DEBUG "Destruction of LLC sock %p delayed in %s, cnt=%d\n",
874 sk, __FUNCTION__, atomic_read(&sk->sk_refcnt));
875 printk(KERN_DEBUG "%d LLC sockets are still alive\n",
876 atomic_read(&llc_sock_nr));
878 atomic_dec(&llc_sock_nr);
879 printk(KERN_DEBUG "LLC socket %p released in %s, %d are still alive\n", sk,
880 __FUNCTION__, atomic_read(&llc_sock_nr));
887 * llc_sk_reset - resets a connection
888 * @sk: LLC socket to reset
890 * Resets a connection to the out of service state. Stops its timers
891 * and frees any frames in the queues of the connection.
893 void llc_sk_reset(struct sock *sk)
895 struct llc_sock *llc = llc_sk(sk);
897 llc_conn_ac_stop_all_timers(sk, NULL);
898 skb_queue_purge(&sk->sk_write_queue);
899 skb_queue_purge(&llc->pdu_unack_q);
900 llc->remote_busy_flag = 0;
902 llc->retry_count = 0;
903 llc_conn_set_p_flag(sk, 0);
907 llc->first_pdu_Ns = 0;
908 llc->ack_must_be_send = 0;
913 llc->failed_data_req = 0 ;