fa.netbsd.tech.net
[Top] [All Lists]

Patch: move reassembly lock/unlock in tcp_input

Subject: Patch: move reassembly lock/unlock in tcp_input
From: Thor Lancelot Simon <tls@xxxxxxxxxxxxxxx>
Date: Wed, 30 Jul 2008 14:55:04 UTC
Newsgroups: fa.netbsd.tech.net

Using accept filters (still pending for commit to NetBSD) it's possible
to get into a situation in which tcp_input can generate a call to
tcp_output, on the same socket.

Surprisingly, this almost works.  The patch below avoids an attempt to
recursively take the TCP reassembly lock in this case, by moving its
acquisition/release in tcp_input to where it (appears to be) actually
needed (so that it is not held across a call to sorwakeup().

Comments?

diff -Naur
/home/coyote/perforce/equalizer/features/folsom/sys/netinet/tcp_input.c
netinet/tcp_input.c
--- /home/coyote/perforce/equalizer/features/folsom/sys/netinet/tcp_input.c
2008-07-11 18:14:31.000000000 +0530
+++ netinet/tcp_input.c 2008-07-25 13:02:51.000000000 +0530
@@ -2636,13 +2636,14 @@
                                m_adj(m, hdroptlen);
                                sbappendstream(&(so)->so_rcv, m);
                        }
+                       TCP_REASS_UNLOCK(tp);
                        sorwakeup(so);
                } else {
                        m_adj(m, hdroptlen);
                        tiflags = tcp_reass(tp, th, m, &tlen);
                        tp->t_flags |= TF_ACKNOW;
+                       TCP_REASS_UNLOCK(tp);
                }
-               TCP_REASS_UNLOCK(tp);

                /*
                 * Note the amount of data that peer has sent into

<Prev in Thread] Current Thread [Next in Thread>
  • Patch: move reassembly lock/unlock in tcp_input, Thor Lancelot Simon <=