Commit a2bbe682 authored by Denis V. Lunev's avatar Denis V. Lunev Committed by David S. Miller

[IPV4]: Unify assignment of fi to fib_result

Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Acked-by: default avatarAlexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c17860a0
...@@ -315,10 +315,7 @@ fn_hash_select_default(struct fib_table *tb, const struct flowi *flp, struct fib ...@@ -315,10 +315,7 @@ fn_hash_select_default(struct fib_table *tb, const struct flowi *flp, struct fib
break; break;
} else if (!fib_detect_death(fi, order, &last_resort, } else if (!fib_detect_death(fi, order, &last_resort,
&last_idx, fn_hash_last_dflt)) { &last_idx, fn_hash_last_dflt)) {
if (res->fi) fib_result_assign(res, fi);
fib_info_put(res->fi);
res->fi = fi;
atomic_inc(&fi->fib_clntref);
fn_hash_last_dflt = order; fn_hash_last_dflt = order;
goto out; goto out;
} }
...@@ -333,21 +330,13 @@ fn_hash_select_default(struct fib_table *tb, const struct flowi *flp, struct fib ...@@ -333,21 +330,13 @@ fn_hash_select_default(struct fib_table *tb, const struct flowi *flp, struct fib
} }
if (!fib_detect_death(fi, order, &last_resort, &last_idx, fn_hash_last_dflt)) { if (!fib_detect_death(fi, order, &last_resort, &last_idx, fn_hash_last_dflt)) {
if (res->fi) fib_result_assign(res, fi);
fib_info_put(res->fi);
res->fi = fi;
atomic_inc(&fi->fib_clntref);
fn_hash_last_dflt = order; fn_hash_last_dflt = order;
goto out; goto out;
} }
if (last_idx >= 0) { if (last_idx >= 0)
if (res->fi) fib_result_assign(res, last_resort);
fib_info_put(res->fi);
res->fi = last_resort;
if (last_resort)
atomic_inc(&last_resort->fib_clntref);
}
fn_hash_last_dflt = last_idx; fn_hash_last_dflt = last_idx;
out: out:
read_unlock(&fib_hash_lock); read_unlock(&fib_hash_lock);
......
...@@ -38,4 +38,14 @@ extern int fib_detect_death(struct fib_info *fi, int order, ...@@ -38,4 +38,14 @@ extern int fib_detect_death(struct fib_info *fi, int order,
struct fib_info **last_resort, struct fib_info **last_resort,
int *last_idx, int dflt); int *last_idx, int dflt);
static inline void fib_result_assign(struct fib_result *res,
struct fib_info *fi)
{
if (res->fi != NULL)
fib_info_put(res->fi);
res->fi = fi;
if (fi != NULL)
atomic_inc(&fi->fib_clntref);
}
#endif /* _FIB_LOOKUP_H */ #endif /* _FIB_LOOKUP_H */
...@@ -1831,10 +1831,7 @@ fn_trie_select_default(struct fib_table *tb, const struct flowi *flp, struct fib ...@@ -1831,10 +1831,7 @@ fn_trie_select_default(struct fib_table *tb, const struct flowi *flp, struct fib
break; break;
} else if (!fib_detect_death(fi, order, &last_resort, } else if (!fib_detect_death(fi, order, &last_resort,
&last_idx, trie_last_dflt)) { &last_idx, trie_last_dflt)) {
if (res->fi) fib_result_assign(res, fi);
fib_info_put(res->fi);
res->fi = fi;
atomic_inc(&fi->fib_clntref);
trie_last_dflt = order; trie_last_dflt = order;
goto out; goto out;
} }
...@@ -1847,20 +1844,12 @@ fn_trie_select_default(struct fib_table *tb, const struct flowi *flp, struct fib ...@@ -1847,20 +1844,12 @@ fn_trie_select_default(struct fib_table *tb, const struct flowi *flp, struct fib
} }
if (!fib_detect_death(fi, order, &last_resort, &last_idx, trie_last_dflt)) { if (!fib_detect_death(fi, order, &last_resort, &last_idx, trie_last_dflt)) {
if (res->fi) fib_result_assign(res, fi);
fib_info_put(res->fi);
res->fi = fi;
atomic_inc(&fi->fib_clntref);
trie_last_dflt = order; trie_last_dflt = order;
goto out; goto out;
} }
if (last_idx >= 0) { if (last_idx >= 0)
if (res->fi) fib_result_assign(res, last_resort);
fib_info_put(res->fi);
res->fi = last_resort;
if (last_resort)
atomic_inc(&last_resort->fib_clntref);
}
trie_last_dflt = last_idx; trie_last_dflt = last_idx;
out:; out:;
rcu_read_unlock(); rcu_read_unlock();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment