diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2015-01-07 15:11:30 +0900 |
---|---|---|
committer | The Android Automerger <android-build@google.com> | 2015-01-09 13:02:12 -0800 |
commit | 2e5fa934741dbf8be9729e1250f6cf37b8d9027f (patch) | |
tree | 976abb00f185e926ae24b0c7cd3a0e9e6c66ccd1 | |
parent | 60ffda165ae0115b89811025cd1fbf773446c684 (diff) | |
download | netd-android-5.1.1_r1.tar.gz |
exit instead of returning when execv()ing clatd fails.android-cts-5.1_r9android-cts-5.1_r8android-cts-5.1_r7android-cts-5.1_r6android-cts-5.1_r5android-cts-5.1_r4android-cts-5.1_r3android-cts-5.1_r28android-cts-5.1_r27android-cts-5.1_r26android-cts-5.1_r25android-cts-5.1_r24android-cts-5.1_r23android-cts-5.1_r22android-cts-5.1_r21android-cts-5.1_r20android-cts-5.1_r2android-cts-5.1_r19android-cts-5.1_r18android-cts-5.1_r17android-cts-5.1_r16android-cts-5.1_r15android-cts-5.1_r14android-cts-5.1_r13android-cts-5.1_r10android-cts-5.1_r1android-5.1.1_r9android-5.1.1_r8android-5.1.1_r7android-5.1.1_r6android-5.1.1_r4android-5.1.1_r38android-5.1.1_r37android-5.1.1_r36android-5.1.1_r35android-5.1.1_r34android-5.1.1_r33android-5.1.1_r30android-5.1.1_r3android-5.1.1_r29android-5.1.1_r26android-5.1.1_r25android-5.1.1_r24android-5.1.1_r23android-5.1.1_r20android-5.1.1_r2android-5.1.1_r19android-5.1.1_r18android-5.1.1_r16android-5.1.1_r15android-5.1.1_r14android-5.1.1_r13android-5.1.1_r10android-5.1.1_r1android-5.1.0_r5android-5.1.0_r4android-5.1.0_r3android-5.1.0_r1lollipop-mr1-releaselollipop-mr1-fi-releaselollipop-mr1-cts-releaselinaro_android_5.1.1
Returning instead of exiting when execv() fails causes mayhem, as
it results in two netd processes running, and netd commands being
processed by one of the two at random.
Bug: 18893886
Change-Id: I25afbabaef5955c9af7053b0333969b4e83549f1
-rw-r--r-- | server/ClatdController.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/server/ClatdController.cpp b/server/ClatdController.cpp index b97ea320..348a0dda 100644 --- a/server/ClatdController.cpp +++ b/server/ClatdController.cpp @@ -57,6 +57,26 @@ int ClatdController::startClatd(char* interface) { return -1; } + // Pass in the interface, a netid to use for DNS lookups, and a fwmark for outgoing packets. + unsigned netId = mNetCtrl->getNetworkForInterface(interface); + if (netId == NETID_UNSET) { + ALOGE("interface %s not assigned to any netId", interface); + errno = ENODEV; + return -1; + } + + char netIdString[UINT32_STRLEN]; + snprintf(netIdString, sizeof(netIdString), "%u", netId); + + Fwmark fwmark; + fwmark.netId = netId; + fwmark.explicitlySelected = true; + fwmark.protectedFromVpn = true; + fwmark.permission = PERMISSION_SYSTEM; + + char fwmarkString[UINT32_HEX_STRLEN]; + snprintf(fwmarkString, sizeof(fwmarkString), "0x%x", fwmark.intValue); + ALOGD("starting clatd on %s", interface); std::string progname("clatd-"); @@ -68,26 +88,6 @@ int ClatdController::startClatd(char* interface) { } if (!pid) { - // Pass in the interface, a netid to use for DNS lookups, and a fwmark for outgoing packets. - unsigned netId = mNetCtrl->getNetworkForInterface(interface); - if (netId == NETID_UNSET) { - ALOGE("interface %s not assigned to any netId", interface); - errno = ENODEV; - return -1; - } - - char netIdString[UINT32_STRLEN]; - snprintf(netIdString, sizeof(netIdString), "%u", netId); - - Fwmark fwmark; - fwmark.netId = netId; - fwmark.explicitlySelected = true; - fwmark.protectedFromVpn = true; - fwmark.permission = PERMISSION_SYSTEM; - - char fwmarkString[UINT32_HEX_STRLEN]; - snprintf(fwmarkString, sizeof(fwmarkString), "0x%x", fwmark.intValue); - char *args[] = { (char *) progname.c_str(), (char *) "-i", @@ -101,10 +101,10 @@ int ClatdController::startClatd(char* interface) { if (execv(kClatdPath, args)) { ALOGE("execv failed (%s)", strerror(errno)); - return -1; + _exit(1); } ALOGE("Should never get here!"); - _exit(0); + _exit(1); } else { mClatdPids[interface] = pid; ALOGD("clatd started on %s", interface); |