From owner-freebsd-bugs@FreeBSD.ORG Tue Feb 16 12:20:03 2010 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 222D21065672 for ; Tue, 16 Feb 2010 12:20:03 +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 D8D2A8FC18 for ; Tue, 16 Feb 2010 12:20:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id o1GCK2o7021048 for ; Tue, 16 Feb 2010 12:20:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id o1GCK2dk021047; Tue, 16 Feb 2010 12:20:02 GMT (envelope-from gnats) Resent-Date: Tue, 16 Feb 2010 12:20:02 GMT Resent-Message-Id: <201002161220.o1GCK2dk021047@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, Andrey Zonov Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9732B1065670 for ; Tue, 16 Feb 2010 12:17:29 +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 7BDD28FC16 for ; Tue, 16 Feb 2010 12:17:29 +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 o1GCHT3m094784 for ; Tue, 16 Feb 2010 12:17:29 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o1GCHTmx094783; Tue, 16 Feb 2010 12:17:29 GMT (envelope-from nobody) Message-Id: <201002161217.o1GCHTmx094783@www.freebsd.org> Date: Tue, 16 Feb 2010 12:17:29 GMT From: Andrey Zonov To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/144000: [tcp] ignore set TCP_MAXSEG by setsockopt() 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: Tue, 16 Feb 2010 12:20:03 -0000 >Number: 144000 >Category: kern >Synopsis: [tcp] ignore set TCP_MAXSEG by setsockopt() >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Feb 16 12:20:02 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Andrey Zonov >Release: 7.2-STABLE, 8.0-STABLE >Organization: >Environment: >Description: After reading Stevens and man 4 tcp, i trying to set mss for connections by setsockopt(TCP_MAXSEG), but it's not worked for me. In Linux it's work fine. >How-To-Repeat: Compile test programs and look into tcpdump. >Fix: Patch attached with submission follows: #include #include #include #include #include #include #include #include #include #include static char buf[] = "test echo"; int main(void) { int s, maxseg; struct sockaddr_in serv; bzero(&serv, sizeof(serv)); serv.sin_family = AF_INET; serv.sin_port = htons(5555); inet_pton(AF_INET, "localhost", &serv.sin_addr); s = socket(AF_INET, SOCK_STREAM, 0); maxseg = 300; if (setsockopt(s, IPPROTO_TCP, TCP_MAXSEG, (const void *) &maxseg, sizeof(maxseg)) != 0) { err(1, "setsockopt():"); } if ((connect(s, (const struct sockaddr *) &serv, sizeof(serv))) == 0) { write(s, buf, 9); } close(s); exit(0); } #include #include #include #include #include #include #include #define SIZE 4096 int main(void) { int s, s1, r; char buf[SIZE]; struct sockaddr_in sin; s = socket(AF_INET, SOCK_STREAM, 0); bzero(&sin, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_port = htons(5555); bind(s, (const struct sockaddr *)&sin, sizeof(sin)); listen(s, -1); s1 = accept(s, (struct sockaddr *) NULL, NULL); while ((r = read(s1, buf, SIZE)) > 0) { write(s1, buf, r); } close(s1); exit(0); } # tcpdump -pni lo0 port 5555 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on lo0, link-type NULL (BSD loopback), capture size 96 bytes 15:05:57.371757 IP 127.0.0.1.39043 > 127.0.0.1.5555: Flags [S], seq 2639122865, win 65535, options [mss 16344,nop,wscale 3,sackOK,TS val 27362 ecr 0], length 0 15:05:57.371900 IP 127.0.0.1.5555 > 127.0.0.1.39043: Flags [S.], seq 1718559353, ack 2639122866, win 65535, options [mss 16344,nop,wscale 3,sackOK,TS val 604177474 ecr 27362], length 0 15:05:57.371902 IP 127.0.0.1.39043 > 127.0.0.1.5555: Flags [.], ack 1, win 8960, options [nop,nop,TS val 27362 ecr 604177474], length 0 15:05:57.372005 IP 127.0.0.1.39043 > 127.0.0.1.5555: Flags [P.], ack 1, win 8960, options [nop,nop,TS val 27362 ecr 604177474], length 9 15:05:57.372081 IP 127.0.0.1.39043 > 127.0.0.1.5555: Flags [F.], seq 10, ack 1, win 8960, options [nop,nop,TS val 27362 ecr 604177474], length 0 15:05:57.372104 IP 127.0.0.1.5555 > 127.0.0.1.39043: Flags [.], ack 11, win 8958, options [nop,nop,TS val 604177474 ecr 27362], length 0 15:05:57.372263 IP 127.0.0.1.5555 > 127.0.0.1.39043: Flags [P.], ack 11, win 8960, options [nop,nop,TS val 604177474 ecr 27362], length 9 15:05:57.372265 IP 127.0.0.1.39043 > 127.0.0.1.5555: Flags [R], seq 2639122876, win 0, length 0 >Release-Note: >Audit-Trail: >Unformatted: