aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristos Longros <chris.longros@gmail.com>2026-04-17 18:19:24 +0000
committerJose Luis Duran <jlduran@FreeBSD.org>2026-04-24 00:53:10 +0000
commitc2b4fbdb45e995c91afde8ab796270bc0dadea37 (patch)
treeade6c9b29cb905b552227f34cced357ddb1086de
parent200b48c5e8be2151bdff9daea0d01ba1a6375d5d (diff)
ping6: treat setsockopt failures as fatal
ping6 needs IPV6_RECVPKTINFO and IPV6_RECVHOPLIMIT to process incoming replies. When these options fail, replies are silently dropped and ping6 appears to hang. Use err(3) instead of warn(3) so the user gets a clear error and immediate exit. Signed-off-by: Christos Longros <chris.longros@gmail.com> Reviewed by: pouria, jlduran, glebius MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D56237 (cherry picked from commit 9a4a9f623bbaf991b3ba580593d47f2ee9f7b03b)
-rw-r--r--sbin/ping/ping6.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sbin/ping/ping6.c b/sbin/ping/ping6.c
index d1f4c192b4c4..c029f7412dce 100644
--- a/sbin/ping/ping6.c
+++ b/sbin/ping/ping6.c
@@ -1119,21 +1119,21 @@ ping6(int argc, char *argv[])
#ifdef IPV6_RECVPKTINFO
if (setsockopt(srecv, IPPROTO_IPV6, IPV6_RECVPKTINFO, &optval,
sizeof(optval)) < 0)
- warn("setsockopt(IPV6_RECVPKTINFO)"); /* XXX err? */
+ err(1, "setsockopt(IPV6_RECVPKTINFO)");
#else /* old adv. API */
if (setsockopt(srecv, IPPROTO_IPV6, IPV6_PKTINFO, &optval,
sizeof(optval)) < 0)
- warn("setsockopt(IPV6_PKTINFO)"); /* XXX err? */
+ err(1, "setsockopt(IPV6_PKTINFO)");
#endif
#endif /* USE_SIN6_SCOPE_ID */
#ifdef IPV6_RECVHOPLIMIT
if (setsockopt(srecv, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &optval,
sizeof(optval)) < 0)
- warn("setsockopt(IPV6_RECVHOPLIMIT)"); /* XXX err? */
+ err(1, "setsockopt(IPV6_RECVHOPLIMIT)");
#else /* old adv. API */
if (setsockopt(srecv, IPPROTO_IPV6, IPV6_HOPLIMIT, &optval,
sizeof(optval)) < 0)
- warn("setsockopt(IPV6_HOPLIMIT)"); /* XXX err? */
+ err(1, "setsockopt(IPV6_HOPLIMIT)");
#endif
cap_rights_clear(&rights_srecv, CAP_SETSOCKOPT);