aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_metrics.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-01-18 01:19:28 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-18 01:19:28 -0500
commit7d0d46da750a252371cb747b48ddda27d1047881 (patch)
treedb6ac506c54775047278332e1cd3e42aad2aacb9 /net/ipv4/tcp_metrics.c
parent48ba620aab90f4c7e9bb002e2f30863a4ea0f915 (diff)
parent3af57f78c38131b7a66e2b01e06fdacae01992a3 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) The value choosen for the new SO_MAX_PACING_RATE socket option on parisc was very poorly choosen, let's fix it while we still can. From Eric Dumazet. 2) Our generic reciprocal divide was found to handle some edge cases incorrectly, part of this is encoded into the BPF as deep as the JIT engines themselves. Just use a real divide throughout for now. From Eric Dumazet. 3) Because the initial lookup is lockless, the TCP metrics engine can end up creating two entries for the same lookup key. Fix this by doing a second lookup under the lock before we actually create the new entry. From Christoph Paasch. 4) Fix scatter-gather list init in usbnet driver, from Bjørn Mork. 5) Fix unintended 32-bit truncation in cxgb4 driver's bit shifting. From Dan Carpenter. 6) Netlink socket dumping uses the wrong socket state for timewait sockets. Fix from Neal Cardwell. 7) Fix netlink memory leak in ieee802154_add_iface(), from Christian Engelmayer. 8) Multicast forwarding in ipv4 can overflow the per-rule reference counts, causing all multicast traffic to cease. Fix from Hannes Frederic Sowa. 9) via-rhine needs to stop all TX queues when it resets the device, from Richard Weinberger. 10) Fix RDS per-cpu accesses broken by the this_cpu_* conversions. From Gerald Schaefer. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: s390/bpf,jit: fix 32 bit divisions, use unsigned divide instructions parisc: fix SO_MAX_PACING_RATE typo ipv6: simplify detection of first operational link-local address on interface tcp: metrics: Avoid duplicate entries with the same destination-IP net: rds: fix per-cpu helper usage e1000e: Fix compilation warning when !CONFIG_PM_SLEEP bpf: do not use reciprocal divide be2net: add dma_mapping_error() check for dma_map_page() bnx2x: Don't release PCI bars on shutdown net,via-rhine: Fix tx_timeout handling batman-adv: fix batman-adv header overhead calculation qlge: Fix vlan netdev features. net: avoid reference counter overflows on fib_rules in multicast forwarding dm9601: add USB IDs for new dm96xx variants MAINTAINERS: add virtio-dev ML for virtio ieee802154: Fix memory leak in ieee802154_add_iface() net: usbnet: fix SG initialisation inet_diag: fix inet_diag_dump_icsk() to use correct state for timewait sockets cxgb4: silence shift wrapping static checker warning
Diffstat (limited to 'net/ipv4/tcp_metrics.c')
-rw-r--r--net/ipv4/tcp_metrics.c51
1 files changed, 32 insertions, 19 deletions
diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
index 06493736fbc8..098b3a29f6f3 100644
--- a/net/ipv4/tcp_metrics.c
+++ b/net/ipv4/tcp_metrics.c
@@ -22,6 +22,9 @@
22 22
23int sysctl_tcp_nometrics_save __read_mostly; 23int sysctl_tcp_nometrics_save __read_mostly;
24 24
25static struct tcp_metrics_block *__tcp_get_metrics(const struct inetpeer_addr *addr,
26 struct net *net, unsigned int hash);
27
25struct tcp_fastopen_metrics { 28struct tcp_fastopen_metrics {
26 u16 mss; 29 u16 mss;
27 u16 syn_loss:10; /* Recurring Fast Open SYN losses */ 30 u16 syn_loss:10; /* Recurring Fast Open SYN losses */
@@ -130,16 +133,41 @@ static void tcpm_suck_dst(struct tcp_metrics_block *tm, struct dst_entry *dst,
130 } 133 }
131} 134}
132 135
136#define TCP_METRICS_TIMEOUT (60 * 60 * HZ)
137
138static void tcpm_check_stamp(struct tcp_metrics_block *tm, struct dst_entry *dst)
139{
140 if (tm && unlikely(time_after(jiffies, tm->tcpm_stamp + TCP_METRICS_TIMEOUT)))
141 tcpm_suck_dst(tm, dst, false);
142}
143
144#define TCP_METRICS_RECLAIM_DEPTH 5
145#define TCP_METRICS_RECLAIM_PTR (struct tcp_metrics_block *) 0x1UL
146
133static struct tcp_metrics_block *tcpm_new(struct dst_entry *dst, 147static struct tcp_metrics_block *tcpm_new(struct dst_entry *dst,
134 struct inetpeer_addr *addr, 148 struct inetpeer_addr *addr,
135 unsigned int hash, 149 unsigned int hash)
136 bool reclaim)
137{ 150{
138 struct tcp_metrics_block *tm; 151 struct tcp_metrics_block *tm;
139 struct net *net; 152 struct net *net;
153 bool reclaim = false;
140 154
141 spin_lock_bh(&tcp_metrics_lock); 155 spin_lock_bh(&tcp_metrics_lock);
142 net = dev_net(dst->dev); 156 net = dev_net(dst->dev);
157
158 /* While waiting for the spin-lock the cache might have been populated
159 * with this entry and so we have to check again.
160 */
161 tm = __tcp_get_metrics(addr, net, hash);
162 if (tm == TCP_METRICS_RECLAIM_PTR) {
163 reclaim = true;
164 tm = NULL;
165 }
166 if (tm) {
167 tcpm_check_stamp(tm, dst);
168 goto out_unlock;
169 }
170
143 if (unlikely(reclaim)) { 171 if (unlikely(reclaim)) {
144 struct tcp_metrics_block *oldest; 172 struct tcp_metrics_block *oldest;
145 173
@@ -169,17 +197,6 @@ out_unlock:
169 return tm; 197 return tm;
170} 198}
171 199
172#define TCP_METRICS_TIMEOUT (60 * 60 * HZ)
173
174static void tcpm_check_stamp(struct tcp_metrics_block *tm, struct dst_entry *dst)
175{
176 if (tm && unlikely(time_after(jiffies, tm->tcpm_stamp + TCP_METRICS_TIMEOUT)))
177 tcpm_suck_dst(tm, dst, false);
178}
179
180#define TCP_METRICS_RECLAIM_DEPTH 5
181#define TCP_METRICS_RECLAIM_PTR (struct tcp_metrics_block *) 0x1UL
182
183static struct tcp_metrics_block *tcp_get_encode(struct tcp_metrics_block *tm, int depth) 200static struct tcp_metrics_block *tcp_get_encode(struct tcp_metrics_block *tm, int depth)
184{ 201{
185 if (tm) 202 if (tm)
@@ -282,7 +299,6 @@ static struct tcp_metrics_block *tcp_get_metrics(struct sock *sk,
282 struct inetpeer_addr addr; 299 struct inetpeer_addr addr;
283 unsigned int hash; 300 unsigned int hash;
284 struct net *net; 301 struct net *net;
285 bool reclaim;
286 302
287 addr.family = sk->sk_family; 303 addr.family = sk->sk_family;
288 switch (addr.family) { 304 switch (addr.family) {
@@ -304,13 +320,10 @@ static struct tcp_metrics_block *tcp_get_metrics(struct sock *sk,
304 hash = hash_32(hash, net->ipv4.tcp_metrics_hash_log); 320 hash = hash_32(hash, net->ipv4.tcp_metrics_hash_log);
305 321
306 tm = __tcp_get_metrics(&addr, net, hash); 322 tm = __tcp_get_metrics(&addr, net, hash);
307 reclaim = false; 323 if (tm == TCP_METRICS_RECLAIM_PTR)
308 if (tm == TCP_METRICS_RECLAIM_PTR) {
309 reclaim = true;
310 tm = NULL; 324 tm = NULL;
311 }
312 if (!tm && create) 325 if (!tm && create)
313 tm = tcpm_new(dst, &addr, hash, reclaim); 326 tm = tcpm_new(dst, &addr, hash);
314 else 327 else
315 tcpm_check_stamp(tm, dst); 328 tcpm_check_stamp(tm, dst);
316 329