ip_forward: Don't cache IP forwarding route.
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 26 Mar 2009 12:57:19 +0000 (20:57 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 26 Mar 2009 12:57:19 +0000 (20:57 +0800)
commit984322d132f10d865d17b7417ba433f018db4d55
tree42f905bd2deca3eb4d3ed7b1e03594049140ca7a
parent75a5634ed2af3470bae431313d4813daf8ff1de9
ip_forward: Don't cache IP forwarding route.

There are two problems with this cached route:
- Any newly created route will nuke this cached route.  If any new
  route was created when the ip_output() was put to sleep due to
  contention on the output path, then the rtentry of this cached
  route would be ripped away behind our back.
  The reported panic was caused by this problem.  The call path:
  ip_forward()->ip_output()->ipflow_create(); the cached route was
  ripped before ipflow_create() was called.
- All network threads on the same CPU share this cached route:
  o  Network thread1 and network thread2 are on the same CPU
  o  Network thread1 uses this cached route to do the ip_output()
  o  Network thread1 is put to sleep due to contention on the
     output path
  o  Network thread2 uses this cached route to do the ip_output()
  o  Now network thread1 was scheduled ...

If we ever want to cached previously used route, we will have to
use per-thread route cache.
sys/netinet/in_rmx.c
sys/netinet/ip_input.c
sys/netinet/ip_var.h