diff mbox

return the right retcode when add a unreachable route

Message ID 1404644511-22112-1-git-send-email-lucien.xin@gmail.com
State Rejected, archived
Delegated to: David Miller
Headers show

Commit Message

Xin Long July 6, 2014, 11:01 a.m. UTC
when add a route like this:
ip route add 74.125.31.199 dev eth0 via 1.2.3.4 ,
1.2.3.4 is a unreachable ip, it return -ENETUNREACH, it is ok.
but before that I add a rule:
ip rule add fwmark 1 lookup 101 ,
then add that route , it will return -ESRCH.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/net/ip_fib.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Cong Wang July 8, 2014, 6:49 p.m. UTC | #1
On Sun, Jul 6, 2014 at 4:01 AM, Xin Long <lucien.xin@gmail.com> wrote:
> when add a route like this:
> ip route add 74.125.31.199 dev eth0 via 1.2.3.4 ,
> 1.2.3.4 is a unreachable ip, it return -ENETUNREACH, it is ok.
> but before that I add a rule:
> ip rule add fwmark 1 lookup 101 ,
> then add that route , it will return -ESRCH.
>

This would potentially break user-space applications.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Xin Long July 9, 2014, 1:51 a.m. UTC | #2
On Wed, Jul 9, 2014 at 2:49 AM, Cong Wang <cwang@twopensource.com> wrote:
> On Sun, Jul 6, 2014 at 4:01 AM, Xin Long <lucien.xin@gmail.com> wrote:
>
> This would potentially break user-space applications.

yes, you are right. if I only handle the -ESRCH , like:

-       return __fib_lookup(net, flp, res);
+
+       err = __fib_lookup(net, flp, res);
+       if(err == -ESRCH)
+               return -ENETUNREACH;
+
+       return err;

I think it will be ok, after all, it looks confused that err is *No
such process* when add a route.

thanks for your reply.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller July 9, 2014, 2:33 a.m. UTC | #3
From: lucien xin <lucien.xin@gmail.com>
Date: Wed, 9 Jul 2014 09:51:02 +0800

> On Wed, Jul 9, 2014 at 2:49 AM, Cong Wang <cwang@twopensource.com> wrote:
>> On Sun, Jul 6, 2014 at 4:01 AM, Xin Long <lucien.xin@gmail.com> wrote:
>>
>> This would potentially break user-space applications.
> 
> yes, you are right. if I only handle the -ESRCH , like:
> 
> -       return __fib_lookup(net, flp, res);
> +
> +       err = __fib_lookup(net, flp, res);
> +       if(err == -ESRCH)
> +               return -ENETUNREACH;
> +
> +       return err;
> 
> I think it will be ok, after all, it looks confused that err is *No
> such process* when add a route.

It doesn't matter, if applications want to work on all kernels they
will test whatever error code is being provided now.

Therefore, by changing it you will break those applications.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index 9922093..cfc2293 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -261,7 +261,9 @@  static inline int fib_lookup(struct net *net, struct flowi4 *flp,
 			return 0;
 		return -ENETUNREACH;
 	}
-	return __fib_lookup(net, flp, res);
+	if(__fib_lookup(net, flp, res))
+		return -ENETUNREACH;
+	return 0;
 }
 
 #endif /* CONFIG_IP_MULTIPLE_TABLES */