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_ATTEMPTS = 50;
|
||||||
static constexpr int WAITPID_RETRY_INTERVAL_US = 100000;
|
static constexpr int WAITPID_RETRY_INTERVAL_US = 100000;
|
||||||
|
|
||||||
static void stopClatdProcess(int pid) {
|
static void com_android_server_connectivity_ClatCoordinator_stopClatd(JNIEnv* env, jclass clazz,
|
||||||
int err = kill(pid, SIGTERM);
|
jint pid) {
|
||||||
if (err) {
|
if (pid <= 0) {
|
||||||
err = errno;
|
jniThrowExceptionFmt(env, "java/io/IOException", "Invalid pid");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int err = kill(pid, SIGTERM);
|
||||||
|
if (err) err = errno;
|
||||||
if (err == ESRCH) {
|
if (err == ESRCH) {
|
||||||
ALOGE("clatd child process %d unexpectedly disappeared", pid);
|
ALOGE("clatd child process %d unexpectedly disappeared", pid);
|
||||||
return;
|
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(
|
static jlong com_android_server_connectivity_ClatCoordinator_getSocketCookie(
|
||||||
JNIEnv* env, jclass clazz, jobject sockJavaFd) {
|
JNIEnv* env, jclass clazz, jobject sockJavaFd) {
|
||||||
int sockFd = netjniutils::GetNativeFileDescriptor(env, 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/"
|
"(Ljava/io/FileDescriptor;Ljava/io/FileDescriptor;Ljava/io/FileDescriptor;Ljava/lang/"
|
||||||
"String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I",
|
"String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I",
|
||||||
(void*)com_android_server_connectivity_ClatCoordinator_startClatd},
|
(void*)com_android_server_connectivity_ClatCoordinator_startClatd},
|
||||||
{"native_stopClatd",
|
{"native_stopClatd", "(I)V",
|
||||||
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V",
|
|
||||||
(void*)com_android_server_connectivity_ClatCoordinator_stopClatd},
|
(void*)com_android_server_connectivity_ClatCoordinator_stopClatd},
|
||||||
{"native_getSocketCookie", "(Ljava/io/FileDescriptor;)J",
|
{"native_getSocketCookie", "(Ljava/io/FileDescriptor;)J",
|
||||||
(void*)com_android_server_connectivity_ClatCoordinator_getSocketCookie},
|
(void*)com_android_server_connectivity_ClatCoordinator_getSocketCookie},
|
||||||
|
|||||||
@@ -237,9 +237,8 @@ public class ClatCoordinator {
|
|||||||
/**
|
/**
|
||||||
* Stop clatd.
|
* Stop clatd.
|
||||||
*/
|
*/
|
||||||
public void stopClatd(String iface, String pfx96, String v4, String v6, int pid)
|
public void stopClatd(int pid) throws IOException {
|
||||||
throws IOException {
|
native_stopClatd(pid);
|
||||||
native_stopClatd(iface, pfx96, v4, v6, pid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -843,9 +842,7 @@ public class ClatCoordinator {
|
|||||||
Log.i(TAG, "Stopping clatd pid=" + mClatdTracker.pid + " on " + mClatdTracker.iface);
|
Log.i(TAG, "Stopping clatd pid=" + mClatdTracker.pid + " on " + mClatdTracker.iface);
|
||||||
|
|
||||||
maybeStopBpf(mClatdTracker);
|
maybeStopBpf(mClatdTracker);
|
||||||
mDeps.stopClatd(mClatdTracker.iface, mClatdTracker.pfx96.getHostAddress(),
|
mDeps.stopClatd(mClatdTracker.pid);
|
||||||
mClatdTracker.v4.getHostAddress(), mClatdTracker.v6.getHostAddress(),
|
|
||||||
mClatdTracker.pid);
|
|
||||||
untagSocket(mClatdTracker.cookie);
|
untagSocket(mClatdTracker.cookie);
|
||||||
|
|
||||||
Log.i(TAG, "clatd on " + mClatdTracker.iface + " stopped");
|
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,
|
private static native int native_startClatd(FileDescriptor tunfd, FileDescriptor readsock6,
|
||||||
FileDescriptor writesock6, String iface, String pfx96, String v4, String v6)
|
FileDescriptor writesock6, String iface, String pfx96, String v4, String v6)
|
||||||
throws IOException;
|
throws IOException;
|
||||||
private static native void native_stopClatd(String iface, String pfx96, String v4, String v6,
|
private static native void native_stopClatd(int pid) throws IOException;
|
||||||
int pid) throws IOException;
|
|
||||||
private static native long native_getSocketCookie(FileDescriptor sock) throws IOException;
|
private static native long native_getSocketCookie(FileDescriptor sock) throws IOException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -313,8 +313,7 @@ public class ClatCoordinatorTest {
|
|||||||
* Stop clatd.
|
* Stop clatd.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void stopClatd(@NonNull String iface, @NonNull String pfx96, @NonNull String v4,
|
public void stopClatd(int pid) throws IOException {
|
||||||
@NonNull String v6, int pid) throws IOException {
|
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
fail("unsupported arg: " + pid);
|
fail("unsupported arg: " + pid);
|
||||||
}
|
}
|
||||||
@@ -479,8 +478,7 @@ public class ClatCoordinatorTest {
|
|||||||
eq((short) PRIO_CLAT), eq((short) ETH_P_IP));
|
eq((short) PRIO_CLAT), eq((short) ETH_P_IP));
|
||||||
inOrder.verify(mEgressMap).deleteEntry(eq(EGRESS_KEY));
|
inOrder.verify(mEgressMap).deleteEntry(eq(EGRESS_KEY));
|
||||||
inOrder.verify(mIngressMap).deleteEntry(eq(INGRESS_KEY));
|
inOrder.verify(mIngressMap).deleteEntry(eq(INGRESS_KEY));
|
||||||
inOrder.verify(mDeps).stopClatd(eq(BASE_IFACE), eq(NAT64_PREFIX_STRING),
|
inOrder.verify(mDeps).stopClatd(eq(CLATD_PID));
|
||||||
eq(XLAT_LOCAL_IPV4ADDR_STRING), eq(XLAT_LOCAL_IPV6ADDR_STRING), eq(CLATD_PID));
|
|
||||||
inOrder.verify(mCookieTagMap).deleteEntry(eq(COOKIE_TAG_KEY));
|
inOrder.verify(mCookieTagMap).deleteEntry(eq(COOKIE_TAG_KEY));
|
||||||
assertNull(coordinator.getClatdTrackerForTesting());
|
assertNull(coordinator.getClatdTrackerForTesting());
|
||||||
inOrder.verifyNoMoreInteractions();
|
inOrder.verifyNoMoreInteractions();
|
||||||
|
|||||||
Reference in New Issue
Block a user