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

net: vrf: Create FIB tables on link create

Tables have to exist for VRFs to function. Ensure they exist
when VRF device is created.
Signed-off-by: default avatarDavid Ahern <dsa@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f37bd0cc
...@@ -364,17 +364,23 @@ static int vrf_rt6_create(struct net_device *dev) ...@@ -364,17 +364,23 @@ static int vrf_rt6_create(struct net_device *dev)
{ {
struct net_vrf *vrf = netdev_priv(dev); struct net_vrf *vrf = netdev_priv(dev);
struct net *net = dev_net(dev); struct net *net = dev_net(dev);
struct fib6_table *rt6i_table;
struct rt6_info *rt6; struct rt6_info *rt6;
int rc = -ENOMEM; int rc = -ENOMEM;
rt6i_table = fib6_new_table(net, vrf->tb_id);
if (!rt6i_table)
goto out;
rt6 = ip6_dst_alloc(net, dev, rt6 = ip6_dst_alloc(net, dev,
DST_HOST | DST_NOPOLICY | DST_NOXFRM | DST_NOCACHE); DST_HOST | DST_NOPOLICY | DST_NOXFRM | DST_NOCACHE);
if (!rt6) if (!rt6)
goto out; goto out;
rt6->dst.output = vrf_output6;
rt6->rt6i_table = fib6_get_table(net, vrf->tb_id);
dst_hold(&rt6->dst); dst_hold(&rt6->dst);
rt6->rt6i_table = rt6i_table;
rt6->dst.output = vrf_output6;
vrf->rt6 = rt6; vrf->rt6 = rt6;
rc = 0; rc = 0;
out: out:
...@@ -462,6 +468,9 @@ static struct rtable *vrf_rtable_create(struct net_device *dev) ...@@ -462,6 +468,9 @@ static struct rtable *vrf_rtable_create(struct net_device *dev)
struct net_vrf *vrf = netdev_priv(dev); struct net_vrf *vrf = netdev_priv(dev);
struct rtable *rth; struct rtable *rth;
if (!fib_new_table(dev_net(dev), vrf->tb_id))
return NULL;
rth = rt_dst_alloc(dev, 0, RTN_UNICAST, 1, 1, 0); rth = rt_dst_alloc(dev, 0, RTN_UNICAST, 1, 1, 0);
if (rth) { if (rth) {
rth->dst.output = vrf_output; rth->dst.output = vrf_output;
......
...@@ -110,6 +110,7 @@ struct fib_table *fib_new_table(struct net *net, u32 id) ...@@ -110,6 +110,7 @@ struct fib_table *fib_new_table(struct net *net, u32 id)
hlist_add_head_rcu(&tb->tb_hlist, &net->ipv4.fib_table_hash[h]); hlist_add_head_rcu(&tb->tb_hlist, &net->ipv4.fib_table_hash[h]);
return tb; return tb;
} }
EXPORT_SYMBOL_GPL(fib_new_table);
/* caller must hold either rtnl or rcu read lock */ /* caller must hold either rtnl or rcu read lock */
struct fib_table *fib_get_table(struct net *net, u32 id) struct fib_table *fib_get_table(struct net *net, u32 id)
......
...@@ -240,6 +240,7 @@ struct fib6_table *fib6_new_table(struct net *net, u32 id) ...@@ -240,6 +240,7 @@ struct fib6_table *fib6_new_table(struct net *net, u32 id)
return tb; return tb;
} }
EXPORT_SYMBOL_GPL(fib6_new_table);
struct fib6_table *fib6_get_table(struct net *net, u32 id) struct fib6_table *fib6_get_table(struct net *net, u32 id)
{ {
......
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