inet: Move VRF table lookup to inlined function
authorDavid Ahern <dsa@cumulusnetworks.com>
Sun, 16 Aug 2015 23:13:27 +0000 (17:13 -0600)
committerDavid S. Miller <davem@davemloft.net>
Mon, 17 Aug 2015 22:58:57 +0000 (15:58 -0700)
Table lookup compiles out when VRF is not enabled.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/vrf.h
net/ipv4/af_inet.c

index 0484d29..40e3793 100644 (file)
@@ -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;
Simple merge