Commit 22bd5b9b authored by David S. Miller's avatar David S. Miller

ipv4: Pass ipv4 flow objects into fib_lookup() paths.

To start doing these conversions, we need to add some temporary
flow4_* macros which will eventually go away when all the protocol
code paths are changed to work on AF specific flowi objects.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 59b1a94c
...@@ -50,6 +50,14 @@ union flowi_uli { ...@@ -50,6 +50,14 @@ union flowi_uli {
struct flowi4 { struct flowi4 {
struct flowi_common __fl_common; struct flowi_common __fl_common;
#define flowi4_oif __fl_common.flowic_oif
#define flowi4_iif __fl_common.flowic_iif
#define flowi4_mark __fl_common.flowic_mark
#define flowi4_tos __fl_common.flowic_tos
#define flowi4_scope __fl_common.flowic_scope
#define flowi4_proto __fl_common.flowic_proto
#define flowi4_flags __fl_common.flowic_flags
#define flowi4_secid __fl_common.flowic_secid
__be32 daddr; __be32 daddr;
__be32 saddr; __be32 saddr;
union flowi_uli uli; union flowi_uli uli;
......
...@@ -155,7 +155,7 @@ struct fib_table { ...@@ -155,7 +155,7 @@ struct fib_table {
unsigned char tb_data[0]; unsigned char tb_data[0];
}; };
extern int fib_table_lookup(struct fib_table *tb, const struct flowi *flp, extern int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp,
struct fib_result *res, int fib_flags); struct fib_result *res, int fib_flags);
extern int fib_table_insert(struct fib_table *, struct fib_config *); extern int fib_table_insert(struct fib_table *, struct fib_config *);
extern int fib_table_delete(struct fib_table *, struct fib_config *); extern int fib_table_delete(struct fib_table *, struct fib_config *);
...@@ -186,7 +186,7 @@ static inline struct fib_table *fib_new_table(struct net *net, u32 id) ...@@ -186,7 +186,7 @@ static inline struct fib_table *fib_new_table(struct net *net, u32 id)
return fib_get_table(net, id); return fib_get_table(net, id);
} }
static inline int fib_lookup(struct net *net, const struct flowi *flp, static inline int fib_lookup(struct net *net, const struct flowi4 *flp,
struct fib_result *res) struct fib_result *res)
{ {
struct fib_table *table; struct fib_table *table;
...@@ -209,7 +209,7 @@ extern void __net_exit fib4_rules_exit(struct net *net); ...@@ -209,7 +209,7 @@ extern void __net_exit fib4_rules_exit(struct net *net);
extern u32 fib_rules_tclass(const struct fib_result *res); extern u32 fib_rules_tclass(const struct fib_result *res);
#endif #endif
extern int fib_lookup(struct net *n, struct flowi *flp, struct fib_result *res); extern int fib_lookup(struct net *n, struct flowi4 *flp, struct fib_result *res);
extern struct fib_table *fib_new_table(struct net *net, u32 id); 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 struct fib_table *fib_get_table(struct net *net, u32 id);
......
...@@ -158,7 +158,7 @@ static inline unsigned __inet_dev_addr_type(struct net *net, ...@@ -158,7 +158,7 @@ static inline unsigned __inet_dev_addr_type(struct net *net,
if (local_table) { if (local_table) {
ret = RTN_UNICAST; ret = RTN_UNICAST;
rcu_read_lock(); rcu_read_lock();
if (!fib_table_lookup(local_table, &fl, &res, FIB_LOOKUP_NOREF)) { if (!fib_table_lookup(local_table, &fl.u.ip4, &res, FIB_LOOKUP_NOREF)) {
if (!dev || dev == res.fi->fib_dev) if (!dev || dev == res.fi->fib_dev)
ret = res.type; ret = res.type;
} }
...@@ -222,7 +222,7 @@ int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif, ...@@ -222,7 +222,7 @@ int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif,
goto e_inval; goto e_inval;
net = dev_net(dev); net = dev_net(dev);
if (fib_lookup(net, &fl, &res)) if (fib_lookup(net, &fl.u.ip4, &res))
goto last_resort; goto last_resort;
if (res.type != RTN_UNICAST) { if (res.type != RTN_UNICAST) {
if (res.type != RTN_LOCAL || !accept_local) if (res.type != RTN_LOCAL || !accept_local)
...@@ -256,7 +256,7 @@ int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif, ...@@ -256,7 +256,7 @@ int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif,
fl.flowi_oif = dev->ifindex; fl.flowi_oif = dev->ifindex;
ret = 0; ret = 0;
if (fib_lookup(net, &fl, &res) == 0) { if (fib_lookup(net, &fl.u.ip4, &res) == 0) {
if (res.type == RTN_UNICAST) { if (res.type == RTN_UNICAST) {
*spec_dst = FIB_RES_PREFSRC(res); *spec_dst = FIB_RES_PREFSRC(res);
ret = FIB_RES_NH(res).nh_scope >= RT_SCOPE_HOST; ret = FIB_RES_NH(res).nh_scope >= RT_SCOPE_HOST;
...@@ -813,7 +813,7 @@ static void nl_fib_lookup(struct fib_result_nl *frn, struct fib_table *tb) ...@@ -813,7 +813,7 @@ static void nl_fib_lookup(struct fib_result_nl *frn, struct fib_table *tb)
frn->tb_id = tb->tb_id; frn->tb_id = tb->tb_id;
rcu_read_lock(); rcu_read_lock();
frn->err = fib_table_lookup(tb, &fl, &res, FIB_LOOKUP_NOREF); frn->err = fib_table_lookup(tb, &fl.u.ip4, &res, FIB_LOOKUP_NOREF);
if (!frn->err) { if (!frn->err) {
frn->prefixlen = res.prefixlen; frn->prefixlen = res.prefixlen;
......
...@@ -53,7 +53,7 @@ u32 fib_rules_tclass(const struct fib_result *res) ...@@ -53,7 +53,7 @@ u32 fib_rules_tclass(const struct fib_result *res)
} }
#endif #endif
int fib_lookup(struct net *net, struct flowi *flp, struct fib_result *res) int fib_lookup(struct net *net, struct flowi4 *flp, struct fib_result *res)
{ {
struct fib_lookup_arg arg = { struct fib_lookup_arg arg = {
.result = res, .result = res,
...@@ -61,7 +61,7 @@ int fib_lookup(struct net *net, struct flowi *flp, struct fib_result *res) ...@@ -61,7 +61,7 @@ int fib_lookup(struct net *net, struct flowi *flp, struct fib_result *res)
}; };
int err; int err;
err = fib_rules_lookup(net->ipv4.rules_ops, flp, 0, &arg); err = fib_rules_lookup(net->ipv4.rules_ops, flowi4_to_flowi(flp), 0, &arg);
res->r = arg.rule; res->r = arg.rule;
return err; return err;
...@@ -95,7 +95,7 @@ static int fib4_rule_action(struct fib_rule *rule, struct flowi *flp, ...@@ -95,7 +95,7 @@ static int fib4_rule_action(struct fib_rule *rule, struct flowi *flp,
if (!tbl) if (!tbl)
goto errout; goto errout;
err = fib_table_lookup(tbl, flp, (struct fib_result *) arg->result, arg->flags); err = fib_table_lookup(tbl, &flp->u.ip4, (struct fib_result *) arg->result, arg->flags);
if (err > 0) if (err > 0)
err = -EAGAIN; err = -EAGAIN;
errout: errout:
......
...@@ -569,7 +569,7 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi, ...@@ -569,7 +569,7 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi,
/* It is not necessary, but requires a bit of thinking */ /* It is not necessary, but requires a bit of thinking */
if (fl.fl4_scope < RT_SCOPE_LINK) if (fl.fl4_scope < RT_SCOPE_LINK)
fl.fl4_scope = RT_SCOPE_LINK; fl.fl4_scope = RT_SCOPE_LINK;
err = fib_lookup(net, &fl, &res); err = fib_lookup(net, &fl.u.ip4, &res);
if (err) { if (err) {
rcu_read_unlock(); rcu_read_unlock();
return err; return err;
......
...@@ -1341,7 +1341,7 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg) ...@@ -1341,7 +1341,7 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg)
/* should be called with rcu_read_lock */ /* should be called with rcu_read_lock */
static int check_leaf(struct fib_table *tb, struct trie *t, struct leaf *l, static int check_leaf(struct fib_table *tb, struct trie *t, struct leaf *l,
t_key key, const struct flowi *flp, t_key key, const struct flowi4 *flp,
struct fib_result *res, int fib_flags) struct fib_result *res, int fib_flags)
{ {
struct leaf_info *li; struct leaf_info *li;
...@@ -1360,9 +1360,9 @@ static int check_leaf(struct fib_table *tb, struct trie *t, struct leaf *l, ...@@ -1360,9 +1360,9 @@ static int check_leaf(struct fib_table *tb, struct trie *t, struct leaf *l,
struct fib_info *fi = fa->fa_info; struct fib_info *fi = fa->fa_info;
int nhsel, err; int nhsel, err;
if (fa->fa_tos && fa->fa_tos != flp->fl4_tos) if (fa->fa_tos && fa->fa_tos != flp->flowi4_tos)
continue; continue;
if (fa->fa_scope < flp->fl4_scope) if (fa->fa_scope < flp->flowi4_scope)
continue; continue;
fib_alias_accessed(fa); fib_alias_accessed(fa);
err = fib_props[fa->fa_type].error; err = fib_props[fa->fa_type].error;
...@@ -1379,7 +1379,7 @@ static int check_leaf(struct fib_table *tb, struct trie *t, struct leaf *l, ...@@ -1379,7 +1379,7 @@ static int check_leaf(struct fib_table *tb, struct trie *t, struct leaf *l,
if (nh->nh_flags & RTNH_F_DEAD) if (nh->nh_flags & RTNH_F_DEAD)
continue; continue;
if (flp->flowi_oif && flp->flowi_oif != nh->nh_oif) if (flp->flowi4_oif && flp->flowi4_oif != nh->nh_oif)
continue; continue;
#ifdef CONFIG_IP_FIB_TRIE_STATS #ifdef CONFIG_IP_FIB_TRIE_STATS
...@@ -1406,7 +1406,7 @@ static int check_leaf(struct fib_table *tb, struct trie *t, struct leaf *l, ...@@ -1406,7 +1406,7 @@ static int check_leaf(struct fib_table *tb, struct trie *t, struct leaf *l,
return 1; return 1;
} }
int fib_table_lookup(struct fib_table *tb, const struct flowi *flp, int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp,
struct fib_result *res, int fib_flags) struct fib_result *res, int fib_flags)
{ {
struct trie *t = (struct trie *) tb->tb_data; struct trie *t = (struct trie *) tb->tb_data;
...@@ -1414,7 +1414,7 @@ int fib_table_lookup(struct fib_table *tb, const struct flowi *flp, ...@@ -1414,7 +1414,7 @@ int fib_table_lookup(struct fib_table *tb, const struct flowi *flp,
struct rt_trie_node *n; struct rt_trie_node *n;
struct tnode *pn; struct tnode *pn;
unsigned int pos, bits; unsigned int pos, bits;
t_key key = ntohl(flp->fl4_dst); t_key key = ntohl(flp->daddr);
unsigned int chopped_off; unsigned int chopped_off;
t_key cindex = 0; t_key cindex = 0;
unsigned int current_prefix_length = KEYLENGTH; unsigned int current_prefix_length = KEYLENGTH;
......
...@@ -1707,7 +1707,7 @@ void ip_rt_get_source(u8 *addr, struct rtable *rt) ...@@ -1707,7 +1707,7 @@ void ip_rt_get_source(u8 *addr, struct rtable *rt)
}; };
rcu_read_lock(); rcu_read_lock();
if (fib_lookup(dev_net(rt->dst.dev), &fl, &res) == 0) if (fib_lookup(dev_net(rt->dst.dev), &fl.u.ip4, &res) == 0)
src = FIB_RES_PREFSRC(res); src = FIB_RES_PREFSRC(res);
else else
src = inet_select_addr(rt->dst.dev, rt->rt_gateway, src = inet_select_addr(rt->dst.dev, rt->rt_gateway,
...@@ -2125,7 +2125,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr, ...@@ -2125,7 +2125,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
fl.fl4_src = saddr; fl.fl4_src = saddr;
fl.fl4_tos = tos; fl.fl4_tos = tos;
fl.fl4_scope = RT_SCOPE_UNIVERSE; fl.fl4_scope = RT_SCOPE_UNIVERSE;
err = fib_lookup(net, &fl, &res); err = fib_lookup(net, &fl.u.ip4, &res);
if (err != 0) { if (err != 0) {
if (!IN_DEV_FORWARD(in_dev)) if (!IN_DEV_FORWARD(in_dev))
goto e_hostunreach; goto e_hostunreach;
...@@ -2551,7 +2551,7 @@ static struct rtable *ip_route_output_slow(struct net *net, ...@@ -2551,7 +2551,7 @@ static struct rtable *ip_route_output_slow(struct net *net,
goto make_route; goto make_route;
} }
if (fib_lookup(net, &fl, &res)) { if (fib_lookup(net, &fl.u.ip4, &res)) {
res.fi = NULL; res.fi = NULL;
if (oldflp->flowi_oif) { if (oldflp->flowi_oif) {
/* Apparently, routing tables are wrong. Assume, /* Apparently, routing tables are wrong. Assume,
......
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