Commit 55e05b9f authored by Robert Olsson's avatar Robert Olsson Committed by David S. Miller

[IPV4]: FIB cleanup, fib_find_alias()

Abstract out fib_node arg usage in fib_find_alias(),
move to fib_semantics.c
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 48b9b27a
......@@ -399,26 +399,6 @@ static struct fib_node *fib_find_node(struct fn_zone *fz, u32 key)
return NULL;
}
/* Return the first fib alias matching TOS with
* priority less than or equal to PRIO.
*/
static struct fib_alias *fib_find_alias(struct fib_node *fn, u8 tos, u32 prio)
{
if (fn) {
struct list_head *head = &fn->fn_alias;
struct fib_alias *fa;
list_for_each_entry(fa, head, fa_list) {
if (fa->fa_tos > tos)
continue;
if (fa->fa_info->fib_priority >= prio ||
fa->fa_tos < tos)
return fa;
}
}
return NULL;
}
static int
fn_hash_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
struct nlmsghdr *n, struct netlink_skb_parms *req)
......@@ -458,7 +438,11 @@ fn_hash_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
fn_rehash_zone(fz);
f = fib_find_node(fz, key);
fa = fib_find_alias(f, tos, fi->fib_priority);
if (!f)
fa = NULL;
else
fa = fib_find_alias(&f->fn_alias, tos, fi->fib_priority);
/* Now fa, if non-NULL, points to the first fib alias
* with the same keys [prefix,tos,priority], if such key already
......@@ -598,7 +582,11 @@ fn_hash_delete(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
}
f = fib_find_node(fz, key);
fa = fib_find_alias(f, tos, 0);
if (!f)
fa = NULL;
else
fa = fib_find_alias(&f->fn_alias, tos, 0);
if (!fa)
return -ESRCH;
......
......@@ -33,5 +33,7 @@ extern int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
extern void rtmsg_fib(int event, u32 key, struct fib_alias *fa,
int z, int tb_id,
struct nlmsghdr *n, struct netlink_skb_parms *req);
extern struct fib_alias *fib_find_alias(struct list_head *fah,
u8 tos, u32 prio);
#endif /* _FIB_LOOKUP_H */
......@@ -297,6 +297,24 @@ void rtmsg_fib(int event, u32 key, struct fib_alias *fa,
netlink_unicast(rtnl, skb, pid, MSG_DONTWAIT);
}
/* Return the first fib alias matching TOS with
* priority less than or equal to PRIO.
*/
struct fib_alias *fib_find_alias(struct list_head *fah, u8 tos, u32 prio)
{
if (fah) {
struct fib_alias *fa;
list_for_each_entry(fa, fah, fa_list) {
if (fa->fa_tos > tos)
continue;
if (fa->fa_info->fib_priority >= prio ||
fa->fa_tos < tos)
return fa;
}
}
return NULL;
}
#ifdef CONFIG_IP_ROUTE_MULTIPATH
static u32 fib_get_attr32(struct rtattr *attr, int attrlen, int type)
......
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