* [PATCH 2.6.25 2/3] ipv4: unify assignment of fi to fib_result
@ 2007-12-07 16:10 Denis V. Lunev
2007-12-08 8:31 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Denis V. Lunev @ 2007-12-07 16:10 UTC (permalink / raw)
To: davem; +Cc: containers, devel, netdev
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>
---
net/ipv4/fib_hash.c | 19 ++++---------------
net/ipv4/fib_lookup.h | 10 ++++++++++
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 76bb7fd..a52b570 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 6c9dd42..26ee66d 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 914a0d2..29a06af 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1828,10 +1828,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;
}
@@ -1844,20 +1841,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();
--
1.5.3.rc5
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-12-08 8:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-07 16:10 [PATCH 2.6.25 2/3] ipv4: unify assignment of fi to fib_result Denis V. Lunev
2007-12-08 8:31 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).