From owner-freebsd-net@freebsd.org Thu May 31 09:56:17 2018 Return-Path: Delivered-To: freebsd-net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 71FF0EFB7C0 for ; Thu, 31 May 2018 09:56:17 +0000 (UTC) (envelope-from borjam@sarenet.es) Received: from cu01176b.smtpx.saremail.com (cu01176b.smtpx.saremail.com [195.16.151.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0822A7B5D3 for ; Thu, 31 May 2018 09:56:16 +0000 (UTC) (envelope-from borjam@sarenet.es) Received: from [172.16.8.141] (unknown [192.148.167.11]) by proxypop01.sare.net (Postfix) with ESMTPA id 365659DD388 for ; Thu, 31 May 2018 11:47:27 +0200 (CEST) From: Borja Marcos Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 11.3 \(3445.6.18\)) Subject: Setting MSS with setsockopt TCP_MAXSEG Message-Id: Date: Thu, 31 May 2018 11:47:26 +0200 To: freebsd-net@freebsd.org X-Mailer: Apple Mail (2.3445.6.18) X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 May 2018 09:56:17 -0000 Hi, I was trying changing the MSS for outgoing TCP connections and I=E2=80=99v= e found out that it doesn=E2=80=99t work.=20 There is an old bug report marked as =E2=80=9Cfixed=E2=80=9D but it = seems that the bug is still there or it resurfaced. https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D144000 Moreover, I have found that the behavior of setsockopt with TCP_MAXSEG = is quite erratic, returning =E2=80=9CInvalid Argument=E2=80=9D for no apparent reason. What I am doing is: socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) setsockopt(TCP_MAXSEG, mss) connect() If I run this on FreeBSD or Mac OS X I get this when specifying a MSS of = 500: # tcpdump -i bge0 -s 0 -vv tcp port 7 tcpdump: listening on bge0, link-type EN10MB (Ethernet), capture size = 262144 bytes 11:35:58.190148 IP (tos 0x0, ttl 64, id 23840, offset 0, flags [none], = proto TCP (6), length 60) 192.168.1.202.39340 > 192.168.1.205.echo: Flags [S], cksum 0x9012 = (correct), seq 1054345346, win 65535, options [mss 1460,nop,wscale = 8,sackOK,TS val 850534213 ecr 0], length 0 I tried disabling MTU discovery (sysctl = net.inet.tcp.path_mtu_discovery=3D0) just in case it interfered but the = result is the same.=20 Curiously, on FreeBSD I get =E2=80=9Cinvalid argumenr=E2=80=9D errors if = I try a MSS value greater than net.inet.tcp.mssdflt.=20 % ./tcpmss 192.168.1.205 7 535 Setting MSS to 535 Done ^C % ./tcpmss 192.168.1.205 7 536 Setting MSS to 536 Done ^C % ./tcpmss 192.168.1.205 7 537 Setting MSS to 537 setsockopt(): Invalid argument %=20 Running the same on Linux it works. Here I have set the MSS to 100.=20 11:39:14.223116 IP (tos 0x0, ttl 64, id 18798, offset 0, flags [DF], = proto TCP (6), length 60) 192.168.1.194.46698 > 192.168.1.205.echo: Flags [S], cksum 0xce33 = (correct), seq 17987680, win 43600, options [mss 100,sackOK,TS val = 960030412 ecr 0,nop,wscale 10], length 0 Is the bug back or am I terribly wrong?=20 Thanks! Borja.