Commit 263547a1 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 7802884 from f90e9055 to mainline-tzdata3-release

Change-Id: Ic1bca58aa5e47d8577a5f84430a9efbcb91a6b77
parents fc6b434a f90e9055
......@@ -214,8 +214,8 @@ java_defaults {
libs: ["unsupportedappusage"],
static_libs: [
"androidx.annotation_annotation",
"modules-utils-build_system",
"netd_aidl_interface-lateststable-java",
"netlink-client",
"networkstack-client",
"net-utils-framework-common",
// See note on statsprotos when adding/updating proto build rules
......@@ -223,6 +223,7 @@ java_defaults {
"statsprotos",
"captiveportal-lib",
"net-utils-device-common",
"net-utils-device-common-netlink",
],
plugins: ["java_api_finder"],
}
......@@ -278,6 +279,7 @@ filegroup {
visibility: [
"//packages/modules/NetworkStack/tests/unit",
"//packages/modules/NetworkStack/tests/integration",
"//packages/modules/Connectivity/tests:__subpackages__",
"//packages/modules/Connectivity/Tethering/tests/integration",
]
}
......
......@@ -21,6 +21,7 @@
android:sharedUserId="android.uid.networkstack"
android:versionCode="319999900"
android:versionName="s_aml_319999900"
coreApp="true"
>
<!-- Permissions must be defined here, and not in the base manifest, as the network stack
running in the system server process does not need any permission, and having privileged
......
......@@ -19,7 +19,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.networkstack.inprocess"
android:sharedUserId="android.uid.system"
android:process="system">
android:process="system"
coreApp="true">
<application>
<service android:name="com.android.server.NetworkStackService"
android:process="system"
......
......@@ -18,5 +18,6 @@
package="com.android.networkstack"
android:sharedUserId="android.uid.networkstack"
android:versionCode="320000000"
android:versionName="T-next">
android:versionName="T-next"
coreApp="true">
</manifest>
......@@ -40,8 +40,7 @@
// We must specify at least one module here or the tests won't run. Use the same set as CTS
// so in theory the infra would not need to reinstall/reboot devices to run both.
{
// TODO: add back tethering when it is updatable in this branch
"name": "NetworkStackTests[CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex]"
"name": "NetworkStackTests[CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex]"
}
],
"mainline-postsubmit": [
......
......@@ -16,8 +16,14 @@
package com.android.networkstack.apishim.api29;
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED;
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_VPN;
import static android.net.NetworkCapabilities.NET_CAPABILITY_TRUSTED;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.ConnectivityManager.NetworkCallback;
import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
import android.os.Handler;
......@@ -30,7 +36,10 @@ import com.android.networkstack.apishim.common.UnsupportedApiLevelException;
* Implementation of {@link ConnectivityManagerShim} for API 29.
*/
public class ConnectivityManagerShimImpl implements ConnectivityManagerShim {
protected ConnectivityManagerShimImpl(Context context) {}
protected final ConnectivityManager mCm;
protected ConnectivityManagerShimImpl(Context context) {
mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
}
/**
* Get a new instance of {@link ConnectivityManagerShim}.
......@@ -52,12 +61,31 @@ public class ConnectivityManagerShimImpl implements ConnectivityManagerShim {
/**
* See android.net.ConnectivityManager#registerSystemDefaultNetworkCallback
* @throws UnsupportedApiLevelException if API is not available in this API level.
*/
@Override
public void registerSystemDefaultNetworkCallback(@NonNull NetworkCallback networkCallback,
@NonNull Handler handler) throws UnsupportedApiLevelException {
// Not supported for API 29.
throw new UnsupportedApiLevelException("Not supported in API 29.");
@NonNull Handler handler) {
// defaultNetworkRequest is not really a "request", just a way of tracking the system
// default network. It's guaranteed not to actually bring up any networks because it
// should be the same request as the ConnectivityService default request, and thus
// shares fate with it. In API <= R, registerSystemDefaultNetworkCallback is not
// available, and registerDefaultNetworkCallback will not track the system default when
// a VPN applies to the UID of this process.
final NetworkRequest defaultNetworkRequest = makeEmptyCapabilitiesRequest()
.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED)
.addCapability(NetworkCapabilities.NET_CAPABILITY_TRUSTED)
.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
.build();
mCm.requestNetwork(defaultNetworkRequest, networkCallback, handler);
}
@NonNull
protected NetworkRequest.Builder makeEmptyCapabilitiesRequest() {
// Q does not have clearCapabilities(), so assume the default capabilities are as below
return new NetworkRequest.Builder()
.removeCapability(NET_CAPABILITY_NOT_RESTRICTED)
.removeCapability(NET_CAPABILITY_TRUSTED)
.removeCapability(NET_CAPABILITY_NOT_VPN);
}
}
......@@ -16,10 +16,10 @@
package com.android.networkstack.apishim.api30;
import static com.android.modules.utils.build.SdkLevel.isAtLeastR;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.ConnectivityManager.NetworkCallback;
import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
import android.os.Build;
import android.os.Handler;
......@@ -28,25 +28,24 @@ import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import com.android.networkstack.apishim.common.ConnectivityManagerShim;
import com.android.networkstack.apishim.common.ShimUtils;
import com.android.networkstack.apishim.common.UnsupportedApiLevelException;
/**
* Implementation of {@link ConnectivityManagerShim} for API 30.
*/
@RequiresApi(Build.VERSION_CODES.R)
public class ConnectivityManagerShimImpl
extends com.android.networkstack.apishim.api29.ConnectivityManagerShimImpl {
protected final ConnectivityManager mCm;
protected ConnectivityManagerShimImpl(Context context) {
super(context);
mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
}
/**
* Get a new instance of {@link ConnectivityManagerShim}.
*/
@RequiresApi(Build.VERSION_CODES.Q)
public static ConnectivityManagerShim newInstance(Context context) {
if (!ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)) {
if (!isAtLeastR()) {
return com.android.networkstack.apishim.api29.ConnectivityManagerShimImpl
.newInstance(context);
}
......@@ -65,27 +64,9 @@ public class ConnectivityManagerShimImpl
throw new UnsupportedApiLevelException("Not supported in API 30.");
}
/**
* See android.net.ConnectivityManager#registerSystemDefaultNetworkCallback
* @throws UnsupportedApiLevelException if API is not available in this API level.
*/
@NonNull
@Override
@RequiresApi(Build.VERSION_CODES.R)
public void registerSystemDefaultNetworkCallback(@NonNull NetworkCallback networkCallback,
@NonNull Handler handler) {
// defaultNetworkRequest is not really a "request", just a way of tracking the system
// default network. It's guaranteed not to actually bring up any networks because it
// should be the same request as the ConnectivityService default request, and thus
// shares fate with it. In API <= R, registerSystemDefaultNetworkCallback is not
// available, and registerDefaultNetworkCallback will not track the system default when
// a VPN applies to the UID of this process.
final NetworkRequest defaultNetworkRequest = new NetworkRequest.Builder()
.clearCapabilities()
.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED)
.addCapability(NetworkCapabilities.NET_CAPABILITY_TRUSTED)
.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
.build();
mCm.requestNetwork(defaultNetworkRequest, networkCallback, handler);
protected NetworkRequest.Builder makeEmptyCapabilitiesRequest() {
return new NetworkRequest.Builder().clearCapabilities();
}
}
......@@ -42,8 +42,7 @@ public interface ConnectivityManagerShim {
/** See android.net.ConnectivityManager#registerSystemDefaultNetworkCallback */
void registerSystemDefaultNetworkCallback(
@NonNull NetworkCallback networkCallback, @NonNull Handler handler)
throws UnsupportedApiLevelException;
@NonNull NetworkCallback networkCallback, @NonNull Handler handler);
/** See android.net.ConnectivityManager#registerDefaultNetworkCallbackForUid */
default void registerDefaultNetworkCallbackForUid(
......
......@@ -21,18 +21,29 @@ package {
default_applicable_licenses: ["Android-Apache-2.0"],
}
// TODO: remove this filegroup together with services.net
filegroup {
name: "net-module-utils-srcs",
srcs: [
"src/android/net/util/SharedLog.java",
"src/android/net/shared/NetdUtils.java",
"src/android/net/shared/NetworkMonitorUtils.java",
"src/android/net/shared/RouteUtils.java",
"src/android/net/util/InterfaceParams.java",
"src/android/net/util/SharedLog.java",
],
visibility: [
"//frameworks/base/services/net",
"//frameworks/base/packages/Connectivity/service",
]
}
filegroup {
name: "connectivity-module-utils-srcs",
srcs: [
"src/android/net/util/SharedLog.java",
"src/android/net/shared/NetdUtils.java",
"src/android/net/shared/NetworkMonitorUtils.java",
"src/android/net/shared/RouteUtils.java",
],
visibility: [
"//packages/modules/Connectivity/service",
]
}
......@@ -53,7 +64,6 @@ filegroup {
"src/android/net/ip/InterfaceController.java",
"src/android/net/ip/IpNeighborMonitor.java",
"src/android/net/ip/NetlinkMonitor.java",
"src/android/net/netlink/*.java",
"src/android/net/shared/NetdUtils.java",
"src/android/net/shared/RouteUtils.java",
"src/android/net/util/InterfaceParams.java",
......
......@@ -16,12 +16,9 @@
package android.net.ip;
import static android.net.netlink.ConntrackMessage.DYING_MASK;
import static android.net.netlink.ConntrackMessage.ESTABLISHED_MASK;
import static com.android.net.module.util.netlink.ConntrackMessage.DYING_MASK;
import static com.android.net.module.util.netlink.ConntrackMessage.ESTABLISHED_MASK;
import android.net.netlink.ConntrackMessage;
import android.net.netlink.NetlinkConstants;
import android.net.netlink.NetlinkMessage;
import android.net.util.SharedLog;
import android.os.Handler;
import android.system.OsConstants;
......@@ -29,6 +26,9 @@ import android.system.OsConstants;
import androidx.annotation.NonNull;
import com.android.internal.annotations.VisibleForTesting;
import com.android.net.module.util.netlink.ConntrackMessage;
import com.android.net.module.util.netlink.NetlinkConstants;
import com.android.net.module.util.netlink.NetlinkMessage;
import java.util.Objects;
......
......@@ -16,22 +16,24 @@
package android.net.ip;
import static android.net.netlink.NetlinkConstants.RTM_DELNEIGH;
import static android.net.netlink.NetlinkConstants.hexify;
import static android.net.netlink.NetlinkConstants.stringForNlMsgType;
import static android.system.OsConstants.NETLINK_ROUTE;
import static com.android.net.module.util.netlink.NetlinkConstants.RTM_DELNEIGH;
import static com.android.net.module.util.netlink.NetlinkConstants.hexify;
import static com.android.net.module.util.netlink.NetlinkConstants.stringForNlMsgType;
import android.net.MacAddress;
import android.net.netlink.NetlinkMessage;
import android.net.netlink.NetlinkSocket;
import android.net.netlink.RtNetlinkNeighborMessage;
import android.net.netlink.StructNdMsg;
import android.net.util.SharedLog;
import android.os.Handler;
import android.system.ErrnoException;
import android.system.OsConstants;
import android.util.Log;
import com.android.net.module.util.netlink.NetlinkMessage;
import com.android.net.module.util.netlink.NetlinkSocket;
import com.android.net.module.util.netlink.RtNetlinkNeighborMessage;
import com.android.net.module.util.netlink.StructNdMsg;
import java.net.InetAddress;
import java.util.StringJoiner;
......
......@@ -16,7 +16,6 @@
package android.net.ip;
import static android.net.netlink.NetlinkConstants.hexify;
import static android.net.util.SocketUtils.makeNetlinkSocketAddress;
import static android.system.OsConstants.AF_NETLINK;
import static android.system.OsConstants.SOCK_DGRAM;
......@@ -24,10 +23,9 @@ import static android.system.OsConstants.SOCK_NONBLOCK;
import static android.system.OsConstants.SOL_SOCKET;
import static android.system.OsConstants.SO_RCVBUF;
import static com.android.net.module.util.netlink.NetlinkConstants.hexify;
import android.annotation.NonNull;
import android.net.netlink.NetlinkErrorMessage;
import android.net.netlink.NetlinkMessage;
import android.net.netlink.NetlinkSocket;
import android.net.util.SharedLog;
import android.net.util.SocketUtils;
import android.os.Handler;
......@@ -37,6 +35,9 @@ import android.system.Os;
import android.util.Log;
import com.android.net.module.util.PacketReader;
import com.android.net.module.util.netlink.NetlinkErrorMessage;
import com.android.net.module.util.netlink.NetlinkMessage;
import com.android.net.module.util.netlink.NetlinkSocket;
import java.io.FileDescriptor;
import java.io.IOException;
......
......@@ -19,6 +19,7 @@ package android.net.shared;
import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET;
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED;
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_VPN;
import static android.net.NetworkCapabilities.NET_CAPABILITY_OEM_PAID;
import static android.net.NetworkCapabilities.NET_CAPABILITY_TRUSTED;
import static android.net.NetworkCapabilities.TRANSPORT_BLUETOOTH;
import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR;
......@@ -27,6 +28,8 @@ import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
import android.net.NetworkCapabilities;
import com.android.modules.utils.build.SdkLevel;
/** @hide */
public class NetworkMonitorUtils {
// This class is used by both NetworkMonitor and ConnectivityService, so it cannot use
......@@ -36,6 +39,14 @@ public class NetworkMonitorUtils {
// TODO: use NetworkCapabilities.TRANSPORT_TEST once NetworkStack builds against API 31.
private static final int TRANSPORT_TEST = 7;
// This class is used by both NetworkMonitor and ConnectivityService, so it cannot use
// NetworkStack shims, but at the same time cannot use non-system APIs.
// NET_CAPABILITY_NOT_VCN_MANAGED is system API as of S (so it is enforced to always be 28 and
// can't be changed).
// TODO: use NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED once NetworkStack builds against
// API 31.
public static final int NET_CAPABILITY_NOT_VCN_MANAGED = 28;
// Network conditions broadcast constants
public static final String ACTION_NETWORK_CONDITIONS_MEASURED =
"android.net.conn.NETWORK_CONDITIONS_MEASURED";
......@@ -59,18 +70,19 @@ public class NetworkMonitorUtils {
public static boolean isPrivateDnsValidationRequired(NetworkCapabilities nc) {
if (nc == null) return false;
final boolean isVcnManaged = SdkLevel.isAtLeastS()
&& !nc.hasCapability(NET_CAPABILITY_NOT_VCN_MANAGED);
final boolean isOemPaid = nc.hasCapability(NET_CAPABILITY_OEM_PAID)
&& nc.hasCapability(NET_CAPABILITY_TRUSTED);
final boolean isDefaultCapable = nc.hasCapability(NET_CAPABILITY_NOT_RESTRICTED)
&& nc.hasCapability(NET_CAPABILITY_TRUSTED);
// TODO: Consider requiring validation for DUN networks.
if (nc.hasCapability(NET_CAPABILITY_INTERNET)
&& nc.hasCapability(NET_CAPABILITY_NOT_RESTRICTED)
&& nc.hasCapability(NET_CAPABILITY_TRUSTED)) {
// Real networks
&& (isVcnManaged || isOemPaid || isDefaultCapable)) {
return true;
}
// TODO: once TRANSPORT_TEST is @SystemApi in S and S SDK is stable (so constant shims can
// be replaced with the SDK constant that will be inlined), replace isTestNetwork with
// hasTransport(TRANSPORT_TEST)
// Test networks that also have one of the major transport types are attempting to replicate
// that transport on a test interface (for example, test ethernet networks with
// EthernetManager#setIncludeTestInterfaces). Run validation on them for realistic tests.
......
//
// Copyright (C) 2018 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package {
default_applicable_licenses: ["Android-Apache-2.0"],
}
java_library {
name: "netlink-client",
srcs: [
"src/**/*.java",
":framework-annotations",
],
libs: [
"androidx.annotation_annotation",
],
sdk_version: "system_current",
// this is part of updatable modules(NetworkStack) which targets 29(Q)
min_sdk_version: "29",
}
</
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.net.netlink;
import static android.net.netlink.NetlinkConstants.SOCK_DIAG_BY_FAMILY;
import static android.net.netlink.NetlinkSocket.DEFAULT_RECV_BUFSIZE;
import static android.net.netlink.StructNlMsgHdr.NLM_F_DUMP;
import static android.net.netlink.StructNlMsgHdr.NLM_F_REQUEST;
import static android.os.Process.INVALID_UID;
import static android.system.OsConstants.AF_INET;
import static android.system.OsConstants.AF_INET6;
import static android.system.OsConstants.IPPROTO_UDP;
import static android.system.OsConstants.NETLINK_INET_DIAG;
import android.annotation.Nullable;
import android.net.util.SocketUtils;
import android.system.ErrnoException;
import android.util.Log;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetSocketAddress;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/**
* A NetlinkMessage subclass for netlink inet_diag messages.
*
* see also: &lt;linux_src&gt;/include/uapi/linux/inet_diag.h
*
* @hide
*/
public class InetDiagMessage extends NetlinkMessage {
public static final String TAG = "InetDiagMessage";
private static final int TIMEOUT_MS = 500;
public static byte[] InetDiagReqV2(int protocol, InetSocketAddress local,
InetSocketAddress remote, int family, short flags) {
return InetDiagReqV2(protocol, local, remote, family, flags, 0 /* pad */,
0 /* idiagExt */, StructInetDiagReqV2.INET_DIAG_REQ_V2_ALL_STATES);
}
/**
* Construct an inet_diag_req_v2 message. This method will throw {@code NullPointerException}
* if local and remote are not both null or both non-null.
*
* @param protocol the request protocol type. This should be set to one of IPPROTO_TCP,
* IPPROTO_UDP, or IPPROTO_UDPLITE.
* @param local local socket address of the target socket. This will be packed into a
* {@Code StructInetDiagSockId}. Request to diagnose for all sockets if both of
* local or remote address is null.
* @param remote remote socket address of the target socket. This will be packed into a
* {@Code StructInetDiagSockId}. Request to diagnose for all sockets if both of
* local or remote address is null.
* @param family the ip family of the request message. This should be set to either AF_INET or
* AF_INET6 for IPv4 or IPv6 sockets respectively.
* @param flags message flags. See &lt;linux_src&gt;/include/uapi/linux/netlink.h.
* @param pad for raw socket protocol specification.
* @param idiagExt a set of flags defining what kind of extended information to report.
* @param state a bit mask that defines a filter of socket states.
*
* @return bytes array representation of the message
**/
public static byte[] InetDiagReqV2(int protocol, @Nullable InetSocketAddress local,
@Nullable InetSocketAddress remote, int family, short flags, int pad, int idiagExt,
int state) throws NullPointerException {
final byte[] bytes = new byte[StructNlMsgHdr.STRUCT_SIZE + StructInetDiagReqV2.STRUCT_SIZE];
final ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
byteBuffer.order(ByteOrder.nativeOrder());
final StructNlMsgHdr nlMsgHdr = new StructNlMsgHdr();
nlMsgHdr.nlmsg_len = bytes.length;
nlMsgHdr.nlmsg_type = SOCK_DIAG_BY_FAMILY;
nlMsgHdr.nlmsg_flags = flags;
nlMsgHdr.pack(byteBuffer);
final StructInetDiagReqV2 inetDiagReqV2 =
new StructInetDiagReqV2(protocol, local, remote, family, pad, idiagExt, state);
inetDiagReqV2.pack(byteBuffer);
return bytes;
}
public StructInetDiagMsg mStructInetDiagMsg;
private InetDiagMessage(StructNlMsgHdr header) {
super(header);
mStructInetDiagMsg = new StructInetDiagMsg();
}
public static InetDiagMessage parse(StructNlMsgHdr header, ByteBuffer byteBuffer) {
final InetDiagMessage msg = new InetDiagMessage(header);
msg.mStructInetDiagMsg = StructInetDiagMsg.parse(byteBuffer);
return msg;
}
private static int lookupUidByFamily(int protocol, InetSocketAddress local,
InetSocketAddress remote, int family, short flags,
FileDescriptor fd)
throws ErrnoException, InterruptedIOException {
byte[] msg = InetDiagReqV2(protocol, local, remote, family, flags);
NetlinkSocket.sendMessage(fd, msg, 0, msg.length, TIMEOUT_MS);
ByteBuffer response = NetlinkSocket.recvMessage(fd, DEFAULT_RECV_BUFSIZE, TIMEOUT_MS);
final NetlinkMessage nlMsg = NetlinkMessage.parse(response, NETLINK_INET_DIAG);
final StructNlMsgHdr hdr = nlMsg.getHeader();
if (hdr.nlmsg_type == NetlinkConstants.NLMSG_DONE) {
return INVALID_UID;
}
if (nlMsg instanceof InetDiagMessage) {
return ((InetDiagMessage) nlMsg).mStructInetDiagMsg.idiag_uid;
}
return INVALID_UID;
}
private static final int FAMILY[] = {AF_INET6, AF_INET};
private static int lookupUid(int protocol, InetSocketAddress local,
InetSocketAddress remote, FileDescriptor fd)
throws ErrnoException, InterruptedIOException {
int uid;
for (int family : FAMILY) {
/**
* For exact match lookup, swap local and remote for UDP lookups due to kernel
* bug which will not be fixed. See aosp/755889 and
* https://www.mail-archive.com/netdev@vger.kernel.org/msg248638.html
*/
if (protocol == IPPROTO_UDP) {
uid = lookupUidByFamily(protocol, remote, local, family, NLM_F_REQUEST, fd);
} else {
uid = lookupUidByFamily(protocol, local, remote, family, NLM_F_REQUEST, fd);
}
if (uid != INVALID_UID) {
return uid;
}