From owner-svn-src-head@freebsd.org Sat Feb 15 15:39:53 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E192B23ED24; Sat, 15 Feb 2020 15:39:53 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48KZF55b8lz4NPy; Sat, 15 Feb 2020 15:39:53 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BA41FF0DD; Sat, 15 Feb 2020 15:39:53 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 01FFdrSr054399; Sat, 15 Feb 2020 15:39:53 GMT (envelope-from melifaro@FreeBSD.org) Received: (from melifaro@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 01FFdrH7054398; Sat, 15 Feb 2020 15:39:53 GMT (envelope-from melifaro@FreeBSD.org) Message-Id: <202002151539.01FFdrH7054398@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: melifaro set sender to melifaro@FreeBSD.org using -f From: "Alexander V. Chernikov" Date: Sat, 15 Feb 2020 15:39:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357967 - head/sbin/ping6 X-SVN-Group: head X-SVN-Commit-Author: melifaro X-SVN-Commit-Paths: head/sbin/ping6 X-SVN-Commit-Revision: 357967 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Feb 2020 15:39:53 -0000 Author: melifaro Date: Sat Feb 15 15:39:53 2020 New Revision: 357967 URL: https://svnweb.freebsd.org/changeset/base/357967 Log: Make ping6(1) return code consistent with the man page. When every sendto() call originated by ping6(1) fails, current code always returns 2 ("transmission was successful but no responses were received") which is incorrect. Return EX_OSERR instead as in many cases it indicates some kernel-level problems. MFC after: 3 weeks Modified: head/sbin/ping6/ping6.c Modified: head/sbin/ping6/ping6.c ============================================================================== --- head/sbin/ping6/ping6.c Sat Feb 15 15:05:25 2020 (r357966) +++ head/sbin/ping6/ping6.c Sat Feb 15 15:39:53 2020 (r357967) @@ -238,6 +238,7 @@ static long npackets; /* max packets to transmit */ static long nreceived; /* # of packets we got back */ static long nrepeats; /* number of duplicates */ static long ntransmitted; /* sequence # for outbound packets = #sent */ +static long ntransmitfailures; /* number of transmit failures */ static int interval = 1000; /* interval between packets in ms */ static int waittime = MAXWAIT; /* timeout for each packet */ static long nrcvtimeout = 0; /* # of packets we got back after waittime */ @@ -1256,7 +1257,12 @@ main(int argc, char *argv[]) if(packet != NULL) free(packet); - exit(nreceived == 0 ? 2 : 0); + if (nreceived > 0) + exit(0); + else if (ntransmitted > ntransmitfailures) + exit(2); + else + exit(EX_OSERR); } static void @@ -1423,8 +1429,10 @@ pinger(void) i = sendmsg(ssend, &smsghdr, 0); if (i < 0 || i != cc) { - if (i < 0) + if (i < 0) { + ntransmitfailures++; warn("sendmsg"); + } (void)printf("ping6: wrote %s %d chars, ret=%d\n", hostname, cc, i); }