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

[IPV4]: FIB cleanup, fib_detect_death()

Remove dependancy upon fib_hash specific
fn_hash_select_dflt and move it over to
fib_semantics.c
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 55e05b9f
......@@ -274,29 +274,6 @@ fn_hash_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result
static int fn_hash_last_dflt=-1;
static int fib_detect_death(struct fib_info *fi, int order,
struct fib_info **last_resort, int *last_idx)
{
struct neighbour *n;
int state = NUD_NONE;
n = neigh_lookup(&arp_tbl, &fi->fib_nh[0].nh_gw, fi->fib_dev);
if (n) {
state = n->nud_state;
neigh_release(n);
}
if (state==NUD_REACHABLE)
return 0;
if ((state&NUD_VALID) && order != fn_hash_last_dflt)
return 0;
if ((state&NUD_VALID) ||
(*last_idx<0 && order > fn_hash_last_dflt)) {
*last_resort = fi;
*last_idx = order;
}
return 1;
}
static void
fn_hash_select_default(struct fib_table *tb, const struct flowi *flp, struct fib_result *res)
{
......@@ -337,7 +314,7 @@ fn_hash_select_default(struct fib_table *tb, const struct flowi *flp, struct fib
if (next_fi != res->fi)
break;
} else if (!fib_detect_death(fi, order, &last_resort,
&last_idx)) {
&last_idx, &fn_hash_last_dflt)) {
if (res->fi)
fib_info_put(res->fi);
res->fi = fi;
......@@ -355,7 +332,7 @@ fn_hash_select_default(struct fib_table *tb, const struct flowi *flp, struct fib
goto out;
}
if (!fib_detect_death(fi, order, &last_resort, &last_idx)) {
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;
......
......@@ -35,5 +35,8 @@ extern void rtmsg_fib(int event, u32 key, struct fib_alias *fa,
struct nlmsghdr *n, struct netlink_skb_parms *req);
extern struct fib_alias *fib_find_alias(struct list_head *fah,
u8 tos, u32 prio);
extern int fib_detect_death(struct fib_info *fi, int order,
struct fib_info **last_resort,
int *last_idx, int *dflt);
#endif /* _FIB_LOOKUP_H */
......@@ -315,6 +315,29 @@ struct fib_alias *fib_find_alias(struct list_head *fah, u8 tos, u32 prio)
return NULL;
}
int fib_detect_death(struct fib_info *fi, int order,
struct fib_info **last_resort, int *last_idx, int *dflt)
{
struct neighbour *n;
int state = NUD_NONE;
n = neigh_lookup(&arp_tbl, &fi->fib_nh[0].nh_gw, fi->fib_dev);
if (n) {
state = n->nud_state;
neigh_release(n);
}
if (state==NUD_REACHABLE)
return 0;
if ((state&NUD_VALID) && order != *dflt)
return 0;
if ((state&NUD_VALID) ||
(*last_idx<0 && order > *dflt)) {
*last_resort = fi;
*last_idx = order;
}
return 1;
}
#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