diff mbox

[2/4] ip: return correct exit code on route failure

Message ID 1430931483-28595-3-git-send-email-stephen@networkplumber.org
State Accepted, archived
Delegated to: stephen hemminger
Headers show

Commit Message

Stephen Hemminger May 6, 2015, 4:58 p.m. UTC
From: Stephen Hemminger <shemming@brocade.com>

If kernel complains about ip route request, exit status should be
2 not 1.

This fixes regression introduced by:
commit 42ecedd4bae534fc688194a795eb4548c6530cda
Author: Roopa Prabhu <roopa@cumulusnetworks.com>
Date:   Tue Mar 17 19:26:32 2015 -0700

    fix ip -force -batch to continue on errors
---
 ip/iproute.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Roopa Prabhu May 6, 2015, 5:19 p.m. UTC | #1
On 5/6/15, 9:58 AM, Stephen Hemminger wrote:
> From: Stephen Hemminger <shemming@brocade.com>
>
> If kernel complains about ip route request, exit status should be
> 2 not 1.
>
> This fixes regression introduced by:
> commit 42ecedd4bae534fc688194a795eb4548c6530cda
> Author: Roopa Prabhu <roopa@cumulusnetworks.com>
> Date:   Tue Mar 17 19:26:32 2015 -0700
>
>      fix ip -force -batch to continue on errors
> ---
>   ip/iproute.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/ip/iproute.c b/ip/iproute.c
> index e0a6159..06aea6f 100644
> --- a/ip/iproute.c
> +++ b/ip/iproute.c
> @@ -1164,7 +1164,7 @@ static int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
>   		req.r.rtm_family = AF_INET;
>   
>   	if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
> -		return -1;
> +		return -2;
>   
>   	return 0;
>   }
Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com>

Thanks for documenting the error code convention.

--
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
Vadym Kochan May 6, 2015, 5:25 p.m. UTC | #2
On Wed, May 06, 2015 at 09:58:01AM -0700, Stephen Hemminger wrote:
> From: Stephen Hemminger <shemming@brocade.com>
> 
> If kernel complains about ip route request, exit status should be
> 2 not 1.
> 
> This fixes regression introduced by:
> commit 42ecedd4bae534fc688194a795eb4548c6530cda
> Author: Roopa Prabhu <roopa@cumulusnetworks.com>
> Date:   Tue Mar 17 19:26:32 2015 -0700
> 
>     fix ip -force -batch to continue on errors
> ---
>  ip/iproute.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/ip/iproute.c b/ip/iproute.c
> index e0a6159..06aea6f 100644
> --- a/ip/iproute.c
> +++ b/ip/iproute.c
> @@ -1164,7 +1164,7 @@ static int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
>  		req.r.rtm_family = AF_INET;
>  
>  	if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
> -		return -1;
> +		return -2;
May be it would be good to have a #define's like ERR_APP & ERR_KERN ?

>  
>  	return 0;
>  }
> -- 
> 2.1.4
> 
> --
> 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
--
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/ip/iproute.c b/ip/iproute.c
index e0a6159..06aea6f 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -1164,7 +1164,7 @@  static int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
 		req.r.rtm_family = AF_INET;
 
 	if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
-		return -1;
+		return -2;
 
 	return 0;
 }