On Sat, May 20, 2023 at 02:46:27PM +0200, Claudio Jeker wrote:
> On Fri, May 19, 2023 at 07:58:47PM +0200, Jan Klemkow wrote:
> > Hi,
> > 
> > We use the wrong interface and mtu in tcp_mss() to calculate the mss if
> > the destination address points is a local address.  In ip_output() we
> > use the correct interface and its mtu.
> > 
> > This limits the mss to 1448 if the mtu of the interface it 1500,
> > instead of using a local 32k mss.
> > 
> > The bigger issue is: local bulk traffic with the current TSO
> > implementation is broken.  tcp_output() creates TSO packets with an mss
> > smaller then 32k and ip_output() calls if_output instead of
> > tcp_if_output_tso() because it fits into the mtu check of lo0.
> > 
> > This diff takes the same logic to pick the interface in tcp_mss() as its
> > done in ip_output() and fixes both issues.
> > 
> > ok?
> 
> I'm fine with this going in since it emulates the same behaviour as
> ip_output. For the curious ip6_output() seems to have the same workaround.

OK bluhm@

> Now in an ideal world the other issue exposed by this mtu mismatch should
> also be fixed. We had similar issues with TCP over loopback on multiple
> occasions. So maybe it is time to fix this for good.

Please wait before commiting your diff.  My "tcp tso loopback
checksum" on tech@ should be commited and tested first, so we see
whether that fixes the underlying problem.

> Note: In an ideal world lo(4) would do TSO and LRO since it bounces the
> packet right back at us.

I think we should try to implement lo(4) checksum offloading.  In
an ideal world, packets are marked with correct checksum over
loopback instead of calculating it twice.

Then sending large packets with TSO and receiving with LSO would
also be good.  It helps testing the feature.  But performance
improvemnet might be small as MTU is already 32768 for loopback.

bluhm

> > Index: netinet/tcp_input.c
> > ===================================================================
> > RCS file: /cvs/src/sys/netinet/tcp_input.c,v
> > retrieving revision 1.387
> > diff -u -p -r1.387 tcp_input.c
> > --- netinet/tcp_input.c     14 Mar 2023 00:24:05 -0000      1.387
> > +++ netinet/tcp_input.c     19 May 2023 17:22:47 -0000
> > @@ -2805,7 +2805,11 @@ tcp_mss(struct tcpcb *tp, int offer)
> >     if (rt == NULL)
> >             goto out;
> >  
> > -   ifp = if_get(rt->rt_ifidx);
> > +   if (ISSET(rt->rt_flags, RTF_LOCAL))
> > +           ifp = if_get(rtable_loindex(inp->inp_rtableid));
> > +   else
> > +           ifp = if_get(rt->rt_ifidx);
> > +
> >     if (ifp == NULL)
> >             goto out;
> >  
> > 
> 
> -- 
> :wq Claudio

Reply via email to