diff options
author | Denis V. Lunev <den@openvz.org> | 2007-12-08 11:31:44 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-29 01:57:01 +0300 |
commit | a2bbe6822f8928e254452765c07cb863633113b8 (patch) | |
tree | 59e932a509a6acdaf0c988f4d6ac24bb780d2f5f /net/ipv4 | |
parent | c17860a039bbde134324ad6f9331500635f5799d (diff) | |
download | linux-a2bbe6822f8928e254452765c07cb863633113b8.tar.xz |
[IPV4]: Unify assignment of fi to fib_result
Signed-off-by: Denis V. Lunev <den@openvz.org>
Acked-by: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/fib_hash.c | 19 | ||||
-rw-r--r-- | net/ipv4/fib_lookup.h | 10 | ||||
-rw-r--r-- | net/ipv4/fib_trie.c | 19 |
3 files changed, 18 insertions, 30 deletions
diff --git a/net/ipv4/fib_hash.c b/net/ipv4/fib_hash.c index 143a5213a185..86087d45c64e 100644 --- a/net/ipv4/fib_hash.c +++ b/net/ipv4/fib_hash.c @@ -315,10 +315,7 @@ fn_hash_select_default(struct fib_table *tb, const struct flowi *flp, struct fib break; } else if (!fib_detect_death(fi, order, &last_resort, &last_idx, fn_hash_last_dflt)) { - if (res->fi) - fib_info_put(res->fi); - res->fi = fi; - atomic_inc(&fi->fib_clntref); + fib_result_assign(res, fi); fn_hash_last_dflt = order; goto out; } @@ -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 (res->fi) - fib_info_put(res->fi); - res->fi = fi; - atomic_inc(&fi->fib_clntref); + fib_result_assign(res, fi); fn_hash_last_dflt = order; goto out; } - if (last_idx >= 0) { - if (res->fi) - fib_info_put(res->fi); - res->fi = last_resort; - if (last_resort) - atomic_inc(&last_resort->fib_clntref); - } + if (last_idx >= 0) + fib_result_assign(res, last_resort); fn_hash_last_dflt = last_idx; out: read_unlock(&fib_hash_lock); diff --git a/net/ipv4/fib_lookup.h b/net/ipv4/fib_lookup.h index 6c9dd4282db0..26ee66d78c18 100644 --- a/net/ipv4/fib_lookup.h +++ b/net/ipv4/fib_lookup.h @@ -38,4 +38,14 @@ extern int fib_detect_death(struct fib_info *fi, int order, struct fib_info **last_resort, 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 */ diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index d48a9bbcf54d..c7c5c6c802df 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c @@ -1831,10 +1831,7 @@ fn_trie_select_default(struct fib_table *tb, const struct flowi *flp, struct fib break; } else if (!fib_detect_death(fi, order, &last_resort, &last_idx, trie_last_dflt)) { - if (res->fi) - fib_info_put(res->fi); - res->fi = fi; - atomic_inc(&fi->fib_clntref); + fib_result_assign(res, fi); trie_last_dflt = order; goto out; } @@ -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 (res->fi) - fib_info_put(res->fi); - res->fi = fi; - atomic_inc(&fi->fib_clntref); + fib_result_assign(res, fi); trie_last_dflt = order; goto out; } - if (last_idx >= 0) { - if (res->fi) - fib_info_put(res->fi); - res->fi = last_resort; - if (last_resort) - atomic_inc(&last_resort->fib_clntref); - } + if (last_idx >= 0) + fib_result_assign(res, last_resort); trie_last_dflt = last_idx; out:; rcu_read_unlock(); |