net: compat_mmsghdr must be used in sys_recvmmsg
[safe/jmp/linux-2.6] / net / ipv4 / tcp_cong.c
index 4451750..6428b34 100644 (file)
@@ -115,8 +115,8 @@ int tcp_set_default_congestion_control(const char *name)
 
        spin_lock(&tcp_cong_list_lock);
        ca = tcp_ca_find(name);
-#ifdef CONFIG_KMOD
-       if (!ca && capable(CAP_SYS_MODULE)) {
+#ifdef CONFIG_MODULES
+       if (!ca && capable(CAP_NET_ADMIN)) {
                spin_unlock(&tcp_cong_list_lock);
 
                request_module("tcp_%s", name);
@@ -244,9 +244,9 @@ int tcp_set_congestion_control(struct sock *sk, const char *name)
        if (ca == icsk->icsk_ca_ops)
                goto out;
 
-#ifdef CONFIG_KMOD
+#ifdef CONFIG_MODULES
        /* not found attempt to autoload module */
-       if (!ca && capable(CAP_SYS_MODULE)) {
+       if (!ca && capable(CAP_NET_ADMIN)) {
                rcu_read_unlock();
                request_module("tcp_%s", name);
                rcu_read_lock();
@@ -274,6 +274,25 @@ int tcp_set_congestion_control(struct sock *sk, const char *name)
        return err;
 }
 
+/* RFC2861 Check whether we are limited by application or congestion window
+ * This is the inverse of cwnd check in tcp_tso_should_defer
+ */
+int tcp_is_cwnd_limited(const struct sock *sk, u32 in_flight)
+{
+       const struct tcp_sock *tp = tcp_sk(sk);
+       u32 left;
+
+       if (in_flight >= tp->snd_cwnd)
+               return 1;
+
+       left = tp->snd_cwnd - in_flight;
+       if (sk_can_gso(sk) &&
+           left * sysctl_tcp_tso_win_divisor < tp->snd_cwnd &&
+           left * tp->mss_cache < sk->sk_gso_max_size)
+               return 1;
+       return left <= tcp_max_burst(tp);
+}
+EXPORT_SYMBOL_GPL(tcp_is_cwnd_limited);
 
 /*
  * Slow start is used when congestion window is less than slow start
@@ -317,6 +336,19 @@ void tcp_slow_start(struct tcp_sock *tp)
 }
 EXPORT_SYMBOL_GPL(tcp_slow_start);
 
+/* In theory this is tp->snd_cwnd += 1 / tp->snd_cwnd (or alternative w) */
+void tcp_cong_avoid_ai(struct tcp_sock *tp, u32 w)
+{
+       if (tp->snd_cwnd_cnt >= w) {
+               if (tp->snd_cwnd < tp->snd_cwnd_clamp)
+                       tp->snd_cwnd++;
+               tp->snd_cwnd_cnt = 0;
+       } else {
+               tp->snd_cwnd_cnt++;
+       }
+}
+EXPORT_SYMBOL_GPL(tcp_cong_avoid_ai);
+
 /*
  * TCP Reno congestion control
  * This is special case used for fallback as well.
@@ -346,13 +378,7 @@ void tcp_reno_cong_avoid(struct sock *sk, u32 ack, u32 in_flight)
                                tp->snd_cwnd++;
                }
        } else {
-               /* In theory this is tp->snd_cwnd += 1 / tp->snd_cwnd */
-               if (tp->snd_cwnd_cnt >= tp->snd_cwnd) {
-                       if (tp->snd_cwnd < tp->snd_cwnd_clamp)
-                               tp->snd_cwnd++;
-                       tp->snd_cwnd_cnt = 0;
-               } else
-                       tp->snd_cwnd_cnt++;
+               tcp_cong_avoid_ai(tp, tp->snd_cwnd);
        }
 }
 EXPORT_SYMBOL_GPL(tcp_reno_cong_avoid);