tcp: Fix upper half (socket code) and so_port switching race.
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 10 Aug 2014 12:22:12 +0000 (20:22 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 10 Aug 2014 12:35:10 +0000 (20:35 +0800)
commitcfc92b211902c0623f72da35d19127eb281f9ffe
treeebd89e903ec26cc9e8f6d56182e8c0a92db89826
parentac6c441c1eb77d0c183254c94adaa31dfcdbed55
tcp: Fix upper half (socket code) and so_port switching race.

Use message put done receipt to change this socket's so_port, i.e. _after_
this message was put onto the target netisr's msgport but _before_ the
message could be pulled from the target netisr's msgport, so that:
- The upper half (socket code) will not see the new msgport before this
  message reaches the new msgport and messages for this socket will be
  ordered.
- This message will see the new msgport, when its handler is called in the
  target netisr.

Add comment about it and explain why the so_port switching should be done
in this commit's fashion.

Reported-by: dillon@
sys/netinet/tcp_usrreq.c