Open and close clat bpf map while clat is starting and stoping

BpfMap class supports AutoCloseable interface which closes
file descriptor only in try-exit. BpfMap class doesn't close
fds while the object is released.

Change the timing of opening and closing bpf map file descriptors
to clat is starting and stoping.

Moreover, the reason that manual close BPF map file descriptors is
as follows. Just don't rely on that GC releasing to close the file
descriptors even if class BpfMap supports close file descriptor in
finalize(). If the interfaces are added and removed quickly, too
many unclosed file descriptors may cause unexpected problems.

Bug: 230880517
Test: manual test
Steps:
1. Connect to IPv6 only wifi (GoogleGuest) and mobile data
2. Check that map fds are appeared:
   /proc/$(system_server_pid)/fd/$(bpf_map_fd)

$ adb shell ps | grep system_server
system        1929   825 20311224 730060 do_epoll_wait      0 S system_server

$ adb shell ls -all proc/1929/fd | grep bpf-map
.. system system 64 2022-05-05 13:36:42 .. 331 -> anon_inode:bpf-map
.. system system 64 2022-05-05 13:36:42 .. 348 -> anon_inode:bpf-map

3. Check the clat maps are added.
$ adb shell dumpsys connectivity
NetworkAgentInfo{network{105}  handle{454377263117}  ni{WIFI ..
Nat464Xlat:
..
  Forwarding rules:
    BPF ingress map: iif nat64Prefix v6Addr -> v4Addr oif
      47 /64:ff9b::/96 /2a00:79e1:abc:6f02:f182:6c29:ab56:9961 -> /192.0.0.4 62
    BPF egress map: iif v4Addr -> v6Addr nat64Prefix oif
      62 /192.0.0.4 -> /2a00:79e1:abc:6f02:f182:6c29:ab56:9961 /64:ff9b::/96 47 ether
NetworkAgentInfo{network{106}  handle{458672230413}  ni{MOBILE[LTE] ..
    Nat464Xlat:
      <not start>

4. Disconnect from wifi

5. Check that map fds are disappeared:
   /proc/$(system_server_pid)/fd/$(bpf_map_fd)

$ adb shell ls -all proc/1929/fd | grep bpf-map
(fd 331 and 348 were not found)

Change-Id: I60c0301bf00beae5cf5ab3535c6a3da68a2a4a9b
2 files changed