Skip to content

Commit b7503e0

Browse files
David Aherndavem330
authored andcommitted
net: Add FIB table id to rtable
Add the FIB table id to rtable to make the information available for IPv4 as it is for IPv6. Signed-off-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d08c4f3 commit b7503e0

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

drivers/net/vrf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ static void vrf_rtable_destroy(struct net_vrf *vrf)
320320

321321
static struct rtable *vrf_rtable_create(struct net_device *dev)
322322
{
323+
struct net_vrf *vrf = netdev_priv(dev);
323324
struct rtable *rth;
324325

325326
rth = dst_alloc(&vrf_dst_ops, dev, 2,
@@ -335,6 +336,7 @@ static struct rtable *vrf_rtable_create(struct net_device *dev)
335336
rth->rt_pmtu = 0;
336337
rth->rt_gateway = 0;
337338
rth->rt_uses_gateway = 0;
339+
rth->rt_table_id = vrf->tb_id;
338340
INIT_LIST_HEAD(&rth->rt_uncached);
339341
rth->rt_uncached_list = NULL;
340342
}

include/net/route.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ struct rtable {
6464
/* Miscellaneous cached information */
6565
u32 rt_pmtu;
6666

67+
u32 rt_table_id;
68+
6769
struct list_head rt_uncached;
6870
struct uncached_list *rt_uncached_list;
6971
};

net/ipv4/route.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,7 @@ static struct rtable *rt_dst_alloc(struct net_device *dev,
14571457
rt->rt_pmtu = 0;
14581458
rt->rt_gateway = 0;
14591459
rt->rt_uses_gateway = 0;
1460+
rt->rt_table_id = 0;
14601461
INIT_LIST_HEAD(&rt->rt_uncached);
14611462

14621463
rt->dst.output = ip_output;
@@ -1629,6 +1630,8 @@ static int __mkroute_input(struct sk_buff *skb,
16291630
}
16301631

16311632
rth->rt_is_input = 1;
1633+
if (res->table)
1634+
rth->rt_table_id = res->table->tb_id;
16321635
RT_CACHE_STAT_INC(in_slow_tot);
16331636

16341637
rth->dst.input = ip_forward;
@@ -1808,6 +1811,8 @@ out: return err;
18081811
rth->dst.tclassid = itag;
18091812
#endif
18101813
rth->rt_is_input = 1;
1814+
if (res.table)
1815+
rth->rt_table_id = res.table->tb_id;
18111816

18121817
RT_CACHE_STAT_INC(in_slow_tot);
18131818
if (res.type == RTN_UNREACHABLE) {
@@ -1988,6 +1993,9 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
19881993
return ERR_PTR(-ENOBUFS);
19891994

19901995
rth->rt_iif = orig_oif ? : 0;
1996+
if (res->table)
1997+
rth->rt_table_id = res->table->tb_id;
1998+
19911999
RT_CACHE_STAT_INC(out_slow_tot);
19922000

19932001
if (flags & (RTCF_BROADCAST | RTCF_MULTICAST)) {

net/ipv4/xfrm4_policy.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ static int xfrm4_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
9595
xdst->u.rt.rt_gateway = rt->rt_gateway;
9696
xdst->u.rt.rt_uses_gateway = rt->rt_uses_gateway;
9797
xdst->u.rt.rt_pmtu = rt->rt_pmtu;
98+
xdst->u.rt.rt_table_id = rt->rt_table_id;
9899
INIT_LIST_HEAD(&xdst->u.rt.rt_uncached);
99100

100101
return 0;

0 commit comments

Comments
 (0)