From 2102796b00a0ad4b25f6e58b45fee513f1f43e8f Mon Sep 17 00:00:00 2001 From: benno Date: Tue, 4 Jul 2017 20:27:09 +0000 Subject: [PATCH] if configured, set the ttl (IPV6_UNICAST_HOPS) for ipv6 tcp checks. From Kapetanakis Giannis, thanks. ok florian@ --- usr.sbin/relayd/check_tcp.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/usr.sbin/relayd/check_tcp.c b/usr.sbin/relayd/check_tcp.c index ea0d7fdb4a1..120bf5f92d1 100644 --- a/usr.sbin/relayd/check_tcp.c +++ b/usr.sbin/relayd/check_tcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: check_tcp.c,v 1.54 2017/05/28 10:39:15 benno Exp $ */ +/* $OpenBSD: check_tcp.c,v 1.55 2017/07/04 20:27:09 benno Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard @@ -82,11 +82,19 @@ check_tcp(struct ctl_tcp_event *cte) if (setsockopt(s, SOL_SOCKET, SO_LINGER, &lng, sizeof(lng)) == -1) goto bad; - if (cte->host->conf.ttl > 0) { - if (setsockopt(s, IPPROTO_IP, IP_TTL, - &cte->host->conf.ttl, sizeof(int)) == -1) - goto bad; - } + if (cte->host->conf.ttl > 0) + switch (cte->host->conf.ss.ss_family) { + case AF_INET: + if (setsockopt(s, IPPROTO_IP, IP_TTL, + &cte->host->conf.ttl, sizeof(int)) == -1) + goto bad; + break; + case AF_INET6: + if (setsockopt(s, IPPROTO_IPV6, IPV6_UNICAST_HOPS, + &cte->host->conf.ttl, sizeof(int)) == -1) + goto bad; + break; + } bcopy(&cte->table->conf.timeout, &tv, sizeof(tv)); if (connect(s, (struct sockaddr *)&cte->host->conf.ss, len) == -1) { -- 2.20.1