Lines Matching refs:skb
48 void update_send_head(struct sock *sk, struct tcp_opt *tp, struct sk_buff *skb) in update_send_head() argument
50 tp->send_head = skb->next; in update_send_head()
53 tp->snd_nxt = TCP_SKB_CB(skb)->end_seq; in update_send_head()
121 static __inline__ void tcp_event_data_sent(struct tcp_opt *tp, struct sk_buff *skb) in tcp_event_data_sent() argument
196 int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb) in tcp_transmit_skb() argument
198 if(skb != NULL) { in tcp_transmit_skb()
200 struct tcp_skb_cb *tcb = TCP_SKB_CB(skb); in tcp_transmit_skb()
246 th = (struct tcphdr *) skb_push(skb, tcp_header_size); in tcp_transmit_skb()
247 skb->h.th = th; in tcp_transmit_skb()
248 skb_set_owner_w(skb, sk); in tcp_transmit_skb()
286 TCP_ECN_send(sk, tp, skb, tcp_header_size); in tcp_transmit_skb()
288 tp->af_specific->send_check(sk, th, skb->len, skb); in tcp_transmit_skb()
293 if (skb->len != tcp_header_size) in tcp_transmit_skb()
294 tcp_event_data_sent(tp, skb); in tcp_transmit_skb()
298 err = tp->af_specific->queue_xmit(skb, 0); in tcp_transmit_skb()
325 void tcp_send_skb(struct sock *sk, struct sk_buff *skb, int force_queue, unsigned cur_mss) in tcp_send_skb() argument
330 tp->write_seq = TCP_SKB_CB(skb)->end_seq; in tcp_send_skb()
331 __skb_queue_tail(&sk->write_queue, skb); in tcp_send_skb()
332 tcp_charge_skb(sk, skb); in tcp_send_skb()
334 if (!force_queue && tp->send_head == NULL && tcp_snd_test(tp, skb, cur_mss, tp->nonagle)) { in tcp_send_skb()
336 TCP_SKB_CB(skb)->when = tcp_time_stamp; in tcp_send_skb()
337 if (tcp_transmit_skb(sk, skb_clone(skb, sk->allocation)) == 0) { in tcp_send_skb()
338 tp->snd_nxt = TCP_SKB_CB(skb)->end_seq; in tcp_send_skb()
339 tcp_minshall_update(tp, cur_mss, skb); in tcp_send_skb()
347 tp->send_head = skb; in tcp_send_skb()
356 struct sk_buff *skb = tp->send_head; in tcp_push_one() local
358 if (tcp_snd_test(tp, skb, cur_mss, 1)) { in tcp_push_one()
360 TCP_SKB_CB(skb)->when = tcp_time_stamp; in tcp_push_one()
361 if (tcp_transmit_skb(sk, skb_clone(skb, sk->allocation)) == 0) { in tcp_push_one()
363 tp->snd_nxt = TCP_SKB_CB(skb)->end_seq; in tcp_push_one()
373 static void skb_split(struct sk_buff *skb, struct sk_buff *skb1, u32 len) in skb_split() argument
376 int pos = skb->len - skb->data_len; in skb_split()
380 memcpy(skb_put(skb1, pos-len), skb->data + len, pos-len); in skb_split()
383 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) in skb_split()
384 skb_shinfo(skb1)->frags[i] = skb_shinfo(skb)->frags[i]; in skb_split()
386 skb_shinfo(skb1)->nr_frags = skb_shinfo(skb)->nr_frags; in skb_split()
387 skb_shinfo(skb)->nr_frags = 0; in skb_split()
389 skb1->data_len = skb->data_len; in skb_split()
391 skb->data_len = 0; in skb_split()
392 skb->len = len; in skb_split()
393 skb->tail = skb->data+len; in skb_split()
396 int nfrags = skb_shinfo(skb)->nr_frags; in skb_split()
400 skb_shinfo(skb)->nr_frags = 0; in skb_split()
401 skb1->len = skb1->data_len = skb->len - len; in skb_split()
402 skb->len = len; in skb_split()
403 skb->data_len = len - pos; in skb_split()
406 int size = skb_shinfo(skb)->frags[i].size; in skb_split()
408 skb_shinfo(skb1)->frags[k] = skb_shinfo(skb)->frags[i]; in skb_split()
419 get_page(skb_shinfo(skb)->frags[i].page); in skb_split()
422 skb_shinfo(skb)->frags[i].size = len-pos; in skb_split()
423 skb_shinfo(skb)->nr_frags++; in skb_split()
427 skb_shinfo(skb)->nr_frags++; in skb_split()
440 static int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len) in tcp_fragment() argument
444 int nsize = skb->len - len; in tcp_fragment()
447 if (skb_cloned(skb) && in tcp_fragment()
448 skb_is_nonlinear(skb) && in tcp_fragment()
449 pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) in tcp_fragment()
459 TCP_SKB_CB(buff)->seq = TCP_SKB_CB(skb)->seq + len; in tcp_fragment()
460 TCP_SKB_CB(buff)->end_seq = TCP_SKB_CB(skb)->end_seq; in tcp_fragment()
461 TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(buff)->seq; in tcp_fragment()
464 flags = TCP_SKB_CB(skb)->flags; in tcp_fragment()
465 TCP_SKB_CB(skb)->flags = flags & ~(TCPCB_FLAG_FIN|TCPCB_FLAG_PSH); in tcp_fragment()
467 TCP_SKB_CB(buff)->sacked = TCP_SKB_CB(skb)->sacked&(TCPCB_LOST|TCPCB_EVER_RETRANS|TCPCB_AT_TAIL); in tcp_fragment()
472 TCP_SKB_CB(skb)->sacked &= ~TCPCB_AT_TAIL; in tcp_fragment()
474 if (!skb_shinfo(skb)->nr_frags && skb->ip_summed != CHECKSUM_HW) { in tcp_fragment()
476 buff->csum = csum_partial_copy_nocheck(skb->data + len, skb_put(buff, nsize), in tcp_fragment()
479 skb_trim(skb, len); in tcp_fragment()
481 skb->csum = csum_block_sub(skb->csum, buff->csum, len); in tcp_fragment()
483 skb->ip_summed = CHECKSUM_HW; in tcp_fragment()
484 skb_split(skb, buff, len); in tcp_fragment()
487 buff->ip_summed = skb->ip_summed; in tcp_fragment()
492 TCP_SKB_CB(buff)->when = TCP_SKB_CB(skb)->when; in tcp_fragment()
495 __skb_append(skb, buff); in tcp_fragment()
576 struct sk_buff *skb; in tcp_write_xmit() local
586 while((skb = tp->send_head) && in tcp_write_xmit()
587 tcp_snd_test(tp, skb, mss_now, tcp_skb_is_last(sk, skb) ? nonagle : 1)) { in tcp_write_xmit()
588 if (skb->len > mss_now) { in tcp_write_xmit()
589 if (tcp_fragment(sk, skb, mss_now)) in tcp_write_xmit()
593 TCP_SKB_CB(skb)->when = tcp_time_stamp; in tcp_write_xmit()
594 if (tcp_transmit_skb(sk, skb_clone(skb, GFP_ATOMIC))) in tcp_write_xmit()
597 update_send_head(sk, tp, skb); in tcp_write_xmit()
598 tcp_minshall_update(tp, mss_now, skb); in tcp_write_xmit()
713 static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *skb, int mss_now) in tcp_retrans_try_collapse() argument
716 struct sk_buff *next_skb = skb->next; in tcp_retrans_try_collapse()
721 if(!skb_cloned(skb) && !skb_cloned(next_skb)) { in tcp_retrans_try_collapse()
722 int skb_size = skb->len, next_skb_size = next_skb->len; in tcp_retrans_try_collapse()
723 u16 flags = TCP_SKB_CB(skb)->flags; in tcp_retrans_try_collapse()
737 if ((next_skb_size > skb_tailroom(skb)) || in tcp_retrans_try_collapse()
744 memcpy(skb_put(skb, next_skb_size), next_skb->data, next_skb_size); in tcp_retrans_try_collapse()
747 skb->ip_summed = CHECKSUM_HW; in tcp_retrans_try_collapse()
749 if (skb->ip_summed != CHECKSUM_HW) in tcp_retrans_try_collapse()
750 skb->csum = csum_block_add(skb->csum, next_skb->csum, skb_size); in tcp_retrans_try_collapse()
753 TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(next_skb)->end_seq; in tcp_retrans_try_collapse()
757 TCP_SKB_CB(skb)->flags = flags; in tcp_retrans_try_collapse()
762 TCP_SKB_CB(skb)->sacked |= TCP_SKB_CB(next_skb)->sacked&(TCPCB_EVER_RETRANS|TCPCB_AT_TAIL); in tcp_retrans_try_collapse()
792 struct sk_buff *skb; in tcp_simple_retransmit() local
796 for_retrans_queue(skb, sk, tp) { in tcp_simple_retransmit()
797 if (skb->len > mss && in tcp_simple_retransmit()
798 !(TCP_SKB_CB(skb)->sacked&TCPCB_SACKED_ACKED)) { in tcp_simple_retransmit()
799 if (TCP_SKB_CB(skb)->sacked&TCPCB_SACKED_RETRANS) { in tcp_simple_retransmit()
800 TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS; in tcp_simple_retransmit()
803 if (!(TCP_SKB_CB(skb)->sacked&TCPCB_LOST)) { in tcp_simple_retransmit()
804 TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; in tcp_simple_retransmit()
835 int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb) in tcp_retransmit_skb() argument
852 if (!before(TCP_SKB_CB(skb)->seq, tp->snd_una+tp->snd_wnd) in tcp_retransmit_skb()
853 && TCP_SKB_CB(skb)->seq != tp->snd_una) in tcp_retransmit_skb()
856 if(skb->len > cur_mss) { in tcp_retransmit_skb()
857 if(tcp_fragment(sk, skb, cur_mss)) in tcp_retransmit_skb()
865 if(!(TCP_SKB_CB(skb)->flags & TCPCB_FLAG_SYN) && in tcp_retransmit_skb()
866 (skb->len < (cur_mss >> 1)) && in tcp_retransmit_skb()
867 (skb->next != tp->send_head) && in tcp_retransmit_skb()
868 (skb->next != (struct sk_buff *)&sk->write_queue) && in tcp_retransmit_skb()
869 (skb_shinfo(skb)->nr_frags == 0 && skb_shinfo(skb->next)->nr_frags == 0) && in tcp_retransmit_skb()
871 tcp_retrans_try_collapse(sk, skb, cur_mss); in tcp_retransmit_skb()
880 if(skb->len > 0 && in tcp_retransmit_skb()
881 (TCP_SKB_CB(skb)->flags & TCPCB_FLAG_FIN) && in tcp_retransmit_skb()
882 tp->snd_una == (TCP_SKB_CB(skb)->end_seq - 1)) { in tcp_retransmit_skb()
883 if (!pskb_trim(skb, 0)) { in tcp_retransmit_skb()
884 TCP_SKB_CB(skb)->seq = TCP_SKB_CB(skb)->end_seq - 1; in tcp_retransmit_skb()
885 skb->ip_summed = CHECKSUM_NONE; in tcp_retransmit_skb()
886 skb->csum = 0; in tcp_retransmit_skb()
893 TCP_SKB_CB(skb)->when = tcp_time_stamp; in tcp_retransmit_skb()
895 err = tcp_transmit_skb(sk, (skb_cloned(skb) ? in tcp_retransmit_skb()
896 pskb_copy(skb, GFP_ATOMIC): in tcp_retransmit_skb()
897 skb_clone(skb, GFP_ATOMIC))); in tcp_retransmit_skb()
904 if (TCP_SKB_CB(skb)->sacked&TCPCB_SACKED_RETRANS) { in tcp_retransmit_skb()
909 TCP_SKB_CB(skb)->sacked |= TCPCB_RETRANS; in tcp_retransmit_skb()
914 tp->retrans_stamp = TCP_SKB_CB(skb)->when; in tcp_retransmit_skb()
921 TCP_SKB_CB(skb)->ack_seq = tp->snd_nxt; in tcp_retransmit_skb()
937 struct sk_buff *skb; in tcp_xmit_retransmit_queue() local
942 for_retrans_queue(skb, sk, tp) { in tcp_xmit_retransmit_queue()
943 __u8 sacked = TCP_SKB_CB(skb)->sacked; in tcp_xmit_retransmit_queue()
950 if (tcp_retransmit_skb(sk, skb)) in tcp_xmit_retransmit_queue()
957 if (skb == skb_peek(&sk->write_queue)) in tcp_xmit_retransmit_queue()
989 for_retrans_queue(skb, sk, tp) { in tcp_xmit_retransmit_queue()
996 if(TCP_SKB_CB(skb)->sacked & TCPCB_TAGBITS) in tcp_xmit_retransmit_queue()
1000 if(tcp_retransmit_skb(sk, skb)) in tcp_xmit_retransmit_queue()
1003 if (skb == skb_peek(&sk->write_queue)) in tcp_xmit_retransmit_queue()
1017 struct sk_buff *skb = skb_peek_tail(&sk->write_queue); in tcp_send_fin() local
1027 TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_FIN; in tcp_send_fin()
1028 TCP_SKB_CB(skb)->end_seq++; in tcp_send_fin()
1033 skb = alloc_skb(MAX_TCP_HEADER, GFP_KERNEL); in tcp_send_fin()
1034 if (skb) in tcp_send_fin()
1040 skb_reserve(skb, MAX_TCP_HEADER); in tcp_send_fin()
1041 skb->csum = 0; in tcp_send_fin()
1042 TCP_SKB_CB(skb)->flags = (TCPCB_FLAG_ACK | TCPCB_FLAG_FIN); in tcp_send_fin()
1043 TCP_SKB_CB(skb)->sacked = 0; in tcp_send_fin()
1046 TCP_SKB_CB(skb)->seq = tp->write_seq; in tcp_send_fin()
1047 TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(skb)->seq + 1; in tcp_send_fin()
1048 tcp_send_skb(sk, skb, 1, mss_now); in tcp_send_fin()
1061 struct sk_buff *skb; in tcp_send_active_reset() local
1064 skb = alloc_skb(MAX_TCP_HEADER, priority); in tcp_send_active_reset()
1065 if (!skb) { in tcp_send_active_reset()
1071 skb_reserve(skb, MAX_TCP_HEADER); in tcp_send_active_reset()
1072 skb->csum = 0; in tcp_send_active_reset()
1073 TCP_SKB_CB(skb)->flags = (TCPCB_FLAG_ACK | TCPCB_FLAG_RST); in tcp_send_active_reset()
1074 TCP_SKB_CB(skb)->sacked = 0; in tcp_send_active_reset()
1077 TCP_SKB_CB(skb)->seq = tcp_acceptable_seq(sk, tp); in tcp_send_active_reset()
1078 TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(skb)->seq; in tcp_send_active_reset()
1079 TCP_SKB_CB(skb)->when = tcp_time_stamp; in tcp_send_active_reset()
1080 if (tcp_transmit_skb(sk, skb)) in tcp_send_active_reset()
1091 struct sk_buff* skb; in tcp_send_synack() local
1093 skb = skb_peek(&sk->write_queue); in tcp_send_synack()
1094 if (skb == NULL || !(TCP_SKB_CB(skb)->flags&TCPCB_FLAG_SYN)) { in tcp_send_synack()
1098 if (!(TCP_SKB_CB(skb)->flags&TCPCB_FLAG_ACK)) { in tcp_send_synack()
1099 if (skb_cloned(skb)) { in tcp_send_synack()
1100 struct sk_buff *nskb = skb_copy(skb, GFP_ATOMIC); in tcp_send_synack()
1103 __skb_unlink(skb, &sk->write_queue); in tcp_send_synack()
1105 tcp_free_skb(sk, skb); in tcp_send_synack()
1107 skb = nskb; in tcp_send_synack()
1110 TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_ACK; in tcp_send_synack()
1111 TCP_ECN_send_synack(&sk->tp_pinfo.af_tcp, skb); in tcp_send_synack()
1113 TCP_SKB_CB(skb)->when = tcp_time_stamp; in tcp_send_synack()
1114 return tcp_transmit_skb(sk, skb_clone(skb, GFP_ATOMIC)); in tcp_send_synack()
1126 struct sk_buff *skb; in tcp_make_synack() local
1128 skb = sock_wmalloc(sk, MAX_TCP_HEADER + 15, 1, GFP_ATOMIC); in tcp_make_synack()
1129 if (skb == NULL) in tcp_make_synack()
1133 skb_reserve(skb, MAX_TCP_HEADER); in tcp_make_synack()
1135 skb->dst = dst_clone(dst); in tcp_make_synack()
1142 skb->h.th = th = (struct tcphdr *) skb_push(skb, tcp_header_size); in tcp_make_synack()
1150 TCP_SKB_CB(skb)->seq = req->snt_isn; in tcp_make_synack()
1151 TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(skb)->seq + 1; in tcp_make_synack()
1152 th->seq = htonl(TCP_SKB_CB(skb)->seq); in tcp_make_synack()
1171 TCP_SKB_CB(skb)->when = tcp_time_stamp; in tcp_make_synack()
1174 TCP_SKB_CB(skb)->when, in tcp_make_synack()
1177 skb->csum = 0; in tcp_make_synack()
1180 return skb; in tcp_make_synack()
1375 struct sk_buff *skb; in tcp_xmit_probe_skb() local
1378 skb = alloc_skb(MAX_TCP_HEADER, GFP_ATOMIC); in tcp_xmit_probe_skb()
1379 if (skb == NULL) in tcp_xmit_probe_skb()
1383 skb_reserve(skb, MAX_TCP_HEADER); in tcp_xmit_probe_skb()
1384 skb->csum = 0; in tcp_xmit_probe_skb()
1385 TCP_SKB_CB(skb)->flags = TCPCB_FLAG_ACK; in tcp_xmit_probe_skb()
1386 TCP_SKB_CB(skb)->sacked = urgent; in tcp_xmit_probe_skb()
1392 TCP_SKB_CB(skb)->seq = urgent ? tp->snd_una : tp->snd_una - 1; in tcp_xmit_probe_skb()
1393 TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(skb)->seq; in tcp_xmit_probe_skb()
1394 TCP_SKB_CB(skb)->when = tcp_time_stamp; in tcp_xmit_probe_skb()
1395 return tcp_transmit_skb(sk, skb); in tcp_xmit_probe_skb()
1402 struct sk_buff *skb; in tcp_write_wakeup() local
1404 if ((skb = tp->send_head) != NULL && in tcp_write_wakeup()
1405 before(TCP_SKB_CB(skb)->seq, tp->snd_una+tp->snd_wnd)) { in tcp_write_wakeup()
1408 int seg_size = tp->snd_una+tp->snd_wnd-TCP_SKB_CB(skb)->seq; in tcp_write_wakeup()
1410 if (before(tp->pushed_seq, TCP_SKB_CB(skb)->end_seq)) in tcp_write_wakeup()
1411 tp->pushed_seq = TCP_SKB_CB(skb)->end_seq; in tcp_write_wakeup()
1417 if (seg_size < TCP_SKB_CB(skb)->end_seq - TCP_SKB_CB(skb)->seq || in tcp_write_wakeup()
1418 skb->len > mss) { in tcp_write_wakeup()
1420 TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_PSH; in tcp_write_wakeup()
1421 if (tcp_fragment(sk, skb, seg_size)) in tcp_write_wakeup()
1424 TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_PSH; in tcp_write_wakeup()
1425 TCP_SKB_CB(skb)->when = tcp_time_stamp; in tcp_write_wakeup()
1426 err = tcp_transmit_skb(sk, skb_clone(skb, GFP_ATOMIC)); in tcp_write_wakeup()
1428 update_send_head(sk, tp, skb); in tcp_write_wakeup()