# FIN Flood on loopback interface



## ssanders47 (Feb 13, 2013)

Anyone heard of this?

Client and server are connected using TCP across the loopback interface.  Both sides of the connection set their socket option buffer size to 64KB and SO_LINGER is set to 3 seconds.  Data is transferred (< 1MB) and the connection is closed from the sever side.

The server side socket goes into a FIN WAIT 1 state and begins sending FINs, receives a FIN/ACK, and then sends FIN again with no time delay.  

Since it received the FIN/ACK, the socket should be shutdown.  However, the server socket continues to hammer the TCP stack for minimally 5 minutes and maximally 12 hours.

[intr] goes to 100%+ cpu and *procstat -kk* shows netisr is continually running.

We collected the traces using tcpdump on lo0.

We found that if you don't change the socket buffer size, everything appears to be OK.

Thanks


----------



## markj (Feb 14, 2013)

As it happens, I'm trying to track down an issue which sounds pretty much identical to yours. In my case both sides seem to go into FIN-WAIT-1 and start continuously sending FIN/ACKs to each other.

At the moment I can't actually reproduce it - I've only been able to see it in action by monitoring the TCP control packet counts on my machines and starting a capture when they start to jump. We do use a non-standard socket buffer size too, but it's set system-wide rather than per-socket. Based on my captures and on your description, I've been trying to trigger the issue with a little program at http://people.freebsd.org/~markj/simulclose but I haven't had any luck so far. Do you have anything you can post which triggers the problem? If I can get it happening reliably I'm fairly confident I can track down the root cause of the problem.


----------



## ssanders47 (Feb 15, 2013)

The only thing I've got at the moment is a really large application.  I'll see what I can do to get something that can be used as a test program together. It might take a few days though.

Thanks


----------



## markj (Feb 15, 2013)

Thanks. I'll let you know if I get anywhere with this.

What FreeBSD version are you using by the way? I'm on an 8.2 derivative.


----------



## markj (Feb 16, 2013)

I eventually found r239672, which sounds like it should fix the problem:

http://lists.freebsd.org/pipermail/svn-src-all/2012-August/057706.html

I've patched a few kernels on machines which were exhibiting the problem and haven't seen any FIN storms yet.


----------



## ssanders47 (Feb 18, 2013)

Outstanding!  I will try this on one of our systems as soon as possible.

We're using 8.1 at the moment.

Thanks


----------

