summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2015-01-07 15:11:30 +0900
committerThe Android Automerger <android-build@google.com>2015-01-09 13:02:12 -0800
commit2e5fa934741dbf8be9729e1250f6cf37b8d9027f (patch)
tree976abb00f185e926ae24b0c7cd3a0e9e6c66ccd1
parent60ffda165ae0115b89811025cd1fbf773446c684 (diff)
downloadnetd-android-5.1.1_r1.tar.gz
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.cpp44
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);