* [PATCH 2.6.24] fib_trie: apply fixes from fib_hash
@ 2008-01-26 2:40 Julian Anastasov
2008-01-26 5:18 ` Joonwoo Park
0 siblings, 1 reply; 4+ messages in thread
From: Julian Anastasov @ 2008-01-26 2:40 UTC (permalink / raw)
To: David S. Miller; +Cc: Robert Olsson, netdev, Joonwoo Park
Update fib_trie with some fib_hash fixes:
- check for duplicate alternative routes for prefix+tos+priority when
replacing route
- properly insert by matching tos together with priority
- fix alias walking to use list_for_each_entry_continue for insertion
and deletion when fa_head is not NULL
- copy state from fa to new_fa on replace (not a problem for now)
Signed-off-by: Julian Anastasov <ja@ssi.bg>
---
Not tested, someone please check the findings
--- linux-2.6.24/net/ipv4/fib_trie.c_orig 2008-01-25 10:45:06.000000000 +0200
+++ linux-2.6.24/net/ipv4/fib_trie.c 2008-01-26 03:54:33.000000000 +0200
@@ -1203,20 +1203,42 @@ static int fn_trie_insert(struct fib_tab
* and we need to allocate a new one of those as well.
*/
- if (fa && fa->fa_info->fib_priority == fi->fib_priority) {
- struct fib_alias *fa_orig;
+ if (fa && fa->fa_tos == tos &&
+ fa->fa_info->fib_priority == fi->fib_priority) {
+ struct fib_alias *fa_first, *fa_match;
err = -EEXIST;
if (cfg->fc_nlflags & NLM_F_EXCL)
goto out;
+ /* We have 2 goals:
+ * 1. Find exact match for type, scope, fib_info to avoid
+ * duplicate routes
+ * 2. Find next 'fa' (or head), NLM_F_APPEND inserts before it
+ */
+ fa_match = NULL;
+ fa_first = fa;
+ fa = list_entry(fa->fa_list.prev, struct fib_alias, fa_list);
+ list_for_each_entry_continue(fa, fa_head, fa_list) {
+ if (fa->fa_tos != tos)
+ break;
+ if (fa->fa_info->fib_priority != fi->fib_priority)
+ break;
+ if (fa->fa_type == cfg->fc_type &&
+ fa->fa_scope == cfg->fc_scope &&
+ fa->fa_info == fi) {
+ fa_match = fa;
+ break;
+ }
+ }
+
if (cfg->fc_nlflags & NLM_F_REPLACE) {
struct fib_info *fi_drop;
u8 state;
- if (fi->fib_treeref > 1)
+ fa = fa_first;
+ if (fa_match && fa != fa_match)
goto out;
-
err = -ENOBUFS;
new_fa = kmem_cache_alloc(fn_alias_kmem, GFP_KERNEL);
if (new_fa == NULL)
@@ -1228,7 +1250,7 @@ static int fn_trie_insert(struct fib_tab
new_fa->fa_type = cfg->fc_type;
new_fa->fa_scope = cfg->fc_scope;
state = fa->fa_state;
- new_fa->fa_state &= ~FA_S_ACCESSED;
+ new_fa->fa_state = state & ~FA_S_ACCESSED;
list_replace_rcu(&fa->fa_list, &new_fa->fa_list);
alias_free_mem_rcu(fa);
@@ -1245,20 +1267,11 @@ static int fn_trie_insert(struct fib_tab
* uses the same scope, type, and nexthop
* information.
*/
- fa_orig = fa;
- list_for_each_entry(fa, fa_orig->fa_list.prev, fa_list) {
- if (fa->fa_tos != tos)
- break;
- if (fa->fa_info->fib_priority != fi->fib_priority)
- break;
- if (fa->fa_type == cfg->fc_type &&
- fa->fa_scope == cfg->fc_scope &&
- fa->fa_info == fi) {
- goto out;
- }
- }
+ if (fa_match)
+ goto out;
+
if (!(cfg->fc_nlflags & NLM_F_APPEND))
- fa = fa_orig;
+ fa = fa_first;
}
err = -ENOENT;
if (!(cfg->fc_nlflags & NLM_F_CREATE))
@@ -1614,9 +1627,8 @@ static int fn_trie_delete(struct fib_tab
pr_debug("Deleting %08x/%d tos=%d t=%p\n", key, plen, tos, t);
fa_to_delete = NULL;
- fa_head = fa->fa_list.prev;
-
- list_for_each_entry(fa, fa_head, fa_list) {
+ fa = list_entry(fa->fa_list.prev, struct fib_alias, fa_list);
+ list_for_each_entry_continue(fa, fa_head, fa_list) {
struct fib_info *fi = fa->fa_info;
if (fa->fa_tos != tos)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2.6.24] fib_trie: apply fixes from fib_hash
2008-01-26 2:40 [PATCH 2.6.24] fib_trie: apply fixes from fib_hash Julian Anastasov
@ 2008-01-26 5:18 ` Joonwoo Park
2008-01-26 5:20 ` Joonwoo Park
0 siblings, 1 reply; 4+ messages in thread
From: Joonwoo Park @ 2008-01-26 5:18 UTC (permalink / raw)
To: Julian Anastasov
Cc: David S. Miller, Robert Olsson, netdev, Joonwoo Park,
Andrew Morton, Jarek Poplawski, schwab
On Sat, Jan 26, 2008 at 04:40:30AM +0200, Julian Anastasov wrote:
>
> Signed-off-by: Julian Anastasov <ja@ssi.bg>
> ---
>
> Not tested, someone please check the findings
>
> --- linux-2.6.24/net/ipv4/fib_trie.c_orig 2008-01-25 10:45:06.000000000 +0200
> +
> if (cfg->fc_nlflags & NLM_F_REPLACE) {
> struct fib_info *fi_drop;
> u8 state;
>
> - if (fi->fib_treeref > 1)
> + fa = fa_first;
> + if (fa_match && fa != fa_match)
> goto out;
> -
Isn't it possible to do this (fib_hash too)?
if (fa_match) {
if (fa != fa_match)
return 0;
goto out;
}
Thanks,
Joonwoo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2.6.24] fib_trie: apply fixes from fib_hash
2008-01-26 5:18 ` Joonwoo Park
@ 2008-01-26 5:20 ` Joonwoo Park
2008-01-26 9:46 ` Julian Anastasov
0 siblings, 1 reply; 4+ messages in thread
From: Joonwoo Park @ 2008-01-26 5:20 UTC (permalink / raw)
To: Julian Anastasov
Cc: David S. Miller, Robert Olsson, netdev, Joonwoo Park,
Andrew Morton, Jarek Poplawski, schwab
2008/1/26, Joonwoo Park <joonwpark81@gmail.com>:
> On Sat, Jan 26, 2008 at 04:40:30AM +0200, Julian Anastasov wrote:
> >
> > Signed-off-by: Julian Anastasov <ja@ssi.bg>
> > ---
> >
> > Not tested, someone please check the findings
> >
> > --- linux-2.6.24/net/ipv4/fib_trie.c_orig 2008-01-25 10:45:06.000000000 +0200
> > +
> > if (cfg->fc_nlflags & NLM_F_REPLACE) {
> > struct fib_info *fi_drop;
> > u8 state;
> >
> > - if (fi->fib_treeref > 1)
> > + fa = fa_first;
> > + if (fa_match && fa != fa_match)
> > goto out;
> > -
>
> Isn't it possible to do this (fib_hash too)?
> if (fa_match) {
> if (fa != fa_match)
Sorry!
if (fa == fa_match)
> return 0;
> goto out;
> }
>
> Thanks,
> Joonwoo
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2.6.24] fib_trie: apply fixes from fib_hash
2008-01-26 5:20 ` Joonwoo Park
@ 2008-01-26 9:46 ` Julian Anastasov
0 siblings, 0 replies; 4+ messages in thread
From: Julian Anastasov @ 2008-01-26 9:46 UTC (permalink / raw)
To: Joonwoo Park
Cc: David S. Miller, Robert Olsson, netdev, Andrew Morton,
Jarek Poplawski, schwab
Hello,
On Sat, 26 Jan 2008, Joonwoo Park wrote:
> > > Not tested, someone please check the findings
news: simple testing of patched fib_trie seems to work
> > > - if (fi->fib_treeref > 1)
> > > + fa = fa_first;
> > > + if (fa_match && fa != fa_match)
> > > goto out;
> > > -
> >
> > Isn't it possible to do this (fib_hash too)?
> > if (fa_match) {
> > if (fa != fa_match)
> Sorry!
> if (fa == fa_match)
> > return 0;
> > goto out;
> > }
I see, your idea is to optimize the case when matched
parameters are same. Considering the used fi is same I don't see
any problems. I'll prepare 2nd version of both patches in
next hours.
Regards
--
Julian Anastasov <ja@ssi.bg>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-01-26 9:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-26 2:40 [PATCH 2.6.24] fib_trie: apply fixes from fib_hash Julian Anastasov
2008-01-26 5:18 ` Joonwoo Park
2008-01-26 5:20 ` Joonwoo Park
2008-01-26 9:46 ` Julian Anastasov
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).