Skip adding ingress discard rule to OEM VPN

OEM VPNs might need to receive packets to VPN address via
non-VPN interface.

Bug: 352424251
Test: CsIngressDiscardRuleTest
Change-Id: Ia9000bcbb5b3b9e1e0d396ba78946be36e2fc5ba
This commit is contained in:
Motomu Utsumi 2024-08-06 19:00:22 +09:00
commit c14288f7c7

View file

@ -9672,10 +9672,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
* interfaces.
* Ingress discard rule is added to the address iff
* 1. The address is not a link local address
* 2. The address is used by a single non-Legacy VPN interface and not used by any other
* interfaces even non-VPN ones
* Ingress discard rule is not be added to Legacy VPN since some Legacy VPNs need to receive
* packet to VPN address via non-VPN interface.
* 2. The address is used by a single interface of VPN whose VPN type is not TYPE_VPN_LEGACY
* or TYPE_VPN_OEM and the address is not used by any other interfaces even non-VPN ones
* Ingress discard rule is not be added to TYPE_VPN_LEGACY or TYPE_VPN_OEM VPN since these VPNs
* might need to receive packet to VPN address via non-VPN interface.
* This method can be called during network disconnects, when nai has already been removed from
* mNetworkAgentInfos.
*
@ -9710,8 +9710,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
// for different network.
final Set<Pair<InetAddress, String>> ingressDiscardRules = new ArraySet<>();
for (final NetworkAgentInfo agent : nais) {
final int vpnType = getVpnType(agent);
if (!agent.isVPN() || agent.isDestroyed()
|| getVpnType(agent) == VpnManager.TYPE_VPN_LEGACY) {
|| vpnType == VpnManager.TYPE_VPN_LEGACY
|| vpnType == VpnManager.TYPE_VPN_OEM) {
continue;
}
final LinkProperties agentLp = (nai == agent) ? lp : agent.linkProperties;