]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - net/ipv4/tcp_metrics.c
Merge branch 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[linux.git] / net / ipv4 / tcp_metrics.c
index b467a7cabf40e6af2ce69649f3ca48635bf06319..279db8822439dadf8582eda047478429183652ed 100644 (file)
@@ -385,7 +385,8 @@ void tcp_update_metrics(struct sock *sk)
 
        if (tcp_in_initial_slowstart(tp)) {
                /* Slow start still did not finish. */
-               if (!tcp_metric_locked(tm, TCP_METRIC_SSTHRESH)) {
+               if (!net->ipv4.sysctl_tcp_no_ssthresh_metrics_save &&
+                   !tcp_metric_locked(tm, TCP_METRIC_SSTHRESH)) {
                        val = tcp_metric_get(tm, TCP_METRIC_SSTHRESH);
                        if (val && (tp->snd_cwnd >> 1) > val)
                                tcp_metric_set(tm, TCP_METRIC_SSTHRESH,
@@ -400,7 +401,8 @@ void tcp_update_metrics(struct sock *sk)
        } else if (!tcp_in_slow_start(tp) &&
                   icsk->icsk_ca_state == TCP_CA_Open) {
                /* Cong. avoidance phase, cwnd is reliable. */
-               if (!tcp_metric_locked(tm, TCP_METRIC_SSTHRESH))
+               if (!net->ipv4.sysctl_tcp_no_ssthresh_metrics_save &&
+                   !tcp_metric_locked(tm, TCP_METRIC_SSTHRESH))
                        tcp_metric_set(tm, TCP_METRIC_SSTHRESH,
                                       max(tp->snd_cwnd >> 1, tp->snd_ssthresh));
                if (!tcp_metric_locked(tm, TCP_METRIC_CWND)) {
@@ -416,7 +418,8 @@ void tcp_update_metrics(struct sock *sk)
                        tcp_metric_set(tm, TCP_METRIC_CWND,
                                       (val + tp->snd_ssthresh) >> 1);
                }
-               if (!tcp_metric_locked(tm, TCP_METRIC_SSTHRESH)) {
+               if (!net->ipv4.sysctl_tcp_no_ssthresh_metrics_save &&
+                   !tcp_metric_locked(tm, TCP_METRIC_SSTHRESH)) {
                        val = tcp_metric_get(tm, TCP_METRIC_SSTHRESH);
                        if (val && tp->snd_ssthresh > val)
                                tcp_metric_set(tm, TCP_METRIC_SSTHRESH,
@@ -441,6 +444,7 @@ void tcp_init_metrics(struct sock *sk)
 {
        struct dst_entry *dst = __sk_dst_get(sk);
        struct tcp_sock *tp = tcp_sk(sk);
+       struct net *net = sock_net(sk);
        struct tcp_metrics_block *tm;
        u32 val, crtt = 0; /* cached RTT scaled by 8 */
 
@@ -458,7 +462,8 @@ void tcp_init_metrics(struct sock *sk)
        if (tcp_metric_locked(tm, TCP_METRIC_CWND))
                tp->snd_cwnd_clamp = tcp_metric_get(tm, TCP_METRIC_CWND);
 
-       val = tcp_metric_get(tm, TCP_METRIC_SSTHRESH);
+       val = net->ipv4.sysctl_tcp_no_ssthresh_metrics_save ?
+             0 : tcp_metric_get(tm, TCP_METRIC_SSTHRESH);
        if (val) {
                tp->snd_ssthresh = val;
                if (tp->snd_ssthresh > tp->snd_cwnd_clamp)
@@ -512,16 +517,6 @@ void tcp_init_metrics(struct sock *sk)
 
                inet_csk(sk)->icsk_rto = TCP_TIMEOUT_FALLBACK;
        }
-       /* Cut cwnd down to 1 per RFC5681 if SYN or SYN-ACK has been
-        * retransmitted. In light of RFC6298 more aggressive 1sec
-        * initRTO, we only reset cwnd when more than 1 SYN/SYN-ACK
-        * retransmission has occurred.
-        */
-       if (tp->total_retrans > 1)
-               tp->snd_cwnd = 1;
-       else
-               tp->snd_cwnd = tcp_init_cwnd(tp, dst);
-       tp->snd_cwnd_stamp = tcp_jiffies32;
 }
 
 bool tcp_peer_is_proven(struct request_sock *req, struct dst_entry *dst)
@@ -658,7 +653,7 @@ static int tcp_metrics_fill_info(struct sk_buff *msg,
        {
                int n = 0;
 
-               nest = nla_nest_start(msg, TCP_METRICS_ATTR_VALS);
+               nest = nla_nest_start_noflag(msg, TCP_METRICS_ATTR_VALS);
                if (!nest)
                        goto nla_put_failure;
                for (i = 0; i < TCP_METRIC_MAX_KERNEL + 1; i++) {
@@ -951,14 +946,14 @@ static int tcp_metrics_nl_cmd_del(struct sk_buff *skb, struct genl_info *info)
 static const struct genl_ops tcp_metrics_nl_ops[] = {
        {
                .cmd = TCP_METRICS_CMD_GET,
+               .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
                .doit = tcp_metrics_nl_cmd_get,
                .dumpit = tcp_metrics_nl_dump,
-               .policy = tcp_metrics_nl_policy,
        },
        {
                .cmd = TCP_METRICS_CMD_DEL,
+               .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
                .doit = tcp_metrics_nl_cmd_del,
-               .policy = tcp_metrics_nl_policy,
                .flags = GENL_ADMIN_PERM,
        },
 };
@@ -968,6 +963,7 @@ static struct genl_family tcp_metrics_nl_family __ro_after_init = {
        .name           = TCP_METRICS_GENL_NAME,
        .version        = TCP_METRICS_GENL_VERSION,
        .maxattr        = TCP_METRICS_ATTR_MAX,
+       .policy = tcp_metrics_nl_policy,
        .netnsok        = true,
        .module         = THIS_MODULE,
        .ops            = tcp_metrics_nl_ops,