From owner-freebsd-bugs@FreeBSD.ORG Thu Sep 24 13:20:02 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 68795106566B for ; Thu, 24 Sep 2009 13:20:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 45C6F8FC15 for ; Thu, 24 Sep 2009 13:20:02 +0000 (UTC) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n8ODK1SX045404 for ; Thu, 24 Sep 2009 13:20:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n8ODK15F045403; Thu, 24 Sep 2009 13:20:01 GMT (envelope-from gnats) Resent-Date: Thu, 24 Sep 2009 13:20:01 GMT Resent-Message-Id: <200909241320.n8ODK15F045403@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Oleg Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5C201106568B for ; Thu, 24 Sep 2009 13:17:25 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 4B4598FC18 for ; Thu, 24 Sep 2009 13:17:25 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n8ODHPIX017911 for ; Thu, 24 Sep 2009 13:17:25 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id n8ODHOrc017910; Thu, 24 Sep 2009 13:17:24 GMT (envelope-from nobody) Message-Id: <200909241317.n8ODHOrc017910@www.freebsd.org> Date: Thu, 24 Sep 2009 13:17:24 GMT From: Oleg To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/139112: [ttcp] sockaddr_in.sin_family initialization, new option -S src_addr added. X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2009 13:20:02 -0000 >Number: 139112 >Category: bin >Synopsis: [ttcp] sockaddr_in.sin_family initialization, new option -S src_addr added. >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Sep 24 13:20:01 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Oleg >Release: FreeBSD 7.0 >Organization: Sunbay >Environment: >Description: Field sinme.sin_family doesn't initialized passed to bind, which failed. New parameter -S src_addr added. -s src_addr Set the source IP address for the ttcp connection to src_addr. >How-To-Repeat: phobos@amd64# ./ttcp -r -s ttcp-r: buflen=8192, nbuf=2048, align=16384/0, port=5001 tcp ttcp-r: socket ttcp-r: bind: Invalid argument errno=22 phobos@amd64# ./ttcp -t -s 127.0.0.1 ttcp-t: buflen=8192, nbuf=2048, align=16384/0, port=5001 tcp -> 127.0.0.1 ttcp-t: socket ttcp-t: bind: Invalid argument errno=22 >Fix: Patch attached with submission follows: --- ttcp.c 2009-09-24 15:54:25.000000000 +0300 +++ ttcp.c.patched 2009-09-24 15:55:38.000000000 +0300 @@ -99,6 +99,7 @@ int touchdata = 0; /* access data after reading */ struct hostent *addr; +in_addr_t src_addr; extern int errno; extern int optind; extern char *optarg; @@ -156,7 +157,7 @@ if (argc < 2) goto usage; - while ((c = getopt(argc, argv, "drstuvBDTb:f:l:n:p:A:O:")) != -1) { + while ((c = getopt(argc, argv, "drstuvBDTb:f:l:n:p:A:O:S:")) != -1) { switch (c) { case 'B': @@ -217,6 +218,9 @@ case 'T': touchdata = 1; break; + case 'S': + src_addr = inet_addr(optarg); + break; default: goto usage; @@ -249,12 +253,14 @@ #endif /* cray */ } sinhim.sin_port = htons(port); + sinme.sin_addr.s_addr = src_addr; sinme.sin_port = 0; /* free choice */ } else { /* rcvr */ sinme.sin_port = htons(port); } + sinme.sin_family = AF_INET; if (udp && buflen < 5) { buflen = 5; /* send more than the sentinel size */ >Release-Note: >Audit-Trail: >Unformatted: