3030#endif
3131
3232static int llc_find_offset (int state , int ev_type );
33- static int llc_conn_send_pdus (struct sock * sk , struct sk_buff * skb );
33+ static void llc_conn_send_pdus (struct sock * sk );
3434static int llc_conn_service (struct sock * sk , struct sk_buff * skb );
3535static int llc_exec_conn_trans_actions (struct sock * sk ,
3636 struct llc_conn_state_trans * trans ,
@@ -55,41 +55,28 @@ int sysctl_llc2_busy_timeout = LLC2_BUSY_TIME * HZ;
5555 * (executing it's actions and changing state), upper layer will be
5656 * indicated or confirmed, if needed. Returns 0 for success, 1 for
5757 * failure. The socket lock has to be held before calling this function.
58+ *
59+ * This function always consumes a reference to the skb.
5860 */
5961int llc_conn_state_process (struct sock * sk , struct sk_buff * skb )
6062{
6163 int rc ;
6264 struct llc_sock * llc = llc_sk (skb -> sk );
6365 struct llc_conn_state_ev * ev = llc_conn_ev (skb );
6466
65- /*
66- * We have to hold the skb, because llc_conn_service will kfree it in
67- * the sending path and we need to look at the skb->cb, where we encode
68- * llc_conn_state_ev.
69- */
70- skb_get (skb );
7167 ev -> ind_prim = ev -> cfm_prim = 0 ;
7268 /*
7369 * Send event to state machine
7470 */
7571 rc = llc_conn_service (skb -> sk , skb );
7672 if (unlikely (rc != 0 )) {
7773 printk (KERN_ERR "%s: llc_conn_service failed\n" , __func__ );
78- goto out_kfree_skb ;
79- }
80-
81- if (unlikely (!ev -> ind_prim && !ev -> cfm_prim )) {
82- /* indicate or confirm not required */
83- if (!skb -> next )
84- goto out_kfree_skb ;
8574 goto out_skb_put ;
8675 }
8776
88- if (unlikely (ev -> ind_prim && ev -> cfm_prim )) /* Paranoia */
89- skb_get (skb );
90-
9177 switch (ev -> ind_prim ) {
9278 case LLC_DATA_PRIM :
79+ skb_get (skb );
9380 llc_save_primitive (sk , skb , LLC_DATA_PRIM );
9481 if (unlikely (sock_queue_rcv_skb (sk , skb ))) {
9582 /*
@@ -106,6 +93,7 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
10693 * skb->sk pointing to the newly created struct sock in
10794 * llc_conn_handler. -acme
10895 */
96+ skb_get (skb );
10997 skb_queue_tail (& sk -> sk_receive_queue , skb );
11098 sk -> sk_state_change (sk );
11199 break ;
@@ -121,7 +109,6 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
121109 sk -> sk_state_change (sk );
122110 }
123111 }
124- kfree_skb (skb );
125112 sock_put (sk );
126113 break ;
127114 case LLC_RESET_PRIM :
@@ -130,14 +117,11 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
130117 * RESET is not being notified to upper layers for now
131118 */
132119 printk (KERN_INFO "%s: received a reset ind!\n" , __func__ );
133- kfree_skb (skb );
134120 break ;
135121 default :
136- if (ev -> ind_prim ) {
122+ if (ev -> ind_prim )
137123 printk (KERN_INFO "%s: received unknown %d prim!\n" ,
138124 __func__ , ev -> ind_prim );
139- kfree_skb (skb );
140- }
141125 /* No indication */
142126 break ;
143127 }
@@ -179,25 +163,22 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
179163 printk (KERN_INFO "%s: received a reset conf!\n" , __func__ );
180164 break ;
181165 default :
182- if (ev -> cfm_prim ) {
166+ if (ev -> cfm_prim )
183167 printk (KERN_INFO "%s: received unknown %d prim!\n" ,
184168 __func__ , ev -> cfm_prim );
185- break ;
186- }
187- goto out_skb_put ; /* No confirmation */
169+ /* No confirmation */
170+ break ;
188171 }
189- out_kfree_skb :
190- kfree_skb (skb );
191172out_skb_put :
192173 kfree_skb (skb );
193174 return rc ;
194175}
195176
196- int llc_conn_send_pdu (struct sock * sk , struct sk_buff * skb )
177+ void llc_conn_send_pdu (struct sock * sk , struct sk_buff * skb )
197178{
198179 /* queue PDU to send to MAC layer */
199180 skb_queue_tail (& sk -> sk_write_queue , skb );
200- return llc_conn_send_pdus (sk , skb );
181+ llc_conn_send_pdus (sk );
201182}
202183
203184/**
@@ -255,7 +236,7 @@ void llc_conn_resend_i_pdu_as_cmd(struct sock *sk, u8 nr, u8 first_p_bit)
255236 if (howmany_resend > 0 )
256237 llc -> vS = (llc -> vS + 1 ) % LLC_2_SEQ_NBR_MODULO ;
257238 /* any PDUs to re-send are queued up; start sending to MAC */
258- llc_conn_send_pdus (sk , NULL );
239+ llc_conn_send_pdus (sk );
259240out :;
260241}
261242
@@ -296,7 +277,7 @@ void llc_conn_resend_i_pdu_as_rsp(struct sock *sk, u8 nr, u8 first_f_bit)
296277 if (howmany_resend > 0 )
297278 llc -> vS = (llc -> vS + 1 ) % LLC_2_SEQ_NBR_MODULO ;
298279 /* any PDUs to re-send are queued up; start sending to MAC */
299- llc_conn_send_pdus (sk , NULL );
280+ llc_conn_send_pdus (sk );
300281out :;
301282}
302283
@@ -340,16 +321,12 @@ int llc_conn_remove_acked_pdus(struct sock *sk, u8 nr, u16 *how_many_unacked)
340321/**
341322 * llc_conn_send_pdus - Sends queued PDUs
342323 * @sk: active connection
343- * @hold_skb: the skb held by caller, or NULL if does not care
344324 *
345- * Sends queued pdus to MAC layer for transmission. When @hold_skb is
346- * NULL, always return 0. Otherwise, return 0 if @hold_skb is sent
347- * successfully, or 1 for failure.
325+ * Sends queued pdus to MAC layer for transmission.
348326 */
349- static int llc_conn_send_pdus (struct sock * sk , struct sk_buff * hold_skb )
327+ static void llc_conn_send_pdus (struct sock * sk )
350328{
351329 struct sk_buff * skb ;
352- int ret = 0 ;
353330
354331 while ((skb = skb_dequeue (& sk -> sk_write_queue )) != NULL ) {
355332 struct llc_pdu_sn * pdu = llc_pdu_sn_hdr (skb );
@@ -361,20 +338,10 @@ static int llc_conn_send_pdus(struct sock *sk, struct sk_buff *hold_skb)
361338 skb_queue_tail (& llc_sk (sk )-> pdu_unack_q , skb );
362339 if (!skb2 )
363340 break ;
364- dev_queue_xmit (skb2 );
365- } else {
366- bool is_target = skb == hold_skb ;
367- int rc ;
368-
369- if (is_target )
370- skb_get (skb );
371- rc = dev_queue_xmit (skb );
372- if (is_target )
373- ret = rc ;
341+ skb = skb2 ;
374342 }
343+ dev_queue_xmit (skb );
375344 }
376-
377- return ret ;
378345}
379346
380347/**
0 commit comments