summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2014-04-23 09:13:01 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2014-04-23 09:13:01 +0000
commit87964bea39547d02831ec953aedc480058429db8 (patch)
treef401911e1daffa4464f57aacb4a0eb99cfe8644a
parentc5fcb68cb0cc81a3b5aec61e6eb9a3b7be59e518 (diff)
move AF independet setsockopts down
OK benno@
-rw-r--r--usr.sbin/traceroute/traceroute.c22
-rw-r--r--usr.sbin/traceroute6/traceroute6.c23
2 files changed, 24 insertions, 21 deletions
diff --git a/usr.sbin/traceroute/traceroute.c b/usr.sbin/traceroute/traceroute.c
index 441d8fe2a8d..ce8100e59fc 100644
--- a/usr.sbin/traceroute/traceroute.c
+++ b/usr.sbin/traceroute/traceroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: traceroute.c,v 1.118 2014/04/23 09:10:53 florian Exp $ */
+/* $OpenBSD: traceroute.c,v 1.119 2014/04/23 09:13:00 florian Exp $ */
/* $NetBSD: traceroute.c,v 1.10 1995/05/21 15:50:45 mycroft Exp $ */
/*-
@@ -613,18 +613,9 @@ main(int argc, char *argv[])
ip->ip_v = IPVERSION;
ip->ip_tos = tos;
- if (options & SO_DEBUG)
- (void) setsockopt(rcvsock, SOL_SOCKET, SO_DEBUG,
- (char *)&on, sizeof(on));
- if (setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, (char *)&datalen,
- sizeof(datalen)) < 0)
- err(6, "SO_SNDBUF");
if (setsockopt(sndsock, IPPROTO_IP, IP_HDRINCL, (char *)&on,
sizeof(on)) < 0)
err(6, "IP_HDRINCL");
- if (options & SO_DEBUG)
- (void) setsockopt(sndsock, SOL_SOCKET, SO_DEBUG,
- (char *)&on, sizeof(on));
if (source) {
(void) memset(&from4, 0, sizeof(from4));
@@ -642,6 +633,17 @@ main(int argc, char *argv[])
err(1, "bind");
}
+ if (options & SO_DEBUG) {
+ (void) setsockopt(rcvsock, SOL_SOCKET, SO_DEBUG,
+ (char *)&on, sizeof(on));
+ (void) setsockopt(sndsock, SOL_SOCKET, SO_DEBUG,
+ (char *)&on, sizeof(on));
+ }
+
+ if (setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, (char *)&datalen,
+ sizeof(datalen)) < 0)
+ err(6, "SO_SNDBUF");
+
if (getnameinfo(to, to->sa_len, hbuf,
sizeof(hbuf), NULL, 0, NI_NUMERICHOST))
strlcpy(hbuf, "(invalid)", sizeof(hbuf));
diff --git a/usr.sbin/traceroute6/traceroute6.c b/usr.sbin/traceroute6/traceroute6.c
index f4a154d6b96..d5908e95d86 100644
--- a/usr.sbin/traceroute6/traceroute6.c
+++ b/usr.sbin/traceroute6/traceroute6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: traceroute6.c,v 1.90 2014/04/23 09:11:35 florian Exp $ */
+/* $OpenBSD: traceroute6.c,v 1.91 2014/04/23 09:13:00 florian Exp $ */
/* $KAME: traceroute6.c,v 1.63 2002/10/24 12:53:25 itojun Exp $ */
/*
@@ -544,10 +544,6 @@ main(int argc, char *argv[])
rcvmhdr.msg_control = (caddr_t) rcvcmsgbuf;
rcvmhdr.msg_controllen = rcvcmsglen;
- if (options & SO_DEBUG)
- (void) setsockopt(rcvsock, SOL_SOCKET, SO_DEBUG,
- (char *)&on, sizeof(on));
-
/*
* Send UDP or ICMP
*/
@@ -555,12 +551,6 @@ main(int argc, char *argv[])
close(sndsock);
sndsock = rcvsock;
}
- if (setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, (char *)&datalen,
- sizeof(datalen)) < 0)
- err(6, "SO_SNDBUF");
- if (options & SO_DEBUG)
- (void) setsockopt(sndsock, SOL_SOCKET, SO_DEBUG,
- (char *)&on, sizeof(on));
/*
* Source selection
@@ -602,6 +592,17 @@ main(int argc, char *argv[])
err(1, "getsockname");
srcport = ntohs(from6.sin6_port);
+ if (options & SO_DEBUG) {
+ (void) setsockopt(sndsock, SOL_SOCKET, SO_DEBUG,
+ (char *)&on, sizeof(on));
+ (void) setsockopt(rcvsock, SOL_SOCKET, SO_DEBUG,
+ (char *)&on, sizeof(on));
+ }
+
+ if (setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, (char *)&datalen,
+ sizeof(datalen)) < 0)
+ err(6, "SO_SNDBUF");
+
/*
* Message to users
*/