Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 May 2018 11:47:26 +0200
From:      Borja Marcos <borjam@sarenet.es>
To:        freebsd-net@freebsd.org
Subject:   Setting MSS with setsockopt TCP_MAXSEG
Message-ID:  <A953171C-7A2B-4779-8E23-41AF8AEBF3A5@sarenet.es>

next in thread | raw e-mail | index | archive | help

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.








Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?A953171C-7A2B-4779-8E23-41AF8AEBF3A5>