Subject: Re: TCP MSS configuration
To: None <tech-net@netbsd.org, netbsd-help@netbsd.org>
From: None <amitg@hss.hns.com>
List: netbsd-help
Date: 07/12/2003 20:27:43
Hi All,
I need to configure the TCP MSS on a netbsd router. My requirement is that
1. Either i want to configure the TCP MSS value from some ioctl and then
use that integer value later
2. or i want to configure that MSS is calculated form the interface mtu
and
then use that further on.
Coudl anyone pls put some light over this ??
First i came to know that by setting tcp.mss_if_mtu to 1 will fufill my 2nd
requirement. But with that also i have some doubt
Acc to that method, there is no direct computation of the MSS on the basis
of tcp_if_mut. The MSS is computed from the interface mtu only and in the
last max value of the def MSS or mss from if_mtu is returned back.
By using the tcp_if_mtu, the check is made from for max value in the if_mtu
and the in_ifmtu value. Could you pls elaborate bit more.
I am attaching the code for that method below for your refrence.
u_long
tcp_mss_to_advertise(ifp, af)
const struct ifnet *ifp;
int af;
{
extern u_long in_maxmtu;
u_long mss = 0;
u_long hdrsiz;
/*
* In order to avoid defeating path MTU discovery on the peer,
* we advertise the max MTU of all attached networks as our MSS,
* per RFC 1191, section 3.1.
*
* We provide the option to advertise just the MTU of
* the interface on which we hope this connection will
* be receiving. If we are responding to a SYN, we
* will have a pretty good idea about this, but when
* initiating a connection there is a bit more doubt.
*
* We also need to ensure that loopback has a large enough
* MSS, as the loopback MTU is never included in in_maxmtu.
*/
if (ifp != NULL)
switch (af) {
case AF_INET:
mss = ifp->if_mtu;
break;
#ifdef INET6
case AF_INET6:
mss = IN6_LINKMTU(ifp);
break;
#endif
}
if (tcp_mss_ifmtu == 0)
switch (af) {
case AF_INET:
mss = max(in_maxmtu, mss);
break;
#ifdef INET6
case AF_INET6:
mss = max(in6_maxmtu, mss);
break;
#endif
}
switch (af) {
case AF_INET:
hdrsiz = sizeof(struct ip);
break;
#ifdef INET6
case AF_INET6:
hdrsiz = sizeof(struct ip6_hdr);
break;
#endif
default:
hdrsiz = 0;
break;
}
hdrsiz += sizeof(struct tcphdr);
if (mss > hdrsiz)
mss -= hdrsiz;
mss = max(tcp_mssdflt, mss);
return (mss);
}
regards
- amit