aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorJulian Anastasov <ja@ssi.bg>2012-07-23 03:46:38 -0400
committerDavid S. Miller <davem@davemloft.net>2012-07-23 03:57:12 -0400
commit9a0a9502cbf19d31f7387e3066f3d1a491bef616 (patch)
treede744eaedb4c0942fab7d0c6af583460b2803fa0 /net/ipv4
parent9b70749e64132e17ab02239b82fcb4a2c55554d1 (diff)
tcp: avoid oops in tcp_metrics and reset tcpm_stamp
In tcp_tw_remember_stamp we incorrectly checked tw instead of tm, it can lead to oops if the cached entry is not found. tcpm_stamp was not updated in tcpm_check_stamp when tcpm_suck_dst was called, move the update into tcpm_suck_dst, so that we do not call it infinitely on every next cache hit after TCP_METRICS_TIMEOUT. Signed-off-by: Julian Anastasov <ja@ssi.bg> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/tcp_metrics.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
index 992f1bff4fc6..2288a6399e1e 100644
--- a/net/ipv4/tcp_metrics.c
+++ b/net/ipv4/tcp_metrics.c
@@ -107,6 +107,8 @@ static void tcpm_suck_dst(struct tcp_metrics_block *tm, struct dst_entry *dst)
107{ 107{
108 u32 val; 108 u32 val;
109 109
110 tm->tcpm_stamp = jiffies;
111
110 val = 0; 112 val = 0;
111 if (dst_metric_locked(dst, RTAX_RTT)) 113 if (dst_metric_locked(dst, RTAX_RTT))
112 val |= 1 << TCP_METRIC_RTT; 114 val |= 1 << TCP_METRIC_RTT;
@@ -158,7 +160,6 @@ static struct tcp_metrics_block *tcpm_new(struct dst_entry *dst,
158 goto out_unlock; 160 goto out_unlock;
159 } 161 }
160 tm->tcpm_addr = *addr; 162 tm->tcpm_addr = *addr;
161 tm->tcpm_stamp = jiffies;
162 163
163 tcpm_suck_dst(tm, dst); 164 tcpm_suck_dst(tm, dst);
164 165
@@ -621,7 +622,7 @@ bool tcp_tw_remember_stamp(struct inet_timewait_sock *tw)
621 622
622 rcu_read_lock(); 623 rcu_read_lock();
623 tm = __tcp_get_metrics_tw(tw); 624 tm = __tcp_get_metrics_tw(tw);
624 if (tw) { 625 if (tm) {
625 const struct tcp_timewait_sock *tcptw; 626 const struct tcp_timewait_sock *tcptw;
626 struct sock *sk = (struct sock *) tw; 627 struct sock *sk = (struct sock *) tw;
627 628