* [PATCH net-next] net: vrf: Create FIB tables on link create
@ 2016-05-05 4:18 David Ahern
2016-05-05 4:24 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: David Ahern @ 2016-05-05 4:18 UTC (permalink / raw)
To: netdev; +Cc: David Ahern
Tables have to exist for VRFs to function. Ensure they exist
when VRF device is created.
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
---
drivers/net/vrf.c | 11 +++++++++--
net/ipv4/fib_frontend.c | 1 +
net/ipv6/ip6_fib.c | 1 +
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index 8a8f1e58b415..2f2aac1b598f 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -372,9 +372,13 @@ static int vrf_rt6_create(struct net_device *dev)
if (!rt6)
goto out;
- rt6->dst.output = vrf_output6;
- rt6->rt6i_table = fib6_get_table(net, vrf->tb_id);
dst_hold(&rt6->dst);
+
+ rt6->rt6i_table = fib6_new_table(net, vrf->tb_id);
+ if (!rt6->rt6i_table)
+ goto out;
+
+ rt6->dst.output = vrf_output6;
vrf->rt6 = rt6;
rc = 0;
out:
@@ -462,6 +466,9 @@ static struct rtable *vrf_rtable_create(struct net_device *dev)
struct net_vrf *vrf = netdev_priv(dev);
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);
if (rth) {
rth->dst.output = vrf_output;
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 63566ec54794..ef2ebeb89d0f 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -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]);
return tb;
}
+EXPORT_SYMBOL_GPL(fib_new_table);
/* caller must hold either rtnl or rcu read lock */
struct fib_table *fib_get_table(struct net *net, u32 id)
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index ea071fad67a0..1bcef2369d64 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -240,6 +240,7 @@ struct fib6_table *fib6_new_table(struct net *net, u32 id)
return tb;
}
+EXPORT_SYMBOL_GPL(fib6_new_table);
struct fib6_table *fib6_get_table(struct net *net, u32 id)
{
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: vrf: Create FIB tables on link create
2016-05-05 4:18 [PATCH net-next] net: vrf: Create FIB tables on link create David Ahern
@ 2016-05-05 4:24 ` David Miller
2016-05-05 4:29 ` David Ahern
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2016-05-05 4:24 UTC (permalink / raw)
To: dsa; +Cc: netdev
From: David Ahern <dsa@cumulusnetworks.com>
Date: Wed, 4 May 2016 21:18:07 -0700
> @@ -372,9 +372,13 @@ static int vrf_rt6_create(struct net_device *dev)
> if (!rt6)
> goto out;
>
> - rt6->dst.output = vrf_output6;
> - rt6->rt6i_table = fib6_get_table(net, vrf->tb_id);
> dst_hold(&rt6->dst);
> +
> + rt6->rt6i_table = fib6_new_table(net, vrf->tb_id);
> + if (!rt6->rt6i_table)
> + goto out;
> +
> + rt6->dst.output = vrf_output6;
> vrf->rt6 = rt6;
> rc = 0;
> out:
This leaks rt6.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: vrf: Create FIB tables on link create
2016-05-05 4:24 ` David Miller
@ 2016-05-05 4:29 ` David Ahern
0 siblings, 0 replies; 3+ messages in thread
From: David Ahern @ 2016-05-05 4:29 UTC (permalink / raw)
To: David Miller; +Cc: netdev
On 5/4/16 10:24 PM, David Miller wrote:
> From: David Ahern <dsa@cumulusnetworks.com>
> Date: Wed, 4 May 2016 21:18:07 -0700
>
>> @@ -372,9 +372,13 @@ static int vrf_rt6_create(struct net_device *dev)
>> if (!rt6)
>> goto out;
>>
>> - rt6->dst.output = vrf_output6;
>> - rt6->rt6i_table = fib6_get_table(net, vrf->tb_id);
>> dst_hold(&rt6->dst);
>> +
>> + rt6->rt6i_table = fib6_new_table(net, vrf->tb_id);
>> + if (!rt6->rt6i_table)
>> + goto out;
>> +
>> + rt6->dst.output = vrf_output6;
>> vrf->rt6 = rt6;
>> rc = 0;
>> out:
>
> This leaks rt6.
>
Indeed. That fact was lost by follow on patches which fix the ordering.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-05-05 4:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-05 4:18 [PATCH net-next] net: vrf: Create FIB tables on link create David Ahern
2016-05-05 4:24 ` David Miller
2016-05-05 4:29 ` David Ahern
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox