Further speed up creating child chains.

Currently createChildChain creates and adds child chains by using
-F -X -N and -A iptables commands. This guarantees that the child
chains are emtpy.  are guaranteed to be empty. Therefore, it is
safe to create all the child chains with a single
iptables-restore command that flushes all the child chains and
appends them to the parent chain.

This makes it possible to create chains quickly even if the
parent chain is touched by vendor code and thus cannot be safely
flushed.

This substantially speeds up netd startup. Before:
02-03 12:52:47.786   492   492 I Netd    : Creating child chains: 1543.5ms
02-03 12:52:48.103   492   492 I Netd    : Netd started in 1929ms

After:
02-03 12:51:46.831   511   511 I Netd    : Creating child chains: 672.5ms
02-03 12:51:47.244   511   511 I Netd    : Netd started in 1115ms

Test: builds, boots
Test: before/after comparison shows no expected rule changes
Bug: 34873832
Change-Id: I88f4e539d727e3b542cf6f8acd61728cadda972f
1 file changed
tree: efecc50392ce86f06647ef5a9ba9652471e44f9f
  1. client/
  2. include/
  3. server/
  4. tests/
  5. Android.mk
  6. MODULE_LICENSE_APACHE2
  7. NOTICE