rtsock: Make sysctl NET_RT_DUMP MPSAFE.
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Mon, 9 Mar 2015 14:28:15 +0000 (22:28 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 13 Mar 2015 01:43:35 +0000 (09:43 +0800)
commit291dd55bdc005bdc5191983b74c294c6090cb925
treeff00e5f1e11460e822f52e3ff768d19a5242043e
parentcfa126b26bccf2f2425bdefd5fd31780bcca0a2e
rtsock: Make sysctl NET_RT_DUMP MPSAFE.

- Add rn_walktree_at(), which walks the radix tree from a target node,
  if it could be found, or from the closest node of the target node.
- Allocate temporary buffer for rtm batch, which should be large enough
  for duplicated keys.  We could consider reallocate it if there are
  any real cases that this temporary buffer could not hold rtms for all
  duplicated keys.  In the current implementation, it just logs one
  error and stop.
- Convert the rtentries to rtms in temporary buffer in netisr; unlike
  what we do for inpcbs, routing table could be in inconsistent state
  (due to blocking malloc), if we are not accessing the routing table
  in netisr.  If there is no more space in the temporary buffer, the
  current rtentry's key and netmask are saved and we will start from it
  next time.  Since rn_walktree_at() only starts from the first node of
  duplicated keys, we have to make sure that there is enough space for
  all duplicated keys in the temoprary buffer.
- Once the temporary buffer can't hold more rtms, the rtms in it will
  be delivered to userland.  And we start converting the rtentries in
  netisr from the last node again, until all rtentries are iterated.
sys/net/radix.c
sys/net/radix.h
sys/net/rtsock.c