b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] batctl ping exit status
@ 2011-11-19 10:43 Filippo Sallemi
  2011-11-19 11:04 ` Antonio Quartulli
  2011-11-20 15:35 ` [B.A.T.M.A.N.] [PATCH] batctl: Return failure code when ping was not successful Sven Eckelmann
  0 siblings, 2 replies; 5+ messages in thread
From: Filippo Sallemi @ 2011-11-19 10:43 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

Hi all,
I'm working on a simple script that check if node is connected. The
scope of this script is make every node able to autorescue in case of
change channel on some gateway node.
To do this check if i'm not a gateway try to ping my gateway ipaddress
then if it not respond try to batctl ping my gateway mac and than if
not respond for a number of tries the node try to find another
channell with the same bssid.
The problem is that batct ping every time exit with status 0 istead of
behaviour of ping command that exit with 1 if ping fail. At this time
I have to use some regex to check if batctl ping status command. It is
possible to fix batctl ping to work such as ping command?

Rgds

-- 
Filippo Sallemi

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [B.A.T.M.A.N.] batctl ping exit status
  2011-11-19 10:43 [B.A.T.M.A.N.] batctl ping exit status Filippo Sallemi
@ 2011-11-19 11:04 ` Antonio Quartulli
  2011-11-19 13:17   ` Filippo Sallemi
  2011-11-20 15:35 ` [B.A.T.M.A.N.] [PATCH] batctl: Return failure code when ping was not successful Sven Eckelmann
  1 sibling, 1 reply; 5+ messages in thread
From: Antonio Quartulli @ 2011-11-19 11:04 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

On Sat, Nov 19, 2011 at 11:43:40 +0100, Filippo Sallemi wrote:
> Hi all,
> I'm working on a simple script that check if node is connected. The
> scope of this script is make every node able to autorescue in case of
> change channel on some gateway node.
> To do this check if i'm not a gateway try to ping my gateway ipaddress
> then if it not respond try to batctl ping my gateway mac and than if
> not respond for a number of tries the node try to find another
> channell with the same bssid.
> The problem is that batct ping every time exit with status 0 istead of
> behaviour of ping command that exit with 1 if ping fail. At this time
> I have to use some regex to check if batctl ping status command. It is
> possible to fix batctl ping to work such as ping command?

I think it is, we just need the proper patch :D
By the way, I see that the ping command returns SUCCESS even if only one
echo_reply is received. Therefore if you send 5 requests and get only 1 reply
(because the node somehow changed channel while you were pinging it), your
script will tell you that the node is UP anyway. Is this the wanted behaviour?

However a meaningful return value for batctl could be a good idea..(not for ping
only)

> 
> Rgds
> 
> -- 
> Filippo Sallemi

-- 
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto "Che" Guevara

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [B.A.T.M.A.N.] batctl ping exit status
  2011-11-19 11:04 ` Antonio Quartulli
@ 2011-11-19 13:17   ` Filippo Sallemi
  0 siblings, 0 replies; 5+ messages in thread
From: Filippo Sallemi @ 2011-11-19 13:17 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

2011/11/19 Antonio Quartulli <ordex@autistici.org>:
> On Sat, Nov 19, 2011 at 11:43:40 +0100, Filippo Sallemi wrote:
>> Hi all,
>> I'm working on a simple script that check if node is connected. The
>> scope of this script is make every node able to autorescue in case of
>> change channel on some gateway node.
>> To do this check if i'm not a gateway try to ping my gateway ipaddress
>> then if it not respond try to batctl ping my gateway mac and than if
>> not respond for a number of tries the node try to find another
>> channell with the same bssid.
>> The problem is that batct ping every time exit with status 0 istead of
>> behaviour of ping command that exit with 1 if ping fail. At this time
>> I have to use some regex to check if batctl ping status command. It is
>> possible to fix batctl ping to work such as ping command?
>
> I think it is, we just need the proper patch :D
> By the way, I see that the ping command returns SUCCESS even if only one
> echo_reply is received. Therefore if you send 5 requests and get only 1 reply
> (because the node somehow changed channel while you were pinging it), your
> script will tell you that the node is UP anyway. Is this the wanted behaviour?
yes
>
> However a meaningful return value for batctl could be a good idea..(not for ping
> only)
exactly
>
>>
>> Rgds
>>
>> --
>> Filippo Sallemi
>
> --
> Antonio Quartulli
>
> ..each of us alone is worth nothing..
> Ernesto "Che" Guevara
>



-- 
Filippo Sallemi

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [B.A.T.M.A.N.] [PATCH] batctl: Return failure code when ping was not successful
  2011-11-19 10:43 [B.A.T.M.A.N.] batctl ping exit status Filippo Sallemi
  2011-11-19 11:04 ` Antonio Quartulli
@ 2011-11-20 15:35 ` Sven Eckelmann
  2011-11-22 10:59   ` Marek Lindner
  1 sibling, 1 reply; 5+ messages in thread
From: Sven Eckelmann @ 2011-11-20 15:35 UTC (permalink / raw)
  To: b.a.t.m.a.n

The standard iputils-ping returns an error code when it could not receive a
single reply to a echo request. batctl ping behaved differently and made it
only possible to detect that the target is not reachable by parsing the text
output of batctl.

A new return code EXIT_NOSUCCESS (2) is introduced to distinguish a general
failure from the inability to reach another node.

Reported-by: Filippo Sallemi <tonyputi@gmail.com>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 main.h |    2 ++
 ping.c |    5 ++++-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/main.h b/main.h
index e5a3e01..fb7ca38 100644
--- a/main.h
+++ b/main.h
@@ -25,4 +25,6 @@
 
 #define SOCKET_PATH_FMT "%s/batman_adv/%s/socket"
 
+#define EXIT_NOSUCCESS 2
+
 #define __packed __attribute((packed))   /* linux kernel compat */
diff --git a/ping.c b/ping.c
index 91b733a..1b715f3 100644
--- a/ping.c
+++ b/ping.c
@@ -322,7 +322,10 @@ sleep:
 	printf("rtt min/avg/max/mdev = %.3f/%.3f/%.3f/%.3f ms\n",
 		min, avg, max, mdev);
 
-	ret = EXIT_SUCCESS;
+	if (packets_in)
+		ret = EXIT_SUCCESS;
+	else
+		ret = EXIT_NOSUCCESS;
 
 out:
 	bat_hosts_free();
-- 
1.7.7.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH] batctl: Return failure code when ping was not successful
  2011-11-20 15:35 ` [B.A.T.M.A.N.] [PATCH] batctl: Return failure code when ping was not successful Sven Eckelmann
@ 2011-11-22 10:59   ` Marek Lindner
  0 siblings, 0 replies; 5+ messages in thread
From: Marek Lindner @ 2011-11-22 10:59 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

On Sunday, November 20, 2011 23:35:16 Sven Eckelmann wrote:
> The standard iputils-ping returns an error code when it could not receive a
> single reply to a echo request. batctl ping behaved differently and made it
> only possible to detect that the target is not reachable by parsing the
> text output of batctl.
> 
> A new return code EXIT_NOSUCCESS (2) is introduced to distinguish a general
> failure from the inability to reach another node.

Applied in revision 5f3776a.

Thanks,
Marek

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-11-22 10:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-19 10:43 [B.A.T.M.A.N.] batctl ping exit status Filippo Sallemi
2011-11-19 11:04 ` Antonio Quartulli
2011-11-19 13:17   ` Filippo Sallemi
2011-11-20 15:35 ` [B.A.T.M.A.N.] [PATCH] batctl: Return failure code when ping was not successful Sven Eckelmann
2011-11-22 10:59   ` Marek Lindner

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).