remove needless arguments to stopClatd
Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ia786a198be336f48327b5e1b568b3e7c24d0dc59
This commit is contained in:
@@ -485,11 +485,15 @@ static jint com_android_server_connectivity_ClatCoordinator_startClatd(
|
||||
static constexpr int WAITPID_ATTEMPTS = 50;
|
||||
static constexpr int WAITPID_RETRY_INTERVAL_US = 100000;
|
||||
|
||||
static void stopClatdProcess(int pid) {
|
||||
int err = kill(pid, SIGTERM);
|
||||
if (err) {
|
||||
err = errno;
|
||||
static void com_android_server_connectivity_ClatCoordinator_stopClatd(JNIEnv* env, jclass clazz,
|
||||
jint pid) {
|
||||
if (pid <= 0) {
|
||||
jniThrowExceptionFmt(env, "java/io/IOException", "Invalid pid");
|
||||
return;
|
||||
}
|
||||
|
||||
int err = kill(pid, SIGTERM);
|
||||
if (err) err = errno;
|
||||
if (err == ESRCH) {
|
||||
ALOGE("clatd child process %d unexpectedly disappeared", pid);
|
||||
return;
|
||||
@@ -518,23 +522,6 @@ static void stopClatdProcess(int pid) {
|
||||
}
|
||||
}
|
||||
|
||||
static void com_android_server_connectivity_ClatCoordinator_stopClatd(JNIEnv* env, jclass clazz,
|
||||
jstring iface, jstring pfx96,
|
||||
jstring v4, jstring v6,
|
||||
jint pid) {
|
||||
ScopedUtfChars ifaceStr(env, iface);
|
||||
ScopedUtfChars pfx96Str(env, pfx96);
|
||||
ScopedUtfChars v4Str(env, v4);
|
||||
ScopedUtfChars v6Str(env, v6);
|
||||
|
||||
if (pid <= 0) {
|
||||
jniThrowExceptionFmt(env, "java/io/IOException", "Invalid pid");
|
||||
return;
|
||||
}
|
||||
|
||||
stopClatdProcess(pid);
|
||||
}
|
||||
|
||||
static jlong com_android_server_connectivity_ClatCoordinator_getSocketCookie(
|
||||
JNIEnv* env, jclass clazz, jobject sockJavaFd) {
|
||||
int sockFd = netjniutils::GetNativeFileDescriptor(env, sockJavaFd);
|
||||
@@ -579,8 +566,7 @@ static const JNINativeMethod gMethods[] = {
|
||||
"(Ljava/io/FileDescriptor;Ljava/io/FileDescriptor;Ljava/io/FileDescriptor;Ljava/lang/"
|
||||
"String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I",
|
||||
(void*)com_android_server_connectivity_ClatCoordinator_startClatd},
|
||||
{"native_stopClatd",
|
||||
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V",
|
||||
{"native_stopClatd", "(I)V",
|
||||
(void*)com_android_server_connectivity_ClatCoordinator_stopClatd},
|
||||
{"native_getSocketCookie", "(Ljava/io/FileDescriptor;)J",
|
||||
(void*)com_android_server_connectivity_ClatCoordinator_getSocketCookie},
|
||||
|
||||
@@ -237,9 +237,8 @@ public class ClatCoordinator {
|
||||
/**
|
||||
* Stop clatd.
|
||||
*/
|
||||
public void stopClatd(String iface, String pfx96, String v4, String v6, int pid)
|
||||
throws IOException {
|
||||
native_stopClatd(iface, pfx96, v4, v6, pid);
|
||||
public void stopClatd(int pid) throws IOException {
|
||||
native_stopClatd(pid);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -843,9 +842,7 @@ public class ClatCoordinator {
|
||||
Log.i(TAG, "Stopping clatd pid=" + mClatdTracker.pid + " on " + mClatdTracker.iface);
|
||||
|
||||
maybeStopBpf(mClatdTracker);
|
||||
mDeps.stopClatd(mClatdTracker.iface, mClatdTracker.pfx96.getHostAddress(),
|
||||
mClatdTracker.v4.getHostAddress(), mClatdTracker.v6.getHostAddress(),
|
||||
mClatdTracker.pid);
|
||||
mDeps.stopClatd(mClatdTracker.pid);
|
||||
untagSocket(mClatdTracker.cookie);
|
||||
|
||||
Log.i(TAG, "clatd on " + mClatdTracker.iface + " stopped");
|
||||
@@ -944,7 +941,6 @@ public class ClatCoordinator {
|
||||
private static native int native_startClatd(FileDescriptor tunfd, FileDescriptor readsock6,
|
||||
FileDescriptor writesock6, String iface, String pfx96, String v4, String v6)
|
||||
throws IOException;
|
||||
private static native void native_stopClatd(String iface, String pfx96, String v4, String v6,
|
||||
int pid) throws IOException;
|
||||
private static native void native_stopClatd(int pid) throws IOException;
|
||||
private static native long native_getSocketCookie(FileDescriptor sock) throws IOException;
|
||||
}
|
||||
|
||||
@@ -313,8 +313,7 @@ public class ClatCoordinatorTest {
|
||||
* Stop clatd.
|
||||
*/
|
||||
@Override
|
||||
public void stopClatd(@NonNull String iface, @NonNull String pfx96, @NonNull String v4,
|
||||
@NonNull String v6, int pid) throws IOException {
|
||||
public void stopClatd(int pid) throws IOException {
|
||||
if (pid == -1) {
|
||||
fail("unsupported arg: " + pid);
|
||||
}
|
||||
@@ -479,8 +478,7 @@ public class ClatCoordinatorTest {
|
||||
eq((short) PRIO_CLAT), eq((short) ETH_P_IP));
|
||||
inOrder.verify(mEgressMap).deleteEntry(eq(EGRESS_KEY));
|
||||
inOrder.verify(mIngressMap).deleteEntry(eq(INGRESS_KEY));
|
||||
inOrder.verify(mDeps).stopClatd(eq(BASE_IFACE), eq(NAT64_PREFIX_STRING),
|
||||
eq(XLAT_LOCAL_IPV4ADDR_STRING), eq(XLAT_LOCAL_IPV6ADDR_STRING), eq(CLATD_PID));
|
||||
inOrder.verify(mDeps).stopClatd(eq(CLATD_PID));
|
||||
inOrder.verify(mCookieTagMap).deleteEntry(eq(COOKIE_TAG_KEY));
|
||||
assertNull(coordinator.getClatdTrackerForTesting());
|
||||
inOrder.verifyNoMoreInteractions();
|
||||
|
||||
Reference in New Issue
Block a user