* [PATCH] return the right retcode when add a unreachable route
@ 2014-07-06 11:01 Xin Long
2014-07-08 18:49 ` Cong Wang
0 siblings, 1 reply; 4+ messages in thread
From: Xin Long @ 2014-07-06 11:01 UTC (permalink / raw)
To: network dev; +Cc: Xin Long
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(-)
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 */
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] return the right retcode when add a unreachable route
2014-07-06 11:01 [PATCH] return the right retcode when add a unreachable route Xin Long
@ 2014-07-08 18:49 ` Cong Wang
2014-07-09 1:51 ` lucien xin
0 siblings, 1 reply; 4+ messages in thread
From: Cong Wang @ 2014-07-08 18:49 UTC (permalink / raw)
To: Xin Long; +Cc: network dev
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] return the right retcode when add a unreachable route
2014-07-08 18:49 ` Cong Wang
@ 2014-07-09 1:51 ` lucien xin
2014-07-09 2:33 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: lucien xin @ 2014-07-09 1:51 UTC (permalink / raw)
To: Cong Wang; +Cc: network dev
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] return the right retcode when add a unreachable route
2014-07-09 1:51 ` lucien xin
@ 2014-07-09 2:33 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2014-07-09 2:33 UTC (permalink / raw)
To: lucien.xin; +Cc: cwang, netdev
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-07-09 2:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-06 11:01 [PATCH] return the right retcode when add a unreachable route Xin Long
2014-07-08 18:49 ` Cong Wang
2014-07-09 1:51 ` lucien xin
2014-07-09 2:33 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).