Commit dc028da5 authored by David Ahern's avatar David Ahern Committed by David S. Miller

inet: Move VRF table lookup to inlined function

Table lookup compiles out when VRF is not enabled.
Signed-off-by: default avatarDavid Ahern <dsa@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 808d28c4
......@@ -81,6 +81,25 @@ static inline int vrf_dev_table(const struct net_device *dev)
return tb_id;
}
static inline int vrf_dev_table_ifindex(struct net *net, int ifindex)
{
struct net_device *dev;
int tb_id = 0;
if (!ifindex)
return 0;
rcu_read_lock();
dev = dev_get_by_index_rcu(net, ifindex);
if (dev)
tb_id = vrf_dev_table_rcu(dev);
rcu_read_unlock();
return tb_id;
}
/* called with rtnl */
static inline int vrf_dev_table_rtnl(const struct net_device *dev)
{
......@@ -125,6 +144,11 @@ static inline int vrf_dev_table(const struct net_device *dev)
return 0;
}
static inline int vrf_dev_table_ifindex(struct net *net, int ifindex)
{
return 0;
}
static inline int vrf_dev_table_rtnl(const struct net_device *dev)
{
return 0;
......
......@@ -450,15 +450,7 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
goto out;
}
if (sk->sk_bound_dev_if) {
struct net_device *dev;
rcu_read_lock();
dev = dev_get_by_index_rcu(net, sk->sk_bound_dev_if);
if (dev)
tb_id = vrf_dev_table_rcu(dev) ? : tb_id;
rcu_read_unlock();
}
tb_id = vrf_dev_table_ifindex(net, sk->sk_bound_dev_if) ? : tb_id;
chk_addr_ret = inet_addr_type_table(net, addr->sin_addr.s_addr, tb_id);
/* Not specified by any standard per-se, however it breaks too
......
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