net: include/net/sock.h cleanup
[deliverable/linux.git] / net / ipv4 / tcp.c
index c2cff8b62772f35265d12a9025a286c05ef51757..e8a80d0b5b3c8a0270290ad94a9d1c28dc82c14c 100644 (file)
@@ -978,39 +978,6 @@ static inline int select_size(const struct sock *sk, bool sg)
        return tmp;
 }
 
-static int tcp_send_rcvq(struct sock *sk, struct msghdr *msg, size_t size)
-{
-       struct sk_buff *skb;
-       struct tcphdr *th;
-       bool fragstolen;
-
-       skb = alloc_skb(size + sizeof(*th), sk->sk_allocation);
-       if (!skb)
-               goto err;
-
-       th = (struct tcphdr *)skb_put(skb, sizeof(*th));
-       skb_reset_transport_header(skb);
-       memset(th, 0, sizeof(*th));
-
-       if (memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size))
-               goto err_free;
-
-       TCP_SKB_CB(skb)->seq = tcp_sk(sk)->rcv_nxt;
-       TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(skb)->seq + size;
-       TCP_SKB_CB(skb)->ack_seq = tcp_sk(sk)->snd_una - 1;
-
-       if (tcp_queue_rcv(sk, skb, sizeof(*th), &fragstolen)) {
-               WARN_ON_ONCE(fragstolen); /* should not happen */
-               __kfree_skb(skb);
-       }
-       return size;
-
-err_free:
-       kfree_skb(skb);
-err:
-       return -ENOMEM;
-}
-
 int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
                size_t size)
 {
@@ -1506,11 +1473,11 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,
                                break;
                }
                if (tcp_hdr(skb)->fin) {
-                       sk_eat_skb(sk, skb, 0);
+                       sk_eat_skb(sk, skb, false);
                        ++seq;
                        break;
                }
-               sk_eat_skb(sk, skb, 0);
+               sk_eat_skb(sk, skb, false);
                if (!desc->count)
                        break;
                tp->copied_seq = seq;
@@ -1546,7 +1513,7 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
        int target;             /* Read at least this many bytes */
        long timeo;
        struct task_struct *user_recv = NULL;
-       int copied_early = 0;
+       bool copied_early = false;
        struct sk_buff *skb;
        u32 urg_hole = 0;
 
@@ -1778,9 +1745,9 @@ do_prequeue:
                }
                if ((flags & MSG_PEEK) &&
                    (peek_seq - copied - urg_hole != tp->copied_seq)) {
-                       if (net_ratelimit())
-                               printk(KERN_DEBUG "TCP(%s:%d): Application bug, race in MSG_PEEK.\n",
-                                      current->comm, task_pid_nr(current));
+                       net_dbg_ratelimited("TCP(%s:%d): Application bug, race in MSG_PEEK\n",
+                                           current->comm,
+                                           task_pid_nr(current));
                        peek_seq = tp->copied_seq;
                }
                continue;
@@ -1834,7 +1801,7 @@ do_prequeue:
                                dma_async_memcpy_issue_pending(tp->ucopy.dma_chan);
 
                                if ((offset + used) == skb->len)
-                                       copied_early = 1;
+                                       copied_early = true;
 
                        } else
 #endif
@@ -1868,7 +1835,7 @@ skip_copy:
                        goto found_fin_ok;
                if (!(flags & MSG_PEEK)) {
                        sk_eat_skb(sk, skb, copied_early);
-                       copied_early = 0;
+                       copied_early = false;
                }
                continue;
 
@@ -1877,7 +1844,7 @@ skip_copy:
                ++*seq;
                if (!(flags & MSG_PEEK)) {
                        sk_eat_skb(sk, skb, copied_early);
-                       copied_early = 0;
+                       copied_early = false;
                }
                break;
        } while (len > 0);
@@ -2035,10 +2002,10 @@ bool tcp_check_oom(struct sock *sk, int shift)
        too_many_orphans = tcp_too_many_orphans(sk, shift);
        out_of_socket_memory = tcp_out_of_memory(sk);
 
-       if (too_many_orphans && net_ratelimit())
-               pr_info("too many orphaned sockets\n");
-       if (out_of_socket_memory && net_ratelimit())
-               pr_info("out of memory -- consider tuning tcp_mem\n");
+       if (too_many_orphans)
+               net_info_ratelimited("too many orphaned sockets\n");
+       if (out_of_socket_memory)
+               net_info_ratelimited("out of memory -- consider tuning tcp_mem\n");
        return too_many_orphans || out_of_socket_memory;
 }
 
@@ -3515,7 +3482,7 @@ void __init tcp_init(void)
 {
        struct sk_buff *skb = NULL;
        unsigned long limit;
-       int max_share, cnt;
+       int max_rshare, max_wshare, cnt;
        unsigned int i;
        unsigned long jiffy = jiffies;
 
@@ -3575,15 +3542,16 @@ void __init tcp_init(void)
        tcp_init_mem(&init_net);
        /* Set per-socket limits to no more than 1/128 the pressure threshold */
        limit = nr_free_buffer_pages() << (PAGE_SHIFT - 7);
-       max_share = min(4UL*1024*1024, limit);
+       max_wshare = min(4UL*1024*1024, limit);
+       max_rshare = min(6UL*1024*1024, limit);
 
        sysctl_tcp_wmem[0] = SK_MEM_QUANTUM;
        sysctl_tcp_wmem[1] = 16*1024;
-       sysctl_tcp_wmem[2] = max(64*1024, max_share);
+       sysctl_tcp_wmem[2] = max(64*1024, max_wshare);
 
        sysctl_tcp_rmem[0] = SK_MEM_QUANTUM;
        sysctl_tcp_rmem[1] = 87380;
-       sysctl_tcp_rmem[2] = max(87380, max_share);
+       sysctl_tcp_rmem[2] = max(87380, max_rshare);
 
        pr_info("Hash tables configured (established %u bind %u)\n",
                tcp_hashinfo.ehash_mask + 1, tcp_hashinfo.bhash_size);
This page took 0.027129 seconds and 5 git commands to generate.