Subject: Re: [net-next]: unable to add routes to tables

From: David Ahern <[email-masked]>
Date: Tue, 18 Aug 2015 11:26:15 -0600

On 8/18/15 10:57 AM, Andreas Schultz wrote:
> Hi,
>
> It seems that the policy for adding routes to tables has changed between
> Linux 4.2-rc6 and net-next.
>
> In Linux main line (tested up to 4.2-rc6), with this main routing table:
> # ip route show table main
> ...
> 172.28.0.0/24 dev vnf-xe1p0  proto kernel  scope link  src 172.28.0.16
>
> and an empty table 100, this works:
>
> # ip route add 10.0.0.0/8 via 172.28.0.32 table 100 dev vnf-xe1p0
>
> With net-next at commit d52736e24fe2e927c26817256f8d1a3c8b5d51a0, the
> same command leads to an:
>
> # ip route add 10.0.0.0/8 via 172.28.0.32 table 100 dev vnf-xe1p0
> RTNETLINK answers: Resource temporarily unavailable
>
> Is this expected behavior?
>

The attached works for me and so does my original problem. Can you 
confirm it resolves your problem? If so I'll send a formal patch.

David

diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index c8025851dac7..01a237278dd2 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -710,9 +710,16 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi,
 				err = fib_table_lookup(tbl, &fl4, &res,
 						       FIB_LOOKUP_IGNORE_LINKSTATE |
 						       FIB_LOOKUP_NOREF);
-			else
+
+			/* on error or if no table given do full lookup. This is
+			 * needed for example when nexthops are in the local table
+			 * rather than the given table
+			 */
+			if (!tbl || err) {
 				err = fib_lookup(net, &fl4, &res,
 						 FIB_LOOKUP_IGNORE_LINKSTATE);
+			}
+
 			if (err) {
 				rcu_read_unlock();
 				return err;