Skip to content

Commit

Permalink
[IPV4]: Consolidate fib_select_default.
Browse files Browse the repository at this point in the history
The difference in the implementation of the fib_select_default when
CONFIG_IP_MULTIPLE_TABLES is (not) defined looks
negligible. Consolidate it and place into fib_frontend.c.

Signed-off-by: Denis V. Lunev <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Denis V. Lunev authored and davem330 committed Jan 28, 2008
1 parent e30d3a0 commit 64c2d53
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
10 changes: 1 addition & 9 deletions include/net/ip_fib.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,6 @@ static inline int fib_lookup(struct net *net, const struct flowi *flp,
return -ENETUNREACH;
}

static inline void fib_select_default(const struct flowi *flp,
struct fib_result *res)
{
struct fib_table *table = fib_get_table(&init_net, RT_TABLE_MAIN);
if (FIB_RES_GW(*res) && FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK)
table->tb_select_default(table, flp, res);
}

#else /* CONFIG_IP_MULTIPLE_TABLES */
extern int __net_init fib4_rules_init(struct net *net);
extern void __net_exit fib4_rules_exit(struct net *net);
Expand All @@ -213,7 +205,6 @@ extern int fib_lookup(struct net *n, struct flowi *flp, struct fib_result *res);

extern struct fib_table *fib_new_table(struct net *net, u32 id);
extern struct fib_table *fib_get_table(struct net *net, u32 id);
extern void fib_select_default(const struct flowi *flp, struct fib_result *res);

#endif /* CONFIG_IP_MULTIPLE_TABLES */

Expand All @@ -222,6 +213,7 @@ extern const struct nla_policy rtm_ipv4_policy[];
extern void ip_fib_init(void);
extern int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif,
struct net_device *dev, __be32 *spec_dst, u32 *itag);
extern void fib_select_default(const struct flowi *flp, struct fib_result *res);

/* Exported by fib_semantics.c */
extern int ip_fib_check_default(__be32 gw, struct net_device *dev);
Expand Down
14 changes: 14 additions & 0 deletions net/ipv4/fib_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,20 @@ struct fib_table *fib_get_table(struct net *net, u32 id)
}
#endif /* CONFIG_IP_MULTIPLE_TABLES */

void fib_select_default(const struct flowi *flp, struct fib_result *res)
{
struct fib_table *tb;
int table = RT_TABLE_MAIN;
#ifdef CONFIG_IP_MULTIPLE_TABLES
if (res->r == NULL || res->r->action != FR_ACT_TO_TBL)
return;
table = res->r->table;
#endif
tb = fib_get_table(&init_net, table);
if (FIB_RES_GW(*res) && FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK)
tb->tb_select_default(tb, flp, res);
}

static void fib_flush(struct net *net)
{
int flushed = 0;
Expand Down
10 changes: 0 additions & 10 deletions net/ipv4/fib_rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,6 @@ static int fib4_rule_action(struct fib_rule *rule, struct flowi *flp,
}


void fib_select_default(const struct flowi *flp, struct fib_result *res)
{
if (res->r && res->r->action == FR_ACT_TO_TBL &&
FIB_RES_GW(*res) && FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK) {
struct fib_table *tb;
if ((tb = fib_get_table(&init_net, res->r->table)) != NULL)
tb->tb_select_default(tb, flp, res);
}
}

static int fib4_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
{
struct fib4_rule *r = (struct fib4_rule *) rule;
Expand Down

0 comments on commit 64c2d53

Please sign in to comment.