summaryrefslogtreecommitdiff
path: root/usr.bin/tcpbench
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2009-08-13 14:19:44 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2009-08-13 14:19:44 +0000
commited6eacbf8749cc005185039370dd6f5203959f2a (patch)
tree0bc9142f52163c8f3a8badc466df9d43cec9ac99 /usr.bin/tcpbench
parenteedcbaee459596630d9ae1cbc0f0a169b0424116 (diff)
Allow tcpbench to bind to a different rdomain.
OK sthen, djm and maybe more
Diffstat (limited to 'usr.bin/tcpbench')
-rw-r--r--usr.bin/tcpbench/tcpbench.19
-rw-r--r--usr.bin/tcpbench/tcpbench.c25
2 files changed, 29 insertions, 5 deletions
diff --git a/usr.bin/tcpbench/tcpbench.1 b/usr.bin/tcpbench/tcpbench.1
index 50a9b6277cc..a525db6e595 100644
--- a/usr.bin/tcpbench/tcpbench.1
+++ b/usr.bin/tcpbench/tcpbench.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tcpbench.1,v 1.5 2008/06/26 07:05:56 jmc Exp $
+.\" $OpenBSD: tcpbench.1,v 1.6 2009/08/13 14:19:43 claudio Exp $
.\"
.\" Copyright (c) 2008 Damien Miller <djm@mindrot.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: June 26 2008 $
+.Dd $Mdocdate: August 13 2009 $
.Os
.Dt TCPBENCH 1
.Sh NAME
@@ -31,6 +31,7 @@
.Op Fl p Ar port
.Op Fl r Ar rate
.Op Fl S Ar space
+.Op Fl V Ar rdomain
.Ar hostname
.Nm
.Fl s
@@ -40,6 +41,7 @@
.Op Fl p Ar port
.Op Fl r Ar rate
.Op Fl S Ar space
+.Op Fl V Ar rdomain
.Sh DESCRIPTION
.Nm
is a small tool that performs throughput benchmarking and concurrent
@@ -94,6 +96,9 @@ Place
.Nm
in server mode, where it will listen on all interfaces for incoming
connections.
+.It Fl V Ar rdomain
+Set the routing domain.
+The default is 0.
.It Fl v
Display verbose output.
If specified more than once, increase the detail of information displayed.
diff --git a/usr.bin/tcpbench/tcpbench.c b/usr.bin/tcpbench/tcpbench.c
index d808c8428dd..41ee20bda83 100644
--- a/usr.bin/tcpbench/tcpbench.c
+++ b/usr.bin/tcpbench/tcpbench.c
@@ -54,6 +54,8 @@
sig_atomic_t done = 0;
sig_atomic_t print_stats = 0;
+u_int rdomain;
+
struct statctx {
struct timeval t_start, t_last, t_cur;
unsigned long long bytes;
@@ -113,10 +115,10 @@ usage(void)
fprintf(stderr,
"usage: tcpbench -l\n"
" tcpbench [-v] [-B buf] [-k kvars] [-n connections]"
- " [-p port] [-r rate]\n"
+ " [-p port] [-r rate] [-V rdomain]\n"
" [-S space] hostname\n"
" tcpbench -s [-v] [-B buf] [-k kvars] [-p port] [-r rate]"
- " [-S space]\n");
+ " [-S space] [-V rdomain]\n");
exit(1);
}
@@ -500,6 +502,11 @@ serverloop(kvm_t *kvmh, u_long ktcbtab, struct addrinfo *aitop,
warn("socket");
continue;
}
+ if (rdomain && ai->ai_family == AF_INET) {
+ if (setsockopt(sock, IPPROTO_IP, SO_RDOMAIN,
+ &rdomain, sizeof(rdomain)) == -1)
+ err(1, "setsockopt SO_RDOMAIN");
+ }
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
&on, sizeof(on)) == -1)
warn("reuse port");
@@ -646,6 +653,11 @@ clientloop(kvm_t *kvmh, u_long ktcbtab, const char *host, const char *port,
warn("socket");
continue;
}
+ if (rdomain && ai->ai_family == AF_INET) {
+ if (setsockopt(sock, IPPROTO_IP, SO_RDOMAIN,
+ &rdomain, sizeof(rdomain)) == -1)
+ err(1, "setsockopt SO_RDOMAIN");
+ }
if (Sflag) {
if (setsockopt(sock, SOL_SOCKET, SO_SNDBUF,
&Sflag, sizeof(Sflag)) == -1)
@@ -757,7 +769,7 @@ main(int argc, char **argv)
struct nlist nl[] = { { "_tcbtable" }, { "" } };
- while ((ch = getopt(argc, argv, "B:hlk:n:p:r:sS:v")) != -1) {
+ while ((ch = getopt(argc, argv, "B:hlk:n:p:r:sS:vV:")) != -1) {
switch (ch) {
case 'l':
list_kvars();
@@ -798,6 +810,13 @@ main(int argc, char **argv)
case 'v':
vflag++;
break;
+ case 'V':
+ rdomain = (unsigned int)strtonum(optarg, 0,
+ RT_TABLEID_MAX, &errstr);
+ if (errstr)
+ errx(1, "rdomain value is %s: %s",
+ errstr, optarg);
+ break;
case 'n':
nconn = strtonum(optarg, 0, 65535, &errstr);
if (errstr != NULL)