-.\" $OpenBSD: tcpbench.1,v 1.28 2020/05/04 12:13:09 sthen Exp $
+.\" $OpenBSD: tcpbench.1,v 1.29 2021/02/04 18:46:25 bluhm Exp $
.\"
.\" Copyright (c) 2008 Damien Miller <djm@mindrot.org>
.\"
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: May 4 2020 $
+.Dd $Mdocdate: February 4 2021 $
.Dt TCPBENCH 1
.Os
.Sh NAME
.Nm
.Fl l
.Nm
-.Op Fl 46RUuv
+.Op Fl 46DRUuv
.Op Fl B Ar buf
.Op Fl b Ar sourceaddr
.Op Fl k Ar kvars
.Nm
.Bk -words
.Fl s
-.Op Fl 46Uuv
+.Op Fl 46DUuv
.Op Fl B Ar buf
.Op Fl k Ar kvars
.Op Fl p Ar port
.It Fl b Ar sourceaddr
Specify the IP address to send the packets from,
which is useful on machines with multiple interfaces.
+.It Fl D
+Enable debugging on the socket.
.It Fl k Ar kvars
Specify one or more kernel variables to monitor; multiple variables must be
separated with commas.
-/* $OpenBSD: tcpbench.c,v 1.63 2020/05/04 12:13:09 sthen Exp $ */
+/* $OpenBSD: tcpbench.c,v 1.64 2021/02/04 18:46:25 bluhm Exp $ */
/*
* Copyright (c) 2008 Damien Miller <djm@mindrot.org>
/* Our tcpbench globals */
struct {
+ int Dflag; /* Socket debug */
int Sflag; /* Socket buffer size */
u_int rflag; /* Report rate (ms) */
int sflag; /* True if server */
{
fprintf(stderr,
"usage: tcpbench -l\n"
- " tcpbench [-46RUuv] [-B buf] [-b sourceaddr] [-k kvars] [-n connections]\n"
+ " tcpbench [-46DRUuv] [-B buf] [-b sourceaddr] [-k kvars] [-n connections]\n"
" [-p port] [-r interval] [-S space] [-T toskeyword]\n"
" [-t secs] [-V rtable] hostname\n"
- " tcpbench -s [-46Uuv] [-B buf] [-k kvars] [-p port] [-r interval]\n"
+ " tcpbench -s [-46DUuv] [-B buf] [-k kvars] [-p port] [-r interval]\n"
" [-S space] [-T toskeyword] [-V rtable] [hostname]\n");
exit(1);
}
warn("socket");
continue;
}
+ if (ptb->Dflag) {
+ if (setsockopt(sock, SOL_SOCKET, SO_DEBUG,
+ &ptb->Dflag, sizeof(ptb->Dflag)))
+ err(1, "setsockopt SO_DEBUG");
+ }
if (ptb->Tflag != -1 && ai->ai_family == AF_INET) {
if (setsockopt(sock, IPPROTO_IP, IP_TOS,
&ptb->Tflag, sizeof(ptb->Tflag)))
warn("socket");
continue;
}
+ if (ptb->Dflag) {
+ if (setsockopt(sock, SOL_SOCKET, SO_DEBUG,
+ &ptb->Dflag, sizeof(ptb->Dflag)))
+ err(1, "setsockopt SO_DEBUG");
+ }
if (aib != NULL) {
saddr_ntop(aib->ai_addr, aib->ai_addrlen,
tmp, sizeof(tmp));
setvbuf(stdout, NULL, _IOLBF, 0);
ptb = &tcpbench;
ptb->dummybuf_len = 0;
+ ptb->Dflag = 0;
ptb->Sflag = ptb->sflag = ptb->vflag = ptb->Rflag = ptb->Uflag = 0;
ptb->kvmh = NULL;
ptb->kvars = NULL;
aib = NULL;
secs = 0;
- while ((ch = getopt(argc, argv, "46b:B:hlk:n:p:Rr:sS:t:T:uUvV:")) != -1) {
+ while ((ch = getopt(argc, argv, "46b:B:Dhlk:n:p:Rr:sS:t:T:uUvV:"))
+ != -1) {
switch (ch) {
case '4':
family = PF_INET;
case 'b':
srcbind = optarg;
break;
+ case 'D':
+ ptb->Dflag = 1;
+ break;
case 'l':
list_kvars();
exit(0);