radix: Fix the non-per-cpu radix tree usage.
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 1 Feb 2011 08:09:26 +0000 (16:09 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 1 Feb 2011 08:09:26 +0000 (16:09 +0800)
commitb4628cf91a5f54965e6a4221f243e315aa7a6860
tree5701fa3ca31f7ae00b4c4a6fcb3795bb9c9f7167
parentbd52bedfc1ee463fcac536b3095817ff4400c191
radix: Fix the non-per-cpu radix tree usage.

- Install a mask radix tree in each radix tree, while, mask radix tree does
  not have mask radix tree (of course).
- rn_cpumaskhead() is added to provide the global per-cpu mask radix tree.
- rn_inithead() requires a mask radix tree as paramter.  Mask radix tree is
  initialized by passing NULL.  INET/INET6/ATALK pass the mask radix tree
  obtained from rn_cpumaskhead(), i.e. the old sementics.
- pf(4) now creates its own mask radix tree, and all of its internal radix
  trees will use that mask radix tree instead of the global per-cpu mask
  radix tree.  pf(4) radix tree operations are protected by its own token.
- rn_addmask() requires a mask radix tree, instead of using the global
  per-cpu mask radix tree.  For most cases, the caller has access to the
  radix tree that has a mask radix tree installed.  For _rtmask_lookup(),
  which is always called from route_output(), we could safely assume that
  global per-cpu mask radix tree is used.

This is mainly used to fix the following bug concerning global per-cpu
mask radix tree:
Before this commit, pf(4) could create mask on CPU0's mask radix tree,
while the deletion of the mask happens on other CPUs, which results pf(4)'s
radix tree operation to fail (can't locate the mask).

Dragonfly-bug: http://bugs.dragonflybsd.org/issue1969
Root-cause-found-by: Jan Lentfer <Jan.Lentfer@web.de>
sys/net/pf/pf.c
sys/net/pf/pf_ioctl.c
sys/net/pf/pf_table.c
sys/net/pf/pfvar.h
sys/net/radix.c
sys/net/radix.h
sys/net/route.c
sys/netinet/in_rmx.c
sys/netinet6/in6_rmx.c
sys/netproto/atalk/at_rmx.c