In short, the Android VPNService that protects fd, runs on policy routing, all packets pass through protected fd , will be marked with a special fwmark , all packets with this fwmark will bypass the VPN.
Key code snippets listed below:
And an example of a routing policy after enabling an application with a VPN service:
root@CP8692 :/ # ip rule 0: from all lookup local 10000: from all fwmark 0xc0000/0xd0000 lookup legacy_system 11000: from all iif tun0 lookup local_network 12000: from all fwmark 0xc0072/0xcffff lookup tun0 12000: from all fwmark 0x0/0x20000 uidrange 0-99999 lookup tun0 13000: from all fwmark 0x10063/0x1ffff lookup local_network 13000: from all fwmark 0x10071/0x1ffff lookup wlan0 13000: from all fwmark 0x10072/0x1ffff uidrange 0-0 lookup tun0 13000: from all fwmark 0x10072/0x1ffff uidrange 0-99999 lookup tun0 14000: from all oif wlan0 lookup wlan0 14000: from all oif tun0 uidrange 0-99999 lookup tun0 15000: from all fwmark 0x0/0x10000 lookup legacy_system 16000: from all fwmark 0x0/0x10000 lookup legacy_network 17000: from all fwmark 0x0/0x10000 lookup local_network 19000: from all fwmark 0x71/0x1ffff lookup wlan0 21000: from all fwmark 0x72/0x1ffff lookup wlan0 22000: from all fwmark 0x0/0xffff lookup wlan0 23000: from all fwmark 0x0/0xffff uidrange 0-0 lookup main 32000: from all unreachable
source share