aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2012-01-08 06:31:24 -0500
committerIngo Molnar <mingo@elte.hu>2012-01-08 06:31:24 -0500
commit636f0c70f2557e0819b50c74e31b4a027327015e (patch)
tree3a259ef26659dac92782651440091b9f5ab1a7f7 /net
parent675eef66e3edcab8065533edfefbcbbacb9a30d3 (diff)
parent2e885057b7f75035f0b85e02f737891482815a81 (diff)
Merge branch 'tip/perf/urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace into perf/core
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/hci_conn.c2
-rw-r--r--net/bluetooth/hci_core.c2
-rw-r--r--net/bluetooth/l2cap_core.c12
-rw-r--r--net/bluetooth/rfcomm/core.c1
-rw-r--r--net/bridge/br_netfilter.c8
-rw-r--r--net/core/flow.c12
-rw-r--r--net/core/net-sysfs.c7
-rw-r--r--net/core/sock.c6
-rw-r--r--net/ipv4/ipconfig.c4
-rw-r--r--net/ipv4/route.c112
-rw-r--r--net/ipv6/ip6_output.c2
-rw-r--r--net/llc/af_llc.c14
-rw-r--r--net/netfilter/ipvs/ip_vs_conn.c2
-rw-r--r--net/netfilter/ipvs/ip_vs_ctl.c10
-rw-r--r--net/netfilter/ipvs/ip_vs_sync.c2
-rw-r--r--net/netfilter/nf_conntrack_netlink.c22
-rw-r--r--net/netfilter/xt_connbytes.c6
-rw-r--r--net/nfc/nci/core.c2
-rw-r--r--net/packet/af_packet.c12
-rw-r--r--net/sched/sch_mqprio.c2
-rw-r--r--net/sched/sch_netem.c7
-rw-r--r--net/sched/sch_qfq.c4
-rw-r--r--net/sctp/associola.c2
-rw-r--r--net/sctp/output.c8
-rw-r--r--net/sctp/outqueue.c6
-rw-r--r--net/sctp/protocol.c3
-rw-r--r--net/sctp/socket.c2
-rw-r--r--net/sctp/sysctl.c13
-rw-r--r--net/sunrpc/sched.c30
-rw-r--r--net/sunrpc/xprt.c10
-rw-r--r--net/xfrm/xfrm_policy.c18
31 files changed, 268 insertions, 75 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index e0af7237cd9..c1c597e3e19 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -673,7 +673,7 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
673 goto encrypt; 673 goto encrypt;
674 674
675auth: 675auth:
676 if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) 676 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend))
677 return 0; 677 return 0;
678 678
679 if (!hci_conn_auth(conn, sec_level, auth_type)) 679 if (!hci_conn_auth(conn, sec_level, auth_type))
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index be84ae33ae3..b84458dcc22 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -613,7 +613,7 @@ static int hci_dev_do_close(struct hci_dev *hdev)
613 if (!test_bit(HCI_RAW, &hdev->flags)) { 613 if (!test_bit(HCI_RAW, &hdev->flags)) {
614 set_bit(HCI_INIT, &hdev->flags); 614 set_bit(HCI_INIT, &hdev->flags);
615 __hci_request(hdev, hci_reset_req, 0, 615 __hci_request(hdev, hci_reset_req, 0,
616 msecs_to_jiffies(HCI_INIT_TIMEOUT)); 616 msecs_to_jiffies(250));
617 clear_bit(HCI_INIT, &hdev->flags); 617 clear_bit(HCI_INIT, &hdev->flags);
618 } 618 }
619 619
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 5ea94a1eecf..17b5b1cd965 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -2152,7 +2152,7 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi
2152 void *ptr = req->data; 2152 void *ptr = req->data;
2153 int type, olen; 2153 int type, olen;
2154 unsigned long val; 2154 unsigned long val;
2155 struct l2cap_conf_rfc rfc; 2155 struct l2cap_conf_rfc rfc = { .mode = L2CAP_MODE_BASIC };
2156 2156
2157 BT_DBG("chan %p, rsp %p, len %d, req %p", chan, rsp, len, data); 2157 BT_DBG("chan %p, rsp %p, len %d, req %p", chan, rsp, len, data);
2158 2158
@@ -2271,6 +2271,16 @@ static void l2cap_conf_rfc_get(struct l2cap_chan *chan, void *rsp, int len)
2271 } 2271 }
2272 } 2272 }
2273 2273
2274 /* Use sane default values in case a misbehaving remote device
2275 * did not send an RFC option.
2276 */
2277 rfc.mode = chan->mode;
2278 rfc.retrans_timeout = cpu_to_le16(L2CAP_DEFAULT_RETRANS_TO);
2279 rfc.monitor_timeout = cpu_to_le16(L2CAP_DEFAULT_MONITOR_TO);
2280 rfc.max_pdu_size = cpu_to_le16(chan->imtu);
2281
2282 BT_ERR("Expected RFC option was not found, using defaults");
2283
2274done: 2284done:
2275 switch (rfc.mode) { 2285 switch (rfc.mode) {
2276 case L2CAP_MODE_ERTM: 2286 case L2CAP_MODE_ERTM:
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 4e32e18211f..2d28dfe9838 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -1146,6 +1146,7 @@ static int rfcomm_recv_ua(struct rfcomm_session *s, u8 dlci)
1146 if (list_empty(&s->dlcs)) { 1146 if (list_empty(&s->dlcs)) {
1147 s->state = BT_DISCONN; 1147 s->state = BT_DISCONN;
1148 rfcomm_send_disc(s, 0); 1148 rfcomm_send_disc(s, 0);
1149 rfcomm_session_clear_timer(s);
1149 } 1150 }
1150 1151
1151 break; 1152 break;
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index d6ec3720c77..fa8b8f76358 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -114,12 +114,18 @@ static struct neighbour *fake_neigh_lookup(const struct dst_entry *dst, const vo
114 return NULL; 114 return NULL;
115} 115}
116 116
117static unsigned int fake_mtu(const struct dst_entry *dst)
118{
119 return dst->dev->mtu;
120}
121
117static struct dst_ops fake_dst_ops = { 122static struct dst_ops fake_dst_ops = {
118 .family = AF_INET, 123 .family = AF_INET,
119 .protocol = cpu_to_be16(ETH_P_IP), 124 .protocol = cpu_to_be16(ETH_P_IP),
120 .update_pmtu = fake_update_pmtu, 125 .update_pmtu = fake_update_pmtu,
121 .cow_metrics = fake_cow_metrics, 126 .cow_metrics = fake_cow_metrics,
122 .neigh_lookup = fake_neigh_lookup, 127 .neigh_lookup = fake_neigh_lookup,
128 .mtu = fake_mtu,
123}; 129};
124 130
125/* 131/*
@@ -141,7 +147,7 @@ void br_netfilter_rtable_init(struct net_bridge *br)
141 rt->dst.dev = br->dev; 147 rt->dst.dev = br->dev;
142 rt->dst.path = &rt->dst; 148 rt->dst.path = &rt->dst;
143 dst_init_metrics(&rt->dst, br_dst_default_metrics, true); 149 dst_init_metrics(&rt->dst, br_dst_default_metrics, true);
144 rt->dst.flags = DST_NOXFRM; 150 rt->dst.flags = DST_NOXFRM | DST_NOPEER;
145 rt->dst.ops = &fake_dst_ops; 151 rt->dst.ops = &fake_dst_ops;
146} 152}
147 153
diff --git a/net/core/flow.c b/net/core/flow.c
index 8ae42de9c79..e318c7e9804 100644
--- a/net/core/flow.c
+++ b/net/core/flow.c
@@ -358,6 +358,18 @@ void flow_cache_flush(void)
358 put_online_cpus(); 358 put_online_cpus();
359} 359}
360 360
361static void flow_cache_flush_task(struct work_struct *work)
362{
363 flow_cache_flush();
364}
365
366static DECLARE_WORK(flow_cache_flush_work, flow_cache_flush_task);
367
368void flow_cache_flush_deferred(void)
369{
370 schedule_work(&flow_cache_flush_work);
371}
372
361static int __cpuinit flow_cache_cpu_prepare(struct flow_cache *fc, int cpu) 373static int __cpuinit flow_cache_cpu_prepare(struct flow_cache *fc, int cpu)
362{ 374{
363 struct flow_cache_percpu *fcp = per_cpu_ptr(fc->percpu, cpu); 375 struct flow_cache_percpu *fcp = per_cpu_ptr(fc->percpu, cpu);
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index c71c434a4c0..385aefe5364 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -665,11 +665,14 @@ static ssize_t store_rps_dev_flow_table_cnt(struct netdev_rx_queue *queue,
665 if (count) { 665 if (count) {
666 int i; 666 int i;
667 667
668 if (count > 1<<30) { 668 if (count > INT_MAX)
669 return -EINVAL;
670 count = roundup_pow_of_two(count);
671 if (count > (ULONG_MAX - sizeof(struct rps_dev_flow_table))
672 / sizeof(struct rps_dev_flow)) {
669 /* Enforce a limit to prevent overflow */ 673 /* Enforce a limit to prevent overflow */
670 return -EINVAL; 674 return -EINVAL;
671 } 675 }
672 count = roundup_pow_of_two(count);
673 table = vmalloc(RPS_DEV_FLOW_TABLE_SIZE(count)); 676 table = vmalloc(RPS_DEV_FLOW_TABLE_SIZE(count));
674 if (!table) 677 if (!table)
675 return -ENOMEM; 678 return -ENOMEM;
diff --git a/net/core/sock.c b/net/core/sock.c
index 4ed7b1d12f5..b23f174ab84 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -288,11 +288,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
288 unsigned long flags; 288 unsigned long flags;
289 struct sk_buff_head *list = &sk->sk_receive_queue; 289 struct sk_buff_head *list = &sk->sk_receive_queue;
290 290
291 /* Cast sk->rcvbuf to unsigned... It's pointless, but reduces 291 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
292 number of warnings when compiling with -W --ANK
293 */
294 if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >=
295 (unsigned)sk->sk_rcvbuf) {
296 atomic_inc(&sk->sk_drops); 292 atomic_inc(&sk->sk_drops);
297 trace_sock_rcvqueue_full(sk, skb); 293 trace_sock_rcvqueue_full(sk, skb);
298 return -ENOMEM; 294 return -ENOMEM;
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 0da2afc97f3..99ec116bef1 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -253,6 +253,10 @@ static int __init ic_open_devs(void)
253 } 253 }
254 } 254 }
255 255
256 /* no point in waiting if we could not bring up at least one device */
257 if (!ic_first_dev)
258 goto have_carrier;
259
256 /* wait for a carrier on at least one device */ 260 /* wait for a carrier on at least one device */
257 start = jiffies; 261 start = jiffies;
258 while (jiffies - start < msecs_to_jiffies(CONF_CARRIER_TIMEOUT)) { 262 while (jiffies - start < msecs_to_jiffies(CONF_CARRIER_TIMEOUT)) {
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 46af62363b8..94cdbc55ca7 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -91,6 +91,7 @@
91#include <linux/rcupdate.h> 91#include <linux/rcupdate.h>
92#include <linux/times.h> 92#include <linux/times.h>
93#include <linux/slab.h> 93#include <linux/slab.h>
94#include <linux/prefetch.h>
94#include <net/dst.h> 95#include <net/dst.h>
95#include <net/net_namespace.h> 96#include <net/net_namespace.h>
96#include <net/protocol.h> 97#include <net/protocol.h>
@@ -120,6 +121,7 @@
120 121
121static int ip_rt_max_size; 122static int ip_rt_max_size;
122static int ip_rt_gc_timeout __read_mostly = RT_GC_TIMEOUT; 123static int ip_rt_gc_timeout __read_mostly = RT_GC_TIMEOUT;
124static int ip_rt_gc_interval __read_mostly = 60 * HZ;
123static int ip_rt_gc_min_interval __read_mostly = HZ / 2; 125static int ip_rt_gc_min_interval __read_mostly = HZ / 2;
124static int ip_rt_redirect_number __read_mostly = 9; 126static int ip_rt_redirect_number __read_mostly = 9;
125static int ip_rt_redirect_load __read_mostly = HZ / 50; 127static int ip_rt_redirect_load __read_mostly = HZ / 50;
@@ -133,6 +135,9 @@ static int ip_rt_min_advmss __read_mostly = 256;
133static int rt_chain_length_max __read_mostly = 20; 135static int rt_chain_length_max __read_mostly = 20;
134static int redirect_genid; 136static int redirect_genid;
135 137
138static struct delayed_work expires_work;
139static unsigned long expires_ljiffies;
140
136/* 141/*
137 * Interface to generic destination cache. 142 * Interface to generic destination cache.
138 */ 143 */
@@ -830,6 +835,97 @@ static int has_noalias(const struct rtable *head, const struct rtable *rth)
830 return ONE; 835 return ONE;
831} 836}
832 837
838static void rt_check_expire(void)
839{
840 static unsigned int rover;
841 unsigned int i = rover, goal;
842 struct rtable *rth;
843 struct rtable __rcu **rthp;
844 unsigned long samples = 0;
845 unsigned long sum = 0, sum2 = 0;
846 unsigned long delta;
847 u64 mult;
848
849 delta = jiffies - expires_ljiffies;
850 expires_ljiffies = jiffies;
851 mult = ((u64)delta) << rt_hash_log;
852 if (ip_rt_gc_timeout > 1)
853 do_div(mult, ip_rt_gc_timeout);
854 goal = (unsigned int)mult;
855 if (goal > rt_hash_mask)
856 goal = rt_hash_mask + 1;
857 for (; goal > 0; goal--) {
858 unsigned long tmo = ip_rt_gc_timeout;
859 unsigned long length;
860
861 i = (i + 1) & rt_hash_mask;
862 rthp = &rt_hash_table[i].chain;
863
864 if (need_resched())
865 cond_resched();
866
867 samples++;
868
869 if (rcu_dereference_raw(*rthp) == NULL)
870 continue;
871 length = 0;
872 spin_lock_bh(rt_hash_lock_addr(i));
873 while ((rth = rcu_dereference_protected(*rthp,
874 lockdep_is_held(rt_hash_lock_addr(i)))) != NULL) {
875 prefetch(rth->dst.rt_next);
876 if (rt_is_expired(rth)) {
877 *rthp = rth->dst.rt_next;
878 rt_free(rth);
879 continue;
880 }
881 if (rth->dst.expires) {
882 /* Entry is expired even if it is in use */
883 if (time_before_eq(jiffies, rth->dst.expires)) {
884nofree:
885 tmo >>= 1;
886 rthp = &rth->dst.rt_next;
887 /*
888 * We only count entries on
889 * a chain with equal hash inputs once
890 * so that entries for different QOS
891 * levels, and other non-hash input
892 * attributes don't unfairly skew
893 * the length computation
894 */
895 length += has_noalias(rt_hash_table[i].chain, rth);
896 continue;
897 }
898 } else if (!rt_may_expire(rth, tmo, ip_rt_gc_timeout))
899 goto nofree;
900
901 /* Cleanup aged off entries. */
902 *rthp = rth->dst.rt_next;
903 rt_free(rth);
904 }
905 spin_unlock_bh(rt_hash_lock_addr(i));
906 sum += length;
907 sum2 += length*length;
908 }
909 if (samples) {
910 unsigned long avg = sum / samples;
911 unsigned long sd = int_sqrt(sum2 / samples - avg*avg);
912 rt_chain_length_max = max_t(unsigned long,
913 ip_rt_gc_elasticity,
914 (avg + 4*sd) >> FRACT_BITS);
915 }
916 rover = i;
917}
918
919/*
920 * rt_worker_func() is run in process context.
921 * we call rt_check_expire() to scan part of the hash table
922 */
923static void rt_worker_func(struct work_struct *work)
924{
925 rt_check_expire();
926 schedule_delayed_work(&expires_work, ip_rt_gc_interval);
927}
928
833/* 929/*
834 * Perturbation of rt_genid by a small quantity [1..256] 930 * Perturbation of rt_genid by a small quantity [1..256]
835 * Using 8 bits of shuffling ensure we can call rt_cache_invalidate() 931 * Using 8 bits of shuffling ensure we can call rt_cache_invalidate()
@@ -1271,7 +1367,7 @@ void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more)
1271{ 1367{
1272 struct rtable *rt = (struct rtable *) dst; 1368 struct rtable *rt = (struct rtable *) dst;
1273 1369
1274 if (rt) { 1370 if (rt && !(rt->dst.flags & DST_NOPEER)) {
1275 if (rt->peer == NULL) 1371 if (rt->peer == NULL)
1276 rt_bind_peer(rt, rt->rt_dst, 1); 1372 rt_bind_peer(rt, rt->rt_dst, 1);
1277 1373
@@ -1282,7 +1378,7 @@ void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more)
1282 iph->id = htons(inet_getid(rt->peer, more)); 1378 iph->id = htons(inet_getid(rt->peer, more));
1283 return; 1379 return;
1284 } 1380 }
1285 } else 1381 } else if (!rt)
1286 printk(KERN_DEBUG "rt_bind_peer(0) @%p\n", 1382 printk(KERN_DEBUG "rt_bind_peer(0) @%p\n",
1287 __builtin_return_address(0)); 1383 __builtin_return_address(0));
1288 1384
@@ -3179,6 +3275,13 @@ static ctl_table ipv4_route_table[] = {
3179 .proc_handler = proc_dointvec_jiffies, 3275 .proc_handler = proc_dointvec_jiffies,
3180 }, 3276 },
3181 { 3277 {
3278 .procname = "gc_interval",
3279 .data = &ip_rt_gc_interval,
3280 .maxlen = sizeof(int),
3281 .mode = 0644,
3282 .proc_handler = proc_dointvec_jiffies,
3283 },
3284 {
3182 .procname = "redirect_load", 3285 .procname = "redirect_load",
3183 .data = &ip_rt_redirect_load, 3286 .data = &ip_rt_redirect_load,
3184 .maxlen = sizeof(int), 3287 .maxlen = sizeof(int),
@@ -3388,6 +3491,11 @@ int __init ip_rt_init(void)
3388 devinet_init(); 3491 devinet_init();
3389 ip_fib_init(); 3492 ip_fib_init();
3390 3493
3494 INIT_DELAYED_WORK_DEFERRABLE(&expires_work, rt_worker_func);
3495 expires_ljiffies = jiffies;
3496 schedule_delayed_work(&expires_work,
3497 net_random() % ip_rt_gc_interval + ip_rt_gc_interval);
3498
3391 if (ip_rt_proc_init()) 3499 if (ip_rt_proc_init())
3392 printk(KERN_ERR "Unable to create route proc files\n"); 3500 printk(KERN_ERR "Unable to create route proc files\n");
3393#ifdef CONFIG_XFRM 3501#ifdef CONFIG_XFRM
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 84d0bd5cac9..ec562713db9 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -603,7 +603,7 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
603 static atomic_t ipv6_fragmentation_id; 603 static atomic_t ipv6_fragmentation_id;
604 int old, new; 604 int old, new;
605 605
606 if (rt) { 606 if (rt && !(rt->dst.flags & DST_NOPEER)) {
607 struct inet_peer *peer; 607 struct inet_peer *peer;
608 608
609 if (!rt->rt6i_peer) 609 if (!rt->rt6i_peer)
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index dfd3a648a55..a18e6c3d36e 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -833,15 +833,15 @@ static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock,
833 copied += used; 833 copied += used;
834 len -= used; 834 len -= used;
835 835
836 /* For non stream protcols we get one packet per recvmsg call */
837 if (sk->sk_type != SOCK_STREAM)
838 goto copy_uaddr;
839
836 if (!(flags & MSG_PEEK)) { 840 if (!(flags & MSG_PEEK)) {
837 sk_eat_skb(sk, skb, 0); 841 sk_eat_skb(sk, skb, 0);
838 *seq = 0; 842 *seq = 0;
839 } 843 }
840 844
841 /* For non stream protcols we get one packet per recvmsg call */
842 if (sk->sk_type != SOCK_STREAM)
843 goto copy_uaddr;
844
845 /* Partial read */ 845 /* Partial read */
846 if (used + offset < skb->len) 846 if (used + offset < skb->len)
847 continue; 847 continue;
@@ -857,6 +857,12 @@ copy_uaddr:
857 } 857 }
858 if (llc_sk(sk)->cmsg_flags) 858 if (llc_sk(sk)->cmsg_flags)
859 llc_cmsg_rcv(msg, skb); 859 llc_cmsg_rcv(msg, skb);
860
861 if (!(flags & MSG_PEEK)) {
862 sk_eat_skb(sk, skb, 0);
863 *seq = 0;
864 }
865
860 goto out; 866 goto out;
861} 867}
862 868
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
index 12571fb2881..29fa5badde7 100644
--- a/net/netfilter/ipvs/ip_vs_conn.c
+++ b/net/netfilter/ipvs/ip_vs_conn.c
@@ -616,7 +616,7 @@ struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp)
616 if ((cp) && (!cp->dest)) { 616 if ((cp) && (!cp->dest)) {
617 dest = ip_vs_find_dest(ip_vs_conn_net(cp), cp->af, &cp->daddr, 617 dest = ip_vs_find_dest(ip_vs_conn_net(cp), cp->af, &cp->daddr,
618 cp->dport, &cp->vaddr, cp->vport, 618 cp->dport, &cp->vaddr, cp->vport,
619 cp->protocol, cp->fwmark); 619 cp->protocol, cp->fwmark, cp->flags);
620 ip_vs_bind_dest(cp, dest); 620 ip_vs_bind_dest(cp, dest);
621 return dest; 621 return dest;
622 } else 622 } else
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index 008bf97cc91..e1a66cf37f9 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -619,15 +619,21 @@ struct ip_vs_dest *ip_vs_find_dest(struct net *net, int af,
619 const union nf_inet_addr *daddr, 619 const union nf_inet_addr *daddr,
620 __be16 dport, 620 __be16 dport,
621 const union nf_inet_addr *vaddr, 621 const union nf_inet_addr *vaddr,
622 __be16 vport, __u16 protocol, __u32 fwmark) 622 __be16 vport, __u16 protocol, __u32 fwmark,
623 __u32 flags)
623{ 624{
624 struct ip_vs_dest *dest; 625 struct ip_vs_dest *dest;
625 struct ip_vs_service *svc; 626 struct ip_vs_service *svc;
627 __be16 port = dport;
626 628
627 svc = ip_vs_service_get(net, af, fwmark, protocol, vaddr, vport); 629 svc = ip_vs_service_get(net, af, fwmark, protocol, vaddr, vport);
628 if (!svc) 630 if (!svc)
629 return NULL; 631 return NULL;
630 dest = ip_vs_lookup_dest(svc, daddr, dport); 632 if (fwmark && (flags & IP_VS_CONN_F_FWD_MASK) != IP_VS_CONN_F_MASQ)
633 port = 0;
634 dest = ip_vs_lookup_dest(svc, daddr, port);
635 if (!dest)
636 dest = ip_vs_lookup_dest(svc, daddr, port ^ dport);
631 if (dest) 637 if (dest)
632 atomic_inc(&dest->refcnt); 638 atomic_inc(&dest->refcnt);
633 ip_vs_service_put(svc); 639 ip_vs_service_put(svc);
diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
index 3cdd479f9b5..2b6678c0ce1 100644
--- a/net/netfilter/ipvs/ip_vs_sync.c
+++ b/net/netfilter/ipvs/ip_vs_sync.c
@@ -740,7 +740,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
740 * but still handled. 740 * but still handled.
741 */ 741 */
742 dest = ip_vs_find_dest(net, type, daddr, dport, param->vaddr, 742 dest = ip_vs_find_dest(net, type, daddr, dport, param->vaddr,
743 param->vport, protocol, fwmark); 743 param->vport, protocol, fwmark, flags);
744 744
745 /* Set the approprite ativity flag */ 745 /* Set the approprite ativity flag */
746 if (protocol == IPPROTO_TCP) { 746 if (protocol == IPPROTO_TCP) {
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index ef21b221f03..257e77256c5 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -135,7 +135,7 @@ nla_put_failure:
135static inline int 135static inline int
136ctnetlink_dump_timeout(struct sk_buff *skb, const struct nf_conn *ct) 136ctnetlink_dump_timeout(struct sk_buff *skb, const struct nf_conn *ct)
137{ 137{
138 long timeout = (ct->timeout.expires - jiffies) / HZ; 138 long timeout = ((long)ct->timeout.expires - (long)jiffies) / HZ;
139 139
140 if (timeout < 0) 140 if (timeout < 0)
141 timeout = 0; 141 timeout = 0;
@@ -1358,12 +1358,15 @@ ctnetlink_create_conntrack(struct net *net, u16 zone,
1358 nf_ct_protonum(ct)); 1358 nf_ct_protonum(ct));
1359 if (helper == NULL) { 1359 if (helper == NULL) {
1360 rcu_read_unlock(); 1360 rcu_read_unlock();
1361 spin_unlock_bh(&nf_conntrack_lock);
1361#ifdef CONFIG_MODULES 1362#ifdef CONFIG_MODULES
1362 if (request_module("nfct-helper-%s", helpname) < 0) { 1363 if (request_module("nfct-helper-%s", helpname) < 0) {
1364 spin_lock_bh(&nf_conntrack_lock);
1363 err = -EOPNOTSUPP; 1365 err = -EOPNOTSUPP;
1364 goto err1; 1366 goto err1;
1365 } 1367 }
1366 1368
1369 spin_lock_bh(&nf_conntrack_lock);
1367 rcu_read_lock(); 1370 rcu_read_lock();
1368 helper = __nf_conntrack_helper_find(helpname, 1371 helper = __nf_conntrack_helper_find(helpname,
1369 nf_ct_l3num(ct), 1372 nf_ct_l3num(ct),
@@ -1638,7 +1641,7 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb,
1638 const struct nf_conntrack_expect *exp) 1641 const struct nf_conntrack_expect *exp)
1639{ 1642{
1640 struct nf_conn *master = exp->master; 1643 struct nf_conn *master = exp->master;
1641 long timeout = (exp->timeout.expires - jiffies) / HZ; 1644 long timeout = ((long)exp->timeout.expires - (long)jiffies) / HZ;
1642 struct nf_conn_help *help; 1645 struct nf_conn_help *help;
1643 1646
1644 if (timeout < 0) 1647 if (timeout < 0)
@@ -1869,25 +1872,30 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
1869 1872
1870 err = -ENOMEM; 1873 err = -ENOMEM;
1871 skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 1874 skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
1872 if (skb2 == NULL) 1875 if (skb2 == NULL) {
1876 nf_ct_expect_put(exp);
1873 goto out; 1877 goto out;
1878 }
1874 1879
1875 rcu_read_lock(); 1880 rcu_read_lock();
1876 err = ctnetlink_exp_fill_info(skb2, NETLINK_CB(skb).pid, 1881 err = ctnetlink_exp_fill_info(skb2, NETLINK_CB(skb).pid,
1877 nlh->nlmsg_seq, IPCTNL_MSG_EXP_NEW, exp); 1882 nlh->nlmsg_seq, IPCTNL_MSG_EXP_NEW, exp);
1878 rcu_read_unlock(); 1883 rcu_read_unlock();
1884 nf_ct_expect_put(exp);
1879 if (err <= 0) 1885 if (err <= 0)
1880 goto free; 1886 goto free;
1881 1887
1882 nf_ct_expect_put(exp); 1888 err = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT);
1889 if (err < 0)
1890 goto out;
1883 1891
1884 return netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT); 1892 return 0;
1885 1893
1886free: 1894free:
1887 kfree_skb(skb2); 1895 kfree_skb(skb2);
1888out: 1896out:
1889 nf_ct_expect_put(exp); 1897 /* this avoids a loop in nfnetlink. */
1890 return err; 1898 return err == -EAGAIN ? -ENOBUFS : err;
1891} 1899}
1892 1900
1893static int 1901static int
diff --git a/net/netfilter/xt_connbytes.c b/net/netfilter/xt_connbytes.c
index 5b138506690..9ddf1c3bfb3 100644
--- a/net/netfilter/xt_connbytes.c
+++ b/net/netfilter/xt_connbytes.c
@@ -87,10 +87,10 @@ connbytes_mt(const struct sk_buff *skb, struct xt_action_param *par)
87 break; 87 break;
88 } 88 }
89 89
90 if (sinfo->count.to) 90 if (sinfo->count.to >= sinfo->count.from)
91 return what <= sinfo->count.to && what >= sinfo->count.from; 91 return what <= sinfo->count.to && what >= sinfo->count.from;
92 else 92 else /* inverted */
93 return what >= sinfo->count.from; 93 return what < sinfo->count.to || what > sinfo->count.from;
94} 94}
95 95
96static int connbytes_mt_check(const struct xt_mtchk_param *par) 96static int connbytes_mt_check(const struct xt_mtchk_param *par)
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 3925c657876..ea66034499c 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -69,7 +69,7 @@ static int __nci_request(struct nci_dev *ndev,
69 __u32 timeout) 69 __u32 timeout)
70{ 70{
71 int rc = 0; 71 int rc = 0;
72 unsigned long completion_rc; 72 long completion_rc;
73 73
74 ndev->req_status = NCI_REQ_PEND; 74 ndev->req_status = NCI_REQ_PEND;
75 75
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 82a6f34d39d..d9d4970b9b0 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1630,8 +1630,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
1630 if (snaplen > res) 1630 if (snaplen > res)
1631 snaplen = res; 1631 snaplen = res;
1632 1632
1633 if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >= 1633 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf)
1634 (unsigned)sk->sk_rcvbuf)
1635 goto drop_n_acct; 1634 goto drop_n_acct;
1636 1635
1637 if (skb_shared(skb)) { 1636 if (skb_shared(skb)) {
@@ -1762,8 +1761,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
1762 if (po->tp_version <= TPACKET_V2) { 1761 if (po->tp_version <= TPACKET_V2) {
1763 if (macoff + snaplen > po->rx_ring.frame_size) { 1762 if (macoff + snaplen > po->rx_ring.frame_size) {
1764 if (po->copy_thresh && 1763 if (po->copy_thresh &&
1765 atomic_read(&sk->sk_rmem_alloc) + skb->truesize 1764 atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf) {
1766 < (unsigned)sk->sk_rcvbuf) {
1767 if (skb_shared(skb)) { 1765 if (skb_shared(skb)) {
1768 copy_skb = skb_clone(skb, GFP_ATOMIC); 1766 copy_skb = skb_clone(skb, GFP_ATOMIC);
1769 } else { 1767 } else {
@@ -2450,8 +2448,12 @@ static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 protoc
2450{ 2448{
2451 struct packet_sock *po = pkt_sk(sk); 2449 struct packet_sock *po = pkt_sk(sk);
2452 2450
2453 if (po->fanout) 2451 if (po->fanout) {
2452 if (dev)
2453 dev_put(dev);
2454
2454 return -EINVAL; 2455 return -EINVAL;
2456 }
2455 2457
2456 lock_sock(sk); 2458 lock_sock(sk);
2457 2459
diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c
index f88256cbacb..28de4309233 100644
--- a/net/sched/sch_mqprio.c
+++ b/net/sched/sch_mqprio.c
@@ -107,7 +107,7 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt)
107 if (!netif_is_multiqueue(dev)) 107 if (!netif_is_multiqueue(dev))
108 return -EOPNOTSUPP; 108 return -EOPNOTSUPP;
109 109
110 if (nla_len(opt) < sizeof(*qopt)) 110 if (!opt || nla_len(opt) < sizeof(*qopt))
111 return -EINVAL; 111 return -EINVAL;
112 112
113 qopt = nla_data(opt); 113 qopt = nla_data(opt);
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index eb3b9a86c6e..a4ab207cdc5 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -488,7 +488,7 @@ static int get_dist_table(struct Qdisc *sch, const struct nlattr *attr)
488 return -EINVAL; 488 return -EINVAL;
489 489
490 s = sizeof(struct disttable) + n * sizeof(s16); 490 s = sizeof(struct disttable) + n * sizeof(s16);
491 d = kmalloc(s, GFP_KERNEL); 491 d = kmalloc(s, GFP_KERNEL | __GFP_NOWARN);
492 if (!d) 492 if (!d)
493 d = vmalloc(s); 493 d = vmalloc(s);
494 if (!d) 494 if (!d)
@@ -501,9 +501,10 @@ static int get_dist_table(struct Qdisc *sch, const struct nlattr *attr)
501 root_lock = qdisc_root_sleeping_lock(sch); 501 root_lock = qdisc_root_sleeping_lock(sch);
502 502
503 spin_lock_bh(root_lock); 503 spin_lock_bh(root_lock);
504 dist_free(q->delay_dist); 504 swap(q->delay_dist, d);
505 q->delay_dist = d;
506 spin_unlock_bh(root_lock); 505 spin_unlock_bh(root_lock);
506
507 dist_free(d);
507 return 0; 508 return 0;
508} 509}
509 510
diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c
index 10334340859..7b0325459e7 100644
--- a/net/sched/sch_qfq.c
+++ b/net/sched/sch_qfq.c
@@ -817,11 +817,11 @@ skip_unblock:
817static void qfq_update_start(struct qfq_sched *q, struct qfq_class *cl) 817static void qfq_update_start(struct qfq_sched *q, struct qfq_class *cl)
818{ 818{
819 unsigned long mask; 819 unsigned long mask;
820 uint32_t limit, roundedF; 820 u64 limit, roundedF;
821 int slot_shift = cl->grp->slot_shift; 821 int slot_shift = cl->grp->slot_shift;
822 822
823 roundedF = qfq_round_down(cl->F, slot_shift); 823 roundedF = qfq_round_down(cl->F, slot_shift);
824 limit = qfq_round_down(q->V, slot_shift) + (1UL << slot_shift); 824 limit = qfq_round_down(q->V, slot_shift) + (1ULL << slot_shift);
825 825
826 if (!qfq_gt(cl->F, q->V) || qfq_gt(roundedF, limit)) { 826 if (!qfq_gt(cl->F, q->V) || qfq_gt(roundedF, limit)) {
827 /* timestamp was stale */ 827 /* timestamp was stale */
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 152b5b3c3ff..acd2edbc073 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -173,7 +173,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
173 asoc->timeouts[SCTP_EVENT_TIMEOUT_HEARTBEAT] = 0; 173 asoc->timeouts[SCTP_EVENT_TIMEOUT_HEARTBEAT] = 0;
174 asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = asoc->sackdelay; 174 asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = asoc->sackdelay;
175 asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] = 175 asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] =
176 (unsigned long)sp->autoclose * HZ; 176 min_t(unsigned long, sp->autoclose, sctp_max_autoclose) * HZ;
177 177
178 /* Initializes the timers */ 178 /* Initializes the timers */
179 for (i = SCTP_EVENT_TIMEOUT_NONE; i < SCTP_NUM_TIMEOUT_TYPES; ++i) 179 for (i = SCTP_EVENT_TIMEOUT_NONE; i < SCTP_NUM_TIMEOUT_TYPES; ++i)
diff --git a/net/sctp/output.c b/net/sctp/output.c
index 08b3cead650..817174eb5f4 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -697,13 +697,7 @@ static void sctp_packet_append_data(struct sctp_packet *packet,
697 /* Keep track of how many bytes are in flight to the receiver. */ 697 /* Keep track of how many bytes are in flight to the receiver. */
698 asoc->outqueue.outstanding_bytes += datasize; 698 asoc->outqueue.outstanding_bytes += datasize;
699 699
700 /* Update our view of the receiver's rwnd. Include sk_buff overhead 700 /* Update our view of the receiver's rwnd. */
701 * while updating peer.rwnd so that it reduces the chances of a
702 * receiver running out of receive buffer space even when receive
703 * window is still open. This can happen when a sender is sending
704 * sending small messages.
705 */
706 datasize += sizeof(struct sk_buff);
707 if (datasize < rwnd) 701 if (datasize < rwnd)
708 rwnd -= datasize; 702 rwnd -= datasize;
709 else 703 else
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
index 14c2b06028f..cfeb1d4a1ee 100644
--- a/net/sctp/outqueue.c
+++ b/net/sctp/outqueue.c
@@ -411,8 +411,7 @@ void sctp_retransmit_mark(struct sctp_outq *q,
411 chunk->transport->flight_size -= 411 chunk->transport->flight_size -=
412 sctp_data_size(chunk); 412 sctp_data_size(chunk);
413 q->outstanding_bytes -= sctp_data_size(chunk); 413 q->outstanding_bytes -= sctp_data_size(chunk);
414 q->asoc->peer.rwnd += (sctp_data_size(chunk) + 414 q->asoc->peer.rwnd += sctp_data_size(chunk);
415 sizeof(struct sk_buff));
416 } 415 }
417 continue; 416 continue;
418 } 417 }
@@ -432,8 +431,7 @@ void sctp_retransmit_mark(struct sctp_outq *q,
432 * (Section 7.2.4)), add the data size of those 431 * (Section 7.2.4)), add the data size of those
433 * chunks to the rwnd. 432 * chunks to the rwnd.
434 */ 433 */
435 q->asoc->peer.rwnd += (sctp_data_size(chunk) + 434 q->asoc->peer.rwnd += sctp_data_size(chunk);
436 sizeof(struct sk_buff));
437 q->outstanding_bytes -= sctp_data_size(chunk); 435 q->outstanding_bytes -= sctp_data_size(chunk);
438 if (chunk->transport) 436 if (chunk->transport)
439 transport->flight_size -= sctp_data_size(chunk); 437 transport->flight_size -= sctp_data_size(chunk);
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 61b9fca5a17..6f6ad868683 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -1285,6 +1285,9 @@ SCTP_STATIC __init int sctp_init(void)
1285 sctp_max_instreams = SCTP_DEFAULT_INSTREAMS; 1285 sctp_max_instreams = SCTP_DEFAULT_INSTREAMS;
1286 sctp_max_outstreams = SCTP_DEFAULT_OUTSTREAMS; 1286 sctp_max_outstreams = SCTP_DEFAULT_OUTSTREAMS;
1287 1287
1288 /* Initialize maximum autoclose timeout. */
1289 sctp_max_autoclose = INT_MAX / HZ;
1290
1288 /* Initialize handle used for association ids. */ 1291 /* Initialize handle used for association ids. */
1289 idr_init(&sctp_assocs_id); 1292 idr_init(&sctp_assocs_id);
1290 1293
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 13bf5fcdbff..54a7cd2fdd7 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -2200,8 +2200,6 @@ static int sctp_setsockopt_autoclose(struct sock *sk, char __user *optval,
2200 return -EINVAL; 2200 return -EINVAL;
2201 if (copy_from_user(&sp->autoclose, optval, optlen)) 2201 if (copy_from_user(&sp->autoclose, optval, optlen))
2202 return -EFAULT; 2202 return -EFAULT;
2203 /* make sure it won't exceed MAX_SCHEDULE_TIMEOUT */
2204 sp->autoclose = min_t(long, sp->autoclose, MAX_SCHEDULE_TIMEOUT / HZ);
2205 2203
2206 return 0; 2204 return 0;
2207} 2205}
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
index 6b3952961b8..60ffbd067ff 100644
--- a/net/sctp/sysctl.c
+++ b/net/sctp/sysctl.c
@@ -53,6 +53,10 @@ static int sack_timer_min = 1;
53static int sack_timer_max = 500; 53static int sack_timer_max = 500;
54static int addr_scope_max = 3; /* check sctp_scope_policy_t in include/net/sctp/constants.h for max entries */ 54static int addr_scope_max = 3; /* check sctp_scope_policy_t in include/net/sctp/constants.h for max entries */
55static int rwnd_scale_max = 16; 55static int rwnd_scale_max = 16;
56static unsigned long max_autoclose_min = 0;
57static unsigned long max_autoclose_max =
58 (MAX_SCHEDULE_TIMEOUT / HZ > UINT_MAX)
59 ? UINT_MAX : MAX_SCHEDULE_TIMEOUT / HZ;
56 60
57extern long sysctl_sctp_mem[3]; 61extern long sysctl_sctp_mem[3];
58extern int sysctl_sctp_rmem[3]; 62extern int sysctl_sctp_rmem[3];
@@ -258,6 +262,15 @@ static ctl_table sctp_table[] = {
258 .extra1 = &one, 262 .extra1 = &one,
259 .extra2 = &rwnd_scale_max, 263 .extra2 = &rwnd_scale_max,
260 }, 264 },
265 {
266 .procname = "max_autoclose",
267 .data = &sctp_max_autoclose,
268 .maxlen = sizeof(unsigned long),
269 .mode = 0644,
270 .proc_handler = &proc_doulongvec_minmax,
271 .extra1 = &max_autoclose_min,
272 .extra2 = &max_autoclose_max,
273 },
261 274
262 { /* sentinel */ } 275 { /* sentinel */ }
263}; 276};
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index d12ffa54581..00a1a2acd58 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -590,6 +590,27 @@ void rpc_prepare_task(struct rpc_task *task)
590 task->tk_ops->rpc_call_prepare(task, task->tk_calldata); 590 task->tk_ops->rpc_call_prepare(task, task->tk_calldata);
591} 591}
592 592
593static void
594rpc_init_task_statistics(struct rpc_task *task)
595{
596 /* Initialize retry counters */
597 task->tk_garb_retry = 2;
598 task->tk_cred_retry = 2;
599 task->tk_rebind_retry = 2;
600
601 /* starting timestamp */
602 task->tk_start = ktime_get();
603}
604
605static void
606rpc_reset_task_statistics(struct rpc_task *task)
607{
608 task->tk_timeouts = 0;
609 task->tk_flags &= ~(RPC_CALL_MAJORSEEN|RPC_TASK_KILLED|RPC_TASK_SENT);
610
611 rpc_init_task_statistics(task);
612}
613
593/* 614/*
594 * Helper that calls task->tk_ops->rpc_call_done if it exists 615 * Helper that calls task->tk_ops->rpc_call_done if it exists
595 */ 616 */
@@ -602,6 +623,7 @@ void rpc_exit_task(struct rpc_task *task)
602 WARN_ON(RPC_ASSASSINATED(task)); 623 WARN_ON(RPC_ASSASSINATED(task));
603 /* Always release the RPC slot and buffer memory */ 624 /* Always release the RPC slot and buffer memory */
604 xprt_release(task); 625 xprt_release(task);
626 rpc_reset_task_statistics(task);
605 } 627 }
606 } 628 }
607} 629}
@@ -804,11 +826,6 @@ static void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *ta
804 task->tk_calldata = task_setup_data->callback_data; 826 task->tk_calldata = task_setup_data->callback_data;
805 INIT_LIST_HEAD(&task->tk_task); 827 INIT_LIST_HEAD(&task->tk_task);
806 828
807 /* Initialize retry counters */
808 task->tk_garb_retry = 2;
809 task->tk_cred_retry = 2;
810 task->tk_rebind_retry = 2;
811
812 task->tk_priority = task_setup_data->priority - RPC_PRIORITY_LOW; 829 task->tk_priority = task_setup_data->priority - RPC_PRIORITY_LOW;
813 task->tk_owner = current->tgid; 830 task->tk_owner = current->tgid;
814 831
@@ -818,8 +835,7 @@ static void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *ta
818 if (task->tk_ops->rpc_call_prepare != NULL) 835 if (task->tk_ops->rpc_call_prepare != NULL)
819 task->tk_action = rpc_prepare_task; 836 task->tk_action = rpc_prepare_task;
820 837
821 /* starting timestamp */ 838 rpc_init_task_statistics(task);
822 task->tk_start = ktime_get();
823 839
824 dprintk("RPC: new task initialized, procpid %u\n", 840 dprintk("RPC: new task initialized, procpid %u\n",
825 task_pid_nr(current)); 841 task_pid_nr(current));
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index f4385e45a5f..c64c0ef519b 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -995,13 +995,11 @@ out_init_req:
995 995
996static void xprt_free_slot(struct rpc_xprt *xprt, struct rpc_rqst *req) 996static void xprt_free_slot(struct rpc_xprt *xprt, struct rpc_rqst *req)
997{ 997{
998 if (xprt_dynamic_free_slot(xprt, req))
999 return;
1000
1001 memset(req, 0, sizeof(*req)); /* mark unused */
1002
1003 spin_lock(&xprt->reserve_lock); 998 spin_lock(&xprt->reserve_lock);
1004 list_add(&req->rq_list, &xprt->free); 999 if (!xprt_dynamic_free_slot(xprt, req)) {
1000 memset(req, 0, sizeof(*req)); /* mark unused */
1001 list_add(&req->rq_list, &xprt->free);
1002 }
1005 rpc_wake_up_next(&xprt->backlog); 1003 rpc_wake_up_next(&xprt->backlog);
1006 spin_unlock(&xprt->reserve_lock); 1004 spin_unlock(&xprt->reserve_lock);
1007} 1005}
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 2118d644663..9049a5caeb2 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -2276,8 +2276,6 @@ static void __xfrm_garbage_collect(struct net *net)
2276{ 2276{
2277 struct dst_entry *head, *next; 2277 struct dst_entry *head, *next;
2278 2278
2279 flow_cache_flush();
2280
2281 spin_lock_bh(&xfrm_policy_sk_bundle_lock); 2279 spin_lock_bh(&xfrm_policy_sk_bundle_lock);
2282 head = xfrm_policy_sk_bundles; 2280 head = xfrm_policy_sk_bundles;
2283 xfrm_policy_sk_bundles = NULL; 2281 xfrm_policy_sk_bundles = NULL;
@@ -2290,6 +2288,18 @@ static void __xfrm_garbage_collect(struct net *net)
2290 } 2288 }
2291} 2289}
2292 2290
2291static void xfrm_garbage_collect(struct net *net)
2292{
2293 flow_cache_flush();
2294 __xfrm_garbage_collect(net);
2295}
2296
2297static void xfrm_garbage_collect_deferred(struct net *net)
2298{
2299 flow_cache_flush_deferred();
2300 __xfrm_garbage_collect(net);
2301}
2302
2293static void xfrm_init_pmtu(struct dst_entry *dst) 2303static void xfrm_init_pmtu(struct dst_entry *dst)
2294{ 2304{
2295 do { 2305 do {
@@ -2422,7 +2432,7 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
2422 if (likely(dst_ops->neigh_lookup == NULL)) 2432 if (likely(dst_ops->neigh_lookup == NULL))
2423 dst_ops->neigh_lookup = xfrm_neigh_lookup; 2433 dst_ops->neigh_lookup = xfrm_neigh_lookup;
2424 if (likely(afinfo->garbage_collect == NULL)) 2434 if (likely(afinfo->garbage_collect == NULL))
2425 afinfo->garbage_collect = __xfrm_garbage_collect; 2435 afinfo->garbage_collect = xfrm_garbage_collect_deferred;
2426 xfrm_policy_afinfo[afinfo->family] = afinfo; 2436 xfrm_policy_afinfo[afinfo->family] = afinfo;
2427 } 2437 }
2428 write_unlock_bh(&xfrm_policy_afinfo_lock); 2438 write_unlock_bh(&xfrm_policy_afinfo_lock);
@@ -2516,7 +2526,7 @@ static int xfrm_dev_event(struct notifier_block *this, unsigned long event, void
2516 2526
2517 switch (event) { 2527 switch (event) {
2518 case NETDEV_DOWN: 2528 case NETDEV_DOWN:
2519 __xfrm_garbage_collect(dev_net(dev)); 2529 xfrm_garbage_collect(dev_net(dev));
2520 } 2530 }
2521 return NOTIFY_DONE; 2531 return NOTIFY_DONE;
2522} 2532}