aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/tcp.c')
-rw-r--r--net/ipv4/tcp.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 99ad52c00c96..2cf9a898ce50 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -460,9 +460,9 @@ static inline int forced_push(struct tcp_sock *tp)
460 return after(tp->write_seq, tp->pushed_seq + (tp->max_window >> 1)); 460 return after(tp->write_seq, tp->pushed_seq + (tp->max_window >> 1));
461} 461}
462 462
463static inline void skb_entail(struct sock *sk, struct tcp_sock *tp, 463static inline void skb_entail(struct sock *sk, struct sk_buff *skb)
464 struct sk_buff *skb)
465{ 464{
465 struct tcp_sock *tp = tcp_sk(sk);
466 struct tcp_skb_cb *tcb = TCP_SKB_CB(skb); 466 struct tcp_skb_cb *tcb = TCP_SKB_CB(skb);
467 467
468 skb->csum = 0; 468 skb->csum = 0;
@@ -486,15 +486,17 @@ static inline void tcp_mark_urg(struct tcp_sock *tp, int flags,
486 } 486 }
487} 487}
488 488
489static inline void tcp_push(struct sock *sk, struct tcp_sock *tp, int flags, 489static inline void tcp_push(struct sock *sk, int flags, int mss_now,
490 int mss_now, int nonagle) 490 int nonagle)
491{ 491{
492 struct tcp_sock *tp = tcp_sk(sk);
493
492 if (tcp_send_head(sk)) { 494 if (tcp_send_head(sk)) {
493 struct sk_buff *skb = tcp_write_queue_tail(sk); 495 struct sk_buff *skb = tcp_write_queue_tail(sk);
494 if (!(flags & MSG_MORE) || forced_push(tp)) 496 if (!(flags & MSG_MORE) || forced_push(tp))
495 tcp_mark_push(tp, skb); 497 tcp_mark_push(tp, skb);
496 tcp_mark_urg(tp, flags, skb); 498 tcp_mark_urg(tp, flags, skb);
497 __tcp_push_pending_frames(sk, tp, mss_now, 499 __tcp_push_pending_frames(sk, mss_now,
498 (flags & MSG_MORE) ? TCP_NAGLE_CORK : nonagle); 500 (flags & MSG_MORE) ? TCP_NAGLE_CORK : nonagle);
499 } 501 }
500} 502}
@@ -540,7 +542,7 @@ new_segment:
540 if (!skb) 542 if (!skb)
541 goto wait_for_memory; 543 goto wait_for_memory;
542 544
543 skb_entail(sk, tp, skb); 545 skb_entail(sk, skb);
544 copy = size_goal; 546 copy = size_goal;
545 } 547 }
546 548
@@ -586,7 +588,7 @@ new_segment:
586 588
587 if (forced_push(tp)) { 589 if (forced_push(tp)) {
588 tcp_mark_push(tp, skb); 590 tcp_mark_push(tp, skb);
589 __tcp_push_pending_frames(sk, tp, mss_now, TCP_NAGLE_PUSH); 591 __tcp_push_pending_frames(sk, mss_now, TCP_NAGLE_PUSH);
590 } else if (skb == tcp_send_head(sk)) 592 } else if (skb == tcp_send_head(sk))
591 tcp_push_one(sk, mss_now); 593 tcp_push_one(sk, mss_now);
592 continue; 594 continue;
@@ -595,7 +597,7 @@ wait_for_sndbuf:
595 set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); 597 set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
596wait_for_memory: 598wait_for_memory:
597 if (copied) 599 if (copied)
598 tcp_push(sk, tp, flags & ~MSG_MORE, mss_now, TCP_NAGLE_PUSH); 600 tcp_push(sk, flags & ~MSG_MORE, mss_now, TCP_NAGLE_PUSH);
599 601
600 if ((err = sk_stream_wait_memory(sk, &timeo)) != 0) 602 if ((err = sk_stream_wait_memory(sk, &timeo)) != 0)
601 goto do_error; 603 goto do_error;
@@ -606,7 +608,7 @@ wait_for_memory:
606 608
607out: 609out:
608 if (copied) 610 if (copied)
609 tcp_push(sk, tp, flags, mss_now, tp->nonagle); 611 tcp_push(sk, flags, mss_now, tp->nonagle);
610 return copied; 612 return copied;
611 613
612do_error: 614do_error:
@@ -637,8 +639,9 @@ ssize_t tcp_sendpage(struct socket *sock, struct page *page, int offset,
637#define TCP_PAGE(sk) (sk->sk_sndmsg_page) 639#define TCP_PAGE(sk) (sk->sk_sndmsg_page)
638#define TCP_OFF(sk) (sk->sk_sndmsg_off) 640#define TCP_OFF(sk) (sk->sk_sndmsg_off)
639 641
640static inline int select_size(struct sock *sk, struct tcp_sock *tp) 642static inline int select_size(struct sock *sk)
641{ 643{
644 struct tcp_sock *tp = tcp_sk(sk);
642 int tmp = tp->mss_cache; 645 int tmp = tp->mss_cache;
643 646
644 if (sk->sk_route_caps & NETIF_F_SG) { 647 if (sk->sk_route_caps & NETIF_F_SG) {
@@ -714,7 +717,7 @@ new_segment:
714 if (!sk_stream_memory_free(sk)) 717 if (!sk_stream_memory_free(sk))
715 goto wait_for_sndbuf; 718 goto wait_for_sndbuf;
716 719
717 skb = sk_stream_alloc_pskb(sk, select_size(sk, tp), 720 skb = sk_stream_alloc_pskb(sk, select_size(sk),
718 0, sk->sk_allocation); 721 0, sk->sk_allocation);
719 if (!skb) 722 if (!skb)
720 goto wait_for_memory; 723 goto wait_for_memory;
@@ -725,7 +728,7 @@ new_segment:
725 if (sk->sk_route_caps & NETIF_F_ALL_CSUM) 728 if (sk->sk_route_caps & NETIF_F_ALL_CSUM)
726 skb->ip_summed = CHECKSUM_PARTIAL; 729 skb->ip_summed = CHECKSUM_PARTIAL;
727 730
728 skb_entail(sk, tp, skb); 731 skb_entail(sk, skb);
729 copy = size_goal; 732 copy = size_goal;
730 } 733 }
731 734
@@ -830,7 +833,7 @@ new_segment:
830 833
831 if (forced_push(tp)) { 834 if (forced_push(tp)) {
832 tcp_mark_push(tp, skb); 835 tcp_mark_push(tp, skb);
833 __tcp_push_pending_frames(sk, tp, mss_now, TCP_NAGLE_PUSH); 836 __tcp_push_pending_frames(sk, mss_now, TCP_NAGLE_PUSH);
834 } else if (skb == tcp_send_head(sk)) 837 } else if (skb == tcp_send_head(sk))
835 tcp_push_one(sk, mss_now); 838 tcp_push_one(sk, mss_now);
836 continue; 839 continue;
@@ -839,7 +842,7 @@ wait_for_sndbuf:
839 set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); 842 set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
840wait_for_memory: 843wait_for_memory:
841 if (copied) 844 if (copied)
842 tcp_push(sk, tp, flags & ~MSG_MORE, mss_now, TCP_NAGLE_PUSH); 845 tcp_push(sk, flags & ~MSG_MORE, mss_now, TCP_NAGLE_PUSH);
843 846
844 if ((err = sk_stream_wait_memory(sk, &timeo)) != 0) 847 if ((err = sk_stream_wait_memory(sk, &timeo)) != 0)
845 goto do_error; 848 goto do_error;
@@ -851,7 +854,7 @@ wait_for_memory:
851 854
852out: 855out:
853 if (copied) 856 if (copied)
854 tcp_push(sk, tp, flags, mss_now, tp->nonagle); 857 tcp_push(sk, flags, mss_now, tp->nonagle);
855 TCP_CHECK_TIMER(sk); 858 TCP_CHECK_TIMER(sk);
856 release_sock(sk); 859 release_sock(sk);
857 return copied; 860 return copied;
@@ -1389,7 +1392,7 @@ do_prequeue:
1389skip_copy: 1392skip_copy:
1390 if (tp->urg_data && after(tp->copied_seq, tp->urg_seq)) { 1393 if (tp->urg_data && after(tp->copied_seq, tp->urg_seq)) {
1391 tp->urg_data = 0; 1394 tp->urg_data = 0;
1392 tcp_fast_path_check(sk, tp); 1395 tcp_fast_path_check(sk);
1393 } 1396 }
1394 if (used + offset < skb->len) 1397 if (used + offset < skb->len)
1395 continue; 1398 continue;
@@ -1830,7 +1833,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
1830 * for currently queued segments. 1833 * for currently queued segments.
1831 */ 1834 */
1832 tp->nonagle |= TCP_NAGLE_OFF|TCP_NAGLE_PUSH; 1835 tp->nonagle |= TCP_NAGLE_OFF|TCP_NAGLE_PUSH;
1833 tcp_push_pending_frames(sk, tp); 1836 tcp_push_pending_frames(sk);
1834 } else { 1837 } else {
1835 tp->nonagle &= ~TCP_NAGLE_OFF; 1838 tp->nonagle &= ~TCP_NAGLE_OFF;
1836 } 1839 }
@@ -1854,7 +1857,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
1854 tp->nonagle &= ~TCP_NAGLE_CORK; 1857 tp->nonagle &= ~TCP_NAGLE_CORK;
1855 if (tp->nonagle&TCP_NAGLE_OFF) 1858 if (tp->nonagle&TCP_NAGLE_OFF)
1856 tp->nonagle |= TCP_NAGLE_PUSH; 1859 tp->nonagle |= TCP_NAGLE_PUSH;
1857 tcp_push_pending_frames(sk, tp); 1860 tcp_push_pending_frames(sk);
1858 } 1861 }
1859 break; 1862 break;
1860 1863