add chaos_calmer branch
[15.05/openwrt.git] / target / linux / generic / patches-3.18 / 080-21-fib_trie-Fall-back-to-slen-update-on-inflate-halve-f.patch
1 From: Alexander Duyck <alexander.h.duyck@redhat.com>
2 Date: Thu, 22 Jan 2015 15:51:20 -0800
3 Subject: [PATCH] fib_trie: Fall back to slen update on inflate/halve failure
4
5 This change corrects an issue where if inflate or halve fails we were
6 exiting the resize function without at least updating the slen for the
7 node.  To correct this I have moved the update of max_size into the while
8 loop so that it is only decremented on a successful call to either inflate
9 or halve.
10
11 Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
12 Signed-off-by: David S. Miller <davem@davemloft.net>
13 ---
14
15 --- a/net/ipv4/fib_trie.c
16 +++ b/net/ipv4/fib_trie.c
17 @@ -752,7 +752,7 @@ static void resize(struct trie *t, struc
18  {
19         struct tnode *tp = node_parent(tn), *n = NULL;
20         struct tnode __rcu **cptr;
21 -       int max_work;
22 +       int max_work = MAX_WORK;
23  
24         pr_debug("In tnode_resize %p inflate_threshold=%d threshold=%d\n",
25                  tn, inflate_threshold, halve_threshold);
26 @@ -775,8 +775,7 @@ static void resize(struct trie *t, struc
27         /* Double as long as the resulting node has a number of
28          * nonempty nodes that are above the threshold.
29          */
30 -       max_work = MAX_WORK;
31 -       while (should_inflate(tp, tn) && max_work--) {
32 +       while (should_inflate(tp, tn) && max_work) {
33                 if (inflate(t, tn)) {
34  #ifdef CONFIG_IP_FIB_TRIE_STATS
35                         this_cpu_inc(t->stats->resize_node_skipped);
36 @@ -784,6 +783,7 @@ static void resize(struct trie *t, struc
37                         break;
38                 }
39  
40 +               max_work--;
41                 tn = rtnl_dereference(*cptr);
42         }
43  
44 @@ -794,8 +794,7 @@ static void resize(struct trie *t, struc
45         /* Halve as long as the number of empty children in this
46          * node is above threshold.
47          */
48 -       max_work = MAX_WORK;
49 -       while (should_halve(tp, tn) && max_work--) {
50 +       while (should_halve(tp, tn) && max_work) {
51                 if (halve(t, tn)) {
52  #ifdef CONFIG_IP_FIB_TRIE_STATS
53                         this_cpu_inc(t->stats->resize_node_skipped);
54 @@ -803,6 +802,7 @@ static void resize(struct trie *t, struc
55                         break;
56                 }
57  
58 +               max_work--;
59                 tn = rtnl_dereference(*cptr);
60         }
61