Re: [RFC PATCH 01/29] fib_trie: Convert fib_alias to hlist from list

Julian Anastasov
2015-02-24T23:09:40Z

Hello,

On Tue, 24 Feb 2015, Alexander Duyck wrote:

> diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
> index 3daf022..e0d44b7 100644
> --- a/net/ipv4/fib_trie.c
> +++ b/net/ipv4/fib_trie.c

> @@ -1192,8 +1193,7 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg)
> */
> 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) {
> + hlist_for_each_entry_from(fa, fa_list) {
> if (fa->fa_tos != tos)
> break;
> if (fa->fa_info->fib_priority != fi->fib_priority)

Also, as this loop when implemented as hlist
can exit with fa = NULL we have to use fa_last = fa at
end of loop:

hlist_for_each_entry_from(fa, 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_info == fi) {
fa_match = fa;
break;
}
+ fa_last = fa;
}

It is needed so that NLM_F_APPEND can work.
Basicly, if list_for_* end with pos pointing to head,
hlist_for_* end with NULL.

Regards

--
Julian Anastasov <ja@ssi.bg>