net: Add FIB table id to rtable
authorDavid Ahern <dsa@cumulusnetworks.com>
Wed, 2 Sep 2015 20:58:35 +0000 (13:58 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 15 Sep 2015 19:01:41 +0000 (12:01 -0700)
Add the FIB table id to rtable to make the information available for
IPv4 as it is for IPv6.

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

index e7094fbd75685998bb5ee492367e686c133a2e15..8c9ab5ebea2318f86e522a3c9129b36c95880b2e 100644 (file)
@@ -320,6 +320,7 @@ static void vrf_rtable_destroy(struct net_vrf *vrf)
 
 static struct rtable *vrf_rtable_create(struct net_device *dev)
 {
+       struct net_vrf *vrf = netdev_priv(dev);
        struct rtable *rth;
 
        rth = dst_alloc(&vrf_dst_ops, dev, 2,
@@ -335,6 +336,7 @@ static struct rtable *vrf_rtable_create(struct net_device *dev)
                rth->rt_pmtu    = 0;
                rth->rt_gateway = 0;
                rth->rt_uses_gateway = 0;
+               rth->rt_table_id = vrf->tb_id;
                INIT_LIST_HEAD(&rth->rt_uncached);
                rth->rt_uncached_list = NULL;
        }
index cc61cb95f059152bc8cc58c0a2cacb2d9099e103..10a7d21a211cd72a9a839ebf241d9950a392da26 100644 (file)
@@ -64,6 +64,8 @@ struct rtable {
        /* Miscellaneous cached information */
        u32                     rt_pmtu;
 
+       u32                     rt_table_id;
+
        struct list_head        rt_uncached;
        struct uncached_list    *rt_uncached_list;
 };
index eaefeadce07cc11e05dc05139b07d9cf4191b311..92acc95b7578f6c44d6ff6548225a6cc636a77d6 100644 (file)
@@ -1457,6 +1457,7 @@ static struct rtable *rt_dst_alloc(struct net_device *dev,
                rt->rt_pmtu = 0;
                rt->rt_gateway = 0;
                rt->rt_uses_gateway = 0;
+               rt->rt_table_id = 0;
                INIT_LIST_HEAD(&rt->rt_uncached);
 
                rt->dst.output = ip_output;
@@ -1629,6 +1630,8 @@ static int __mkroute_input(struct sk_buff *skb,
        }
 
        rth->rt_is_input = 1;
+       if (res->table)
+               rth->rt_table_id = res->table->tb_id;
        RT_CACHE_STAT_INC(in_slow_tot);
 
        rth->dst.input = ip_forward;
@@ -1808,6 +1811,8 @@ local_input:
        rth->dst.tclassid = itag;
 #endif
        rth->rt_is_input = 1;
+       if (res.table)
+               rth->rt_table_id = res.table->tb_id;
 
        RT_CACHE_STAT_INC(in_slow_tot);
        if (res.type == RTN_UNREACHABLE) {
@@ -1988,6 +1993,9 @@ add:
                return ERR_PTR(-ENOBUFS);
 
        rth->rt_iif     = orig_oif ? : 0;
+       if (res->table)
+               rth->rt_table_id = res->table->tb_id;
+
        RT_CACHE_STAT_INC(out_slow_tot);
 
        if (flags & (RTCF_BROADCAST | RTCF_MULTICAST)) {
index bb919b28619fbfd7689d5479ca267ce03db89d71..671011055ad5dd0d2d1ebbb864873683f981da67 100644 (file)
@@ -95,6 +95,7 @@ static int xfrm4_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
        xdst->u.rt.rt_gateway = rt->rt_gateway;
        xdst->u.rt.rt_uses_gateway = rt->rt_uses_gateway;
        xdst->u.rt.rt_pmtu = rt->rt_pmtu;
+       xdst->u.rt.rt_table_id = rt->rt_table_id;
        INIT_LIST_HEAD(&xdst->u.rt.rt_uncached);
 
        return 0;