Merge 4.4.109 into android-4.4
[GitHub/exynos8895/android_kernel_samsung_universal8895.git] / net / ipv4 / fib_frontend.c
index ee94bd32d6dc5180176160611b78364563b311a2..7dc9f0680bf6cf8c8bf8f34df1c37f356a9314be 100644 (file)
@@ -1253,7 +1253,7 @@ fail:
 
 static void ip_fib_net_exit(struct net *net)
 {
-       unsigned int i;
+       int i;
 
        rtnl_lock();
 #ifdef CONFIG_IP_MULTIPLE_TABLES
@@ -1261,7 +1261,12 @@ static void ip_fib_net_exit(struct net *net)
        RCU_INIT_POINTER(net->ipv4.fib_main, NULL);
        RCU_INIT_POINTER(net->ipv4.fib_default, NULL);
 #endif
-       for (i = 0; i < FIB_TABLE_HASHSZ; i++) {
+       /* Destroy the tables in reverse order to guarantee that the
+        * local table, ID 255, is destroyed before the main table, ID
+        * 254. This is necessary as the local table may contain
+        * references to data contained in the main table.
+        */
+       for (i = FIB_TABLE_HASHSZ - 1; i >= 0; i--) {
                struct hlist_head *head = &net->ipv4.fib_table_hash[i];
                struct hlist_node *tmp;
                struct fib_table *tb;