traceroute sets ret to EXIT_SUCCESS unconditionally once the probe loop
finishes. dst_reached is only set on an actual echo reply, so when the
target never answers within TTL_MAX hops, it is unreachable or all
probes time out. But this information is ignored when traceroute exits. A
script will not be able to distinguish a failed and working traceroute.

Use the same error codes as the ping but make it depend on the dst_reached
variable.

Fixes: e1c83d9260e8 ("[batctl] traceroute utility updated to latest batman adv")
Signed-off-by: Sven Eckelmann <[email protected]>
---
 traceroute.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/traceroute.c b/traceroute.c
index 441cd77..94443d7 100644
--- a/traceroute.c
+++ b/traceroute.c
@@ -212,7 +212,10 @@ static int traceroute(struct state *state, int argc, char 
**argv)
                printf("\n");
        }
 
-       ret = EXIT_SUCCESS;
+       if (dst_reached)
+               ret = EXIT_SUCCESS;
+       else
+               ret = EXIT_NOSUCCESS;
 
 out:
        icmp_interfaces_clean();

-- 
2.47.3

Reply via email to