blob: ab2e91c7e60559f9c5dc96bf05d83bd965475ceb [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001diff --git a/system/netd/server/BandwidthController.cpp b/system/netd/server/BandwidthController.cpp
2index d71ce3b..0ab5418 100644
3--- a/system/netd/server/BandwidthController.cpp
4+++ b/system/netd/server/BandwidthController.cpp
5@@ -43,7 +43,7 @@
6
7 #define LOG_TAG "BandwidthController"
8 #include <cutils/log.h>
9-#include <cutils/properties.h>
10+//#include <cutils/properties.h>
11 #include <logwrap/logwrap.h>
12
13 #include "NetdConstants.h"
14@@ -253,10 +253,10 @@ int BandwidthController::setupIptablesHooks(void) {
15
16 int BandwidthController::enableBandwidthControl(bool force) {
17 int res;
18- char value[PROPERTY_VALUE_MAX];
19+ char value[20];
20
21 if (!force) {
22- property_get("persist.bandwidth.enable", value, "1");
23+ //property_get("persist.bandwidth.enable", value, "1");
24 if (!strcmp(value, "0"))
25 return 0;
26 }
27diff --git a/system/netd/server/CommandListener.cpp b/system/netd/server/CommandListener.cpp
28index 7ecbffc..956dc0d 100644
29--- a/system/netd/server/CommandListener.cpp
30+++ b/system/netd/server/CommandListener.cpp
31@@ -49,6 +49,8 @@
32 #include <string>
33 #include <vector>
34
35+#define UID_MAX 0xffffffffU
36+
37 namespace {
38
39 const unsigned NUM_OEM_IDS = NetworkController::MAX_OEM_ID - NetworkController::MIN_OEM_ID + 1;
40@@ -83,7 +85,7 @@ unsigned stringToNetId(const char* arg) {
41
42 NetworkController *CommandListener::sNetCtrl = NULL;
43 TetherController *CommandListener::sTetherCtrl = NULL;
44-NatController *CommandListener::sNatCtrl = NULL;
45+//NatController *CommandListener::sNatCtrl = NULL;
46 PppController *CommandListener::sPppCtrl = NULL;
47 SoftapController *CommandListener::sSoftapCtrl = NULL;
48 BandwidthController * CommandListener::sBandwidthCtrl = NULL;
49@@ -91,7 +93,7 @@ IdletimerController * CommandListener::sIdletimerCtrl = NULL;
50 InterfaceController *CommandListener::sInterfaceCtrl = NULL;
51 ResolverController *CommandListener::sResolverCtrl = NULL;
52 FirewallController *CommandListener::sFirewallCtrl = NULL;
53-ClatdController *CommandListener::sClatdCtrl = NULL;
54+//ClatdController *CommandListener::sClatdCtrl = NULL;
55 StrictController *CommandListener::sStrictCtrl = NULL;
56
57 /**
58@@ -110,7 +112,7 @@ static const char* FILTER_FORWARD[] = {
59 OEM_IPTABLES_FILTER_FORWARD,
60 FirewallController::LOCAL_FORWARD,
61 BandwidthController::LOCAL_FORWARD,
62- NatController::LOCAL_FORWARD,
63+ //NatController::LOCAL_FORWARD,
64 NULL,
65 };
66
67@@ -135,7 +137,7 @@ static const char* MANGLE_POSTROUTING[] = {
68 };
69
70 static const char* MANGLE_FORWARD[] = {
71- NatController::LOCAL_MANGLE_FORWARD,
72+ //NatController::LOCAL_MANGLE_FORWARD,
73 NULL,
74 };
75
76@@ -145,7 +147,7 @@ static const char* NAT_PREROUTING[] = {
77 };
78
79 static const char* NAT_POSTROUTING[] = {
80- NatController::LOCAL_NAT_POSTROUTING,
81+ //NatController::LOCAL_NAT_POSTROUTING,
82 NULL,
83 };
84
85@@ -174,7 +176,7 @@ CommandListener::CommandListener() :
86 registerCmd(new InterfaceCmd());
87 registerCmd(new IpFwdCmd());
88 registerCmd(new TetherCmd());
89- registerCmd(new NatCmd());
90+ //registerCmd(new NatCmd());
91 registerCmd(new ListTtysCmd());
92 registerCmd(new PppdCmd());
93 registerCmd(new SoftapCmd());
94@@ -182,7 +184,7 @@ CommandListener::CommandListener() :
95 registerCmd(new IdletimerControlCmd());
96 registerCmd(new ResolverCmd());
97 registerCmd(new FirewallCmd());
98- registerCmd(new ClatdCmd());
99+ //registerCmd(new ClatdCmd());
100 registerCmd(new NetworkCommand());
101 registerCmd(new StrictCmd());
102
103@@ -190,8 +192,8 @@ CommandListener::CommandListener() :
104 sNetCtrl = new NetworkController();
105 if (!sTetherCtrl)
106 sTetherCtrl = new TetherController();
107- if (!sNatCtrl)
108- sNatCtrl = new NatController();
109+ /*if (!sNatCtrl)
110+ sNatCtrl = new NatController();*/
111 if (!sPppCtrl)
112 sPppCtrl = new PppController();
113 if (!sSoftapCtrl)
114@@ -206,8 +208,10 @@ CommandListener::CommandListener() :
115 sFirewallCtrl = new FirewallController();
116 if (!sInterfaceCtrl)
117 sInterfaceCtrl = new InterfaceController();
118+ #if 0
119 if (!sClatdCtrl)
120 sClatdCtrl = new ClatdController(sNetCtrl);
121+ #endif
122 if (!sStrictCtrl)
123 sStrictCtrl = new StrictController();
124
125@@ -232,13 +236,13 @@ CommandListener::CommandListener() :
126 createChildChains(V4, "nat", "POSTROUTING", NAT_POSTROUTING);
127
128 // Let each module setup their child chains
129- setupOemIptablesHook();
130+ //setupOemIptablesHook();
131
132 /* When enabled, DROPs all packets except those matching rules. */
133 sFirewallCtrl->setupIptablesHooks();
134
135 /* Does DROPs in FORWARD by default */
136- sNatCtrl->setupIptablesHooks();
137+ //sNatCtrl->setupIptablesHooks();
138 /*
139 * Does REJECT in INPUT, OUTPUT. Does counting also.
140 * No DROP/REJECT allowed later in netfilter-flow hook order.
141@@ -673,6 +677,7 @@ int CommandListener::TetherCmd::runCommand(SocketClient *cli,
142 return 0;
143 }
144
145+#if 0
146 CommandListener::NatCmd::NatCmd() :
147 NetdCommand("nat") {
148 }
149@@ -712,6 +717,7 @@ int CommandListener::NatCmd::runCommand(SocketClient *cli,
150
151 return 0;
152 }
153+#endif
154
155 CommandListener::PppdCmd::PppdCmd() :
156 NetdCommand("pppd") {
157@@ -831,7 +837,7 @@ int CommandListener::ResolverCmd::runCommand(SocketClient *cli, int argc, char *
158 if (!strcmp(argv[1], "setnetdns")) {
159 // "resolver setnetdns <netId> <domains> <dns1> <dns2> ..."
160 if (argc >= 5) {
161- rc = sResolverCtrl->setDnsServers(netId, argv[3], &argv[4], argc - 4);
162+ rc = sResolverCtrl->setDnsServers(netId, "", &argv[4], argc - 4);
163 } else {
164 cli->sendMsg(ResponseCode::CommandSyntaxError,
165 "Wrong number of arguments to resolver setnetdns", false);
166@@ -1169,6 +1175,7 @@ int CommandListener::BandwidthControlCmd::runCommand(SocketClient *cli, int argc
167 return 0;
168
169 }
170+ #if 0
171 if (!strcmp(argv[1], "gettetherstats") || !strcmp(argv[1], "gts")) {
172 BandwidthController::TetherStats tetherStats;
173 std::string extraProcessingInfo = "";
174@@ -1192,7 +1199,7 @@ int CommandListener::BandwidthControlCmd::runCommand(SocketClient *cli, int argc
175 return 0;
176
177 }
178-
179+ #endif
180 cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown bandwidth cmd", false);
181 return 0;
182 }
183@@ -1432,6 +1439,7 @@ int CommandListener::FirewallCmd::runCommand(SocketClient *cli, int argc,
184 return 0;
185 }
186
187+#if 0
188 CommandListener::ClatdCmd::ClatdCmd() : NetdCommand("clatd") {
189 }
190
191@@ -1467,6 +1475,7 @@ int CommandListener::ClatdCmd::runCommand(SocketClient *cli, int argc,
192
193 return 0;
194 }
195+#endif
196
197 CommandListener::StrictCmd::StrictCmd() :
198 NetdCommand("strict") {
199@@ -1601,7 +1610,9 @@ int CommandListener::NetworkCommand::runCommand(SocketClient* client, int argc,
200
201 int ret;
202 if (add) {
203+ ALOGI("[zy]before addRoute");
204 ret = sNetCtrl->addRoute(netId, interface, destination, nexthop, legacy, uid);
205+ ALOGI("[zy]after addRoute");
206 } else {
207 ret = sNetCtrl->removeRoute(netId, interface, destination, nexthop, legacy, uid);
208 }
209diff --git a/system/netd/server/CommandListener.h b/system/netd/server/CommandListener.h
210index 72f4da1..e8a88d7 100644
211--- a/system/netd/server/CommandListener.h
212+++ b/system/netd/server/CommandListener.h
213@@ -22,7 +22,7 @@
214 #include "NetdCommand.h"
215 #include "NetworkController.h"
216 #include "TetherController.h"
217-#include "NatController.h"
218+//#include "NatController.h"
219 #include "PppController.h"
220 #include "SoftapController.h"
221 #include "BandwidthController.h"
222@@ -35,7 +35,7 @@
223
224 class CommandListener : public FrameworkListener {
225 static TetherController *sTetherCtrl;
226- static NatController *sNatCtrl;
227+ //static NatController *sNatCtrl;
228 static PppController *sPppCtrl;
229 static SoftapController *sSoftapCtrl;
230 static BandwidthController *sBandwidthCtrl;
231diff --git a/system/netd/server/DnsProxyListener.cpp b/system/netd/server/DnsProxyListener.cpp
232index 6c71c5b..1aa3676 100644
233--- a/system/netd/server/DnsProxyListener.cpp
234+++ b/system/netd/server/DnsProxyListener.cpp
235@@ -26,7 +26,7 @@
236 #include <string.h>
237 #include <pthread.h>
238 #include <resolv_netid.h>
239-#include <net/if.h>
240+//#include <net/if.h>
241
242 #define LOG_TAG "DnsProxyListener"
243 #define DBG 0
244@@ -155,12 +155,12 @@ static bool sendaddrinfo(SocketClient* c, struct addrinfo* ai) {
245 }
246
247 void DnsProxyListener::GetAddrInfoHandler::run() {
248- if (DBG) {
249- ALOGD("GetAddrInfoHandler, now for %s / %s / {%u,%u,%u,%u,%u}", mHost, mService,
250+
251+ ALOGI("[libdns]GetAddrInfoHandler, now for %s / %s / {%u,%u,%u,%u,%u}", mHost, mService,
252 mNetContext.app_netid, mNetContext.app_mark,
253 mNetContext.dns_netid, mNetContext.dns_mark,
254 mNetContext.uid);
255- }
256+
257
258 struct addrinfo* result = NULL;
259 uint32_t rv = android_getaddrinfofornetcontext(mHost, mService, mHints, &mNetContext, &result);
260@@ -176,11 +176,11 @@ void DnsProxyListener::GetAddrInfoHandler::run() {
261 }
262 success = success && sendBE32(mClient, 0);
263 if (!success) {
264- ALOGW("Error writing DNS result to client");
265+ ALOGI("[libdns]Error writing DNS result to client");
266 }
267 }
268 if (result) {
269- freeaddrinfo(result);
270+ android_freeaddrinfo(result);
271 }
272 mClient->decRef();
273 }
274diff --git a/system/netd/server/FwmarkServer.cpp b/system/netd/server/FwmarkServer.cpp
275index 530e96a..9d533e6 100644
276--- a/system/netd/server/FwmarkServer.cpp
277+++ b/system/netd/server/FwmarkServer.cpp
278@@ -23,6 +23,7 @@
279
280 #include <sys/socket.h>
281 #include <unistd.h>
282+#include <string.h>
283
284 FwmarkServer::FwmarkServer(NetworkController* networkController) :
285 SocketListener("fwmarkd", true), mNetworkController(networkController) {
286diff --git a/system/netd/server/IdletimerController.cpp b/system/netd/server/IdletimerController.cpp
287index e6306fd..c222018 100644
288--- a/system/netd/server/IdletimerController.cpp
289+++ b/system/netd/server/IdletimerController.cpp
290@@ -104,7 +104,7 @@
291 #include <netinet/in.h>
292 #include <arpa/inet.h>
293 #include <string.h>
294-#include <cutils/properties.h>
295+//#include <cutils/properties.h>
296
297 #define LOG_TAG "IdletimerController"
298 #include <cutils/log.h>
299diff --git a/system/netd/server/InterfaceController.cpp b/system/netd/server/InterfaceController.cpp
300index 3882bcc..e1125fe 100644
301--- a/system/netd/server/InterfaceController.cpp
302+++ b/system/netd/server/InterfaceController.cpp
303@@ -17,10 +17,11 @@
304 #include <dirent.h>
305 #include <errno.h>
306 #include <malloc.h>
307+#include <string.h>
308
309 #define LOG_TAG "InterfaceController"
310-#include <base/file.h>
311-#include <base/stringprintf.h>
312+#include <android-base/file.h>
313+#include <android-base/stringprintf.h>
314 #include <cutils/log.h>
315 #include <logwrap/logwrap.h>
316
317diff --git a/system/netd/server/NatController.cpp b/system/netd/server/NatController.cpp
318index 19d19c7..f455b6f 100644
319--- a/system/netd/server/NatController.cpp
320+++ b/system/netd/server/NatController.cpp
321@@ -25,7 +25,7 @@
322 #include <netinet/in.h>
323 #include <arpa/inet.h>
324 #include <string.h>
325-#include <cutils/properties.h>
326+//#include <cutils/properties.h>
327
328 #define LOG_TAG "NatController"
329 #include <cutils/log.h>
330diff --git a/system/netd/server/NatController.h b/system/netd/server/NatController.h
331index f23bf84..6bd4f64 100644
332--- a/system/netd/server/NatController.h
333+++ b/system/netd/server/NatController.h
334@@ -17,7 +17,7 @@
335 #ifndef _NAT_CONTROLLER_H
336 #define _NAT_CONTROLLER_H
337
338-#include <linux/in.h>
339+//#include <linux/in.h>
340 #include <list>
341 #include <string>
342
343diff --git a/system/netd/server/NetdConstants.cpp b/system/netd/server/NetdConstants.cpp
344index c86538b..54f1344 100644
345--- a/system/netd/server/NetdConstants.cpp
346+++ b/system/netd/server/NetdConstants.cpp
347@@ -19,7 +19,6 @@
348 #include <fcntl.h>
349 #include <netdb.h>
350 #include <net/if.h>
351-#include <netinet/in.h>
352 #include <stdlib.h>
353 #include <string.h>
354 #include <sys/wait.h>
355@@ -32,10 +31,10 @@
356 #include "NetdConstants.h"
357
358 const char * const OEM_SCRIPT_PATH = "/system/bin/oem-iptables-init.sh";
359-const char * const IPTABLES_PATH = "/system/bin/iptables";
360-const char * const IP6TABLES_PATH = "/system/bin/ip6tables";
361-const char * const TC_PATH = "/system/bin/tc";
362-const char * const IP_PATH = "/system/bin/ip";
363+const char * const IPTABLES_PATH = "/usr/sbin/iptables";
364+const char * const IP6TABLES_PATH = "/usr/sbin/ip6tables";
365+const char * const TC_PATH = "/sbin/tc";
366+const char * const IP_PATH = "/sbin/ip";
367 const char * const ADD = "add";
368 const char * const DEL = "del";
369
370@@ -172,6 +171,7 @@ int parsePrefix(const char *prefix, uint8_t *family, void *address, int size, ui
371 addrinfo hints = {
372 .ai_flags = AI_NUMERICHOST,
373 };
374+ ALOGI("[zy]addressString.c_str(%s)", addressString.c_str());
375 int ret = getaddrinfo(addressString.c_str(), NULL, &hints, &res);
376 if (ret || !res) {
377 return -EINVAL; // getaddrinfo return values are not errno values.
378@@ -211,7 +211,9 @@ int parsePrefix(const char *prefix, uint8_t *family, void *address, int size, ui
379 }
380
381 *family = res[0].ai_family;
382+ ALOGI("[zy]parsePrefix address[%p], rawAddress[%p], rawLength[%d]", address, rawAddress, rawLength);
383 memcpy(address, rawAddress, rawLength);
384+ ALOGI("[zy]after");
385 freeaddrinfo(res);
386
387 return rawLength;
388diff --git a/system/netd/server/NetlinkManager.cpp b/system/netd/server/NetlinkManager.cpp
389index 76af46f..853bf47 100644
390--- a/system/netd/server/NetlinkManager.cpp
391+++ b/system/netd/server/NetlinkManager.cpp
392@@ -44,7 +44,7 @@
393 #include "NetlinkManager.h"
394 #include "NetlinkHandler.h"
395
396-#include "pcap-netfilter-linux-android.h"
397+//#include "pcap-netfilter-linux-android.h"
398
399 const int NetlinkManager::NFLOG_QUOTA_GROUP = 1;
400 const int NetlinkManager::NETFILTER_STRICT_GROUP = 2;
401@@ -98,7 +98,7 @@ NetlinkHandler *NetlinkManager::setupSocket(int *sock, int netlinkFamily,
402 close(*sock);
403 return NULL;
404 }
405-
406+ #if 0
407 if (configNflog) {
408 if (android_nflog_send_config_cmd(*sock, 0, NFULNL_CFG_CMD_PF_UNBIND, AF_INET) < 0) {
409 ALOGE("Failed NFULNL_CFG_CMD_PF_UNBIND: %s", strerror(errno));
410@@ -113,7 +113,7 @@ NetlinkHandler *NetlinkManager::setupSocket(int *sock, int netlinkFamily,
411 return NULL;
412 }
413 }
414-
415+ #endif
416 NetlinkHandler *handler = new NetlinkHandler(this, *sock, format);
417 if (handler->start()) {
418 ALOGE("Unable to start NetlinkHandler: %s", strerror(errno));
419diff --git a/system/netd/server/PppController.cpp b/system/netd/server/PppController.cpp
420index 581b9c6..4b9f79c 100644
421--- a/system/netd/server/PppController.cpp
422+++ b/system/netd/server/PppController.cpp
423@@ -26,7 +26,6 @@
424
425 #include <dirent.h>
426
427-#include <netinet/in.h>
428 #include <arpa/inet.h>
429
430 #define LOG_TAG "PppController"
431diff --git a/system/netd/server/PppController.h b/system/netd/server/PppController.h
432index cc74c8c..3f45262 100644
433--- a/system/netd/server/PppController.h
434+++ b/system/netd/server/PppController.h
435@@ -17,7 +17,6 @@
436 #ifndef _PPP_CONTROLLER_H
437 #define _PPP_CONTROLLER_H
438
439-#include <linux/in.h>
440
441 #include "List.h"
442
443diff --git a/system/netd/server/ResolverController.h b/system/netd/server/ResolverController.h
444index 39f002d..049bae1 100644
445--- a/system/netd/server/ResolverController.h
446+++ b/system/netd/server/ResolverController.h
447@@ -18,7 +18,7 @@
448 #define _RESOLVER_CONTROLLER_H_
449
450 #include <netinet/in.h>
451-#include <linux/in.h>
452+//#include <linux/in.h>
453
454 class ResolverController {
455 public:
456diff --git a/system/netd/server/RouteController.cpp b/system/netd/server/RouteController.cpp
457index 889779d..1d9f1e4 100644
458--- a/system/netd/server/RouteController.cpp
459+++ b/system/netd/server/RouteController.cpp
460@@ -21,7 +21,8 @@
461 #include <fcntl.h>
462 #include <linux/fib_rules.h>
463 #include <net/if.h>
464-#include <sys/stat.h>
465+#include <sys/stat.h>
466+#include <string.h>
467
468 #include <private/android_filesystem_config.h>
469
470@@ -31,7 +32,7 @@
471 #include "UidRanges.h"
472 #include "DummyNetwork.h"
473
474-#include "base/file.h"
475+#include "android-base/file.h"
476 #define LOG_TAG "Netd"
477 #include "log/log.h"
478 #include "logwrap/logwrap.h"
479@@ -99,7 +100,7 @@ const bool ACTION_ADD = true;
480 const bool ACTION_DEL = false;
481 const bool MODIFY_NON_UID_BASED_RULES = true;
482
483-const char* const RT_TABLES_PATH = "/data/misc/net/rt_tables";
484+const char* const RT_TABLES_PATH = "/etc/iproute2/rt_tables";
485 const mode_t RT_TABLES_MODE = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; // mode 0644, rw-r--r--
486
487 const unsigned ROUTE_FLUSH_ATTEMPTS = 2;
488@@ -181,10 +182,17 @@ void updateTableNamesFile() {
489 // The netlink header is generated by this function based on |action| and |flags|.
490 // Returns -errno if there was an error or if the kernel reported an error.
491 WARN_UNUSED_RESULT int sendNetlinkRequest(uint16_t action, uint16_t flags, iovec* iov, int iovlen) {
492+ #if 0
493 nlmsghdr nlmsg = {
494- .nlmsg_type = action,
495- .nlmsg_flags = flags,
496+ nlmsg_type : action,
497+ nlmsg_flags : flags,
498 };
499+ #else
500+ nlmsghdr nlmsg = {};
501+ nlmsg.nlmsg_type = action;
502+ nlmsg.nlmsg_flags = flags;
503+ #endif
504+
505 iov[0].iov_base = &nlmsg;
506 iov[0].iov_len = sizeof(nlmsg);
507 for (int i = 0; i < iovlen; ++i) {
508@@ -231,11 +239,12 @@ int padInterfaceName(const char* input, char* name, size_t* length, uint16_t* pa
509 *padding = 0;
510 return 0;
511 }
512- *length = strlcpy(name, input, IFNAMSIZ) + 1;
513+ strncpy(name, input, IFNAMSIZ) + 1;
514+ /* *length = strlcpy(name, input, IFNAMSIZ) + 1;
515 if (*length > IFNAMSIZ) {
516 ALOGE("interface name too long (%zu > %u)", *length, IFNAMSIZ);
517 return -ENAMETOOLONG;
518- }
519+ }*/
520 *padding = RTA_SPACE(*length) - RTA_LENGTH(*length);
521 return 0;
522 }
523@@ -283,13 +292,17 @@ WARN_UNUSED_RESULT int modifyIpRule(uint16_t action, uint32_t priority, uint32_t
524 bool isUidRule = (uidStart != INVALID_UID);
525
526 // Assemble a rule request and put it in an array of iovec structures.
527+ #if 0
528 fib_rule_hdr rule = {
529 .action = static_cast<uint8_t>(priority != RULE_PRIORITY_UNREACHABLE ? FR_ACT_TO_TBL :
530 FR_ACT_UNREACHABLE),
531 // Note that here we're implicitly setting rule.table to 0. When we want to specify a
532 // non-zero table, we do this via the FRATTR_TABLE attribute.
533 };
534-
535+ #else
536+ fib_rule_hdr rule = {};
537+ rule.action = static_cast<uint8_t>(priority != RULE_PRIORITY_UNREACHABLE ? FR_ACT_TO_TBL : FR_ACT_UNREACHABLE);
538+ #endif
539 // Don't ever create a rule that looks up table 0, because table 0 is the local table.
540 // It's OK to specify a table ID of 0 when deleting a rule, because that doesn't actually select
541 // table 0, it's a wildcard that matches anything.
542@@ -355,8 +368,10 @@ WARN_UNUSED_RESULT int modifyIpRoute(uint16_t action, uint32_t table, const char
543 uint8_t rawAddress[sizeof(in6_addr)];
544 uint8_t family;
545 uint8_t prefixLength;
546+ ALOGI("[zy]modifyIpRoute before parsePrefix");
547 int rawLength = parsePrefix(destination, &family, rawAddress, sizeof(rawAddress),
548 &prefixLength);
549+ ALOGI("[zy]modifyIpRoute after parsePrefix");
550 if (rawLength < 0) {
551 ALOGE("parsePrefix failed for destination %s (%s)", destination, strerror(-rawLength));
552 return rawLength;
553@@ -400,6 +415,7 @@ WARN_UNUSED_RESULT int modifyIpRoute(uint16_t action, uint32_t table, const char
554 }
555
556 // Assemble a rtmsg and put it in an array of iovec structures.
557+ #if 0
558 rtmsg route = {
559 .rtm_protocol = RTPROT_STATIC,
560 .rtm_type = type,
561@@ -407,7 +423,16 @@ WARN_UNUSED_RESULT int modifyIpRoute(uint16_t action, uint32_t table, const char
562 .rtm_dst_len = prefixLength,
563 .rtm_scope = static_cast<uint8_t>(nexthop ? RT_SCOPE_UNIVERSE : RT_SCOPE_LINK),
564 };
565-
566+ #else
567+ rtmsg route = {};
568+ route.rtm_protocol = RTPROT_STATIC;
569+ route.rtm_type = type;
570+ route.rtm_family = family;
571+ route.rtm_dst_len = prefixLength;
572+ route.rtm_scope = static_cast<uint8_t>(nexthop ? RT_SCOPE_UNIVERSE : RT_SCOPE_LINK);
573+
574+ #endif
575+
576 rtattr rtaDst = { U16_RTA_LENGTH(rawLength), RTA_DST };
577 rtattr rtaGateway = { U16_RTA_LENGTH(rawLength), RTA_GATEWAY };
578
579@@ -740,17 +765,22 @@ WARN_UNUSED_RESULT int modifyPhysicalNetwork(unsigned netId, const char* interfa
580 return -ESRCH;
581 }
582
583+ ALOGE("PhysicalNetwork");
584 if (int ret = modifyIncomingPacketMark(netId, interface, permission, add)) {
585+ ALOGE("modifyIncomingPacketMark ret[%d]", ret);
586 return ret;
587 }
588 if (int ret = modifyExplicitNetworkRule(netId, table, permission, INVALID_UID, INVALID_UID,
589 add)) {
590+ ALOGE("modifyExplicitNetworkRule ret[%d]", ret);
591 return ret;
592 }
593+ #if 0
594 if (int ret = modifyOutputInterfaceRules(interface, table, permission, INVALID_UID, INVALID_UID,
595 add)) {
596 return ret;
597 }
598+ #endif
599 return modifyImplicitNetworkRule(netId, table, permission, add);
600 }
601
602@@ -867,7 +897,7 @@ WARN_UNUSED_RESULT int modifyRoute(uint16_t action, const char* interface, const
603 break;
604 }
605 }
606-
607+ ALOGI("[zy]modifyRoute");
608 int ret = modifyIpRoute(action, table, interface, destination, nexthop);
609 // Trying to add a route that already exists shouldn't cause an error.
610 if (ret && !(action == RTM_NEWROUTE && ret == -EEXIST)) {
611@@ -986,14 +1016,20 @@ int RouteController::addInterfaceToPhysicalNetwork(unsigned netId, const char* i
612 int RouteController::removeInterfaceFromPhysicalNetwork(unsigned netId, const char* interface,
613 Permission permission) {
614 if (int ret = modifyPhysicalNetwork(netId, interface, permission, ACTION_DEL)) {
615+ ALOGE("modifyPhysicalNetwork ret[%d]", ret);
616 return ret;
617 }
618 if (int ret = flushRoutes(interface)) {
619+ ALOGE("flushRoutes ret[%d]", ret);
620 return ret;
621 }
622+
623+ #if 0
624 if (int ret = clearTetheringRules(interface)) {
625+ ALOGE("clearTetheringRules ret[%d]", ret);
626 return ret;
627 }
628+ #endif
629 updateTableNamesFile();
630 return 0;
631 }
632diff --git a/system/netd/server/SoftapController.cpp b/system/netd/server/SoftapController.cpp
633index d9e40a4..cc9c63e 100644
634--- a/system/netd/server/SoftapController.cpp
635+++ b/system/netd/server/SoftapController.cpp
636@@ -34,8 +34,8 @@
637 #include <openssl/sha.h>
638
639 #define LOG_TAG "SoftapController"
640-#include <base/file.h>
641-#include <base/stringprintf.h>
642+#include <android-base/file.h>
643+#include <android-base/stringprintf.h>
644 #include <cutils/log.h>
645 #include <netutils/ifc.h>
646 #include <private/android_filesystem_config.h>
647diff --git a/system/netd/server/SoftapController.h b/system/netd/server/SoftapController.h
648index 7063067..bad1a32 100644
649--- a/system/netd/server/SoftapController.h
650+++ b/system/netd/server/SoftapController.h
651@@ -17,8 +17,8 @@
652 #ifndef _SOFTAP_CONTROLLER_H
653 #define _SOFTAP_CONTROLLER_H
654
655-#include <linux/in.h>
656-#include <net/if.h>
657+//#include <linux/in.h>
658+//#include <net/if.h>
659
660 #define SOFTAP_MAX_BUFFER_SIZE 4096
661 #define AP_BSS_START_DELAY 200000
662diff --git a/system/netd/server/TetherController.cpp b/system/netd/server/TetherController.cpp
663index 88baa31..d32ea0e 100644
664--- a/system/netd/server/TetherController.cpp
665+++ b/system/netd/server/TetherController.cpp
666@@ -29,7 +29,7 @@
667
668 #define LOG_TAG "TetherController"
669 #include <cutils/log.h>
670-#include <cutils/properties.h>
671+//#include <cutils/properties.h>
672
673 #include "Fwmark.h"
674 #include "NetdConstants.h"
675@@ -61,9 +61,13 @@ bool writeToFile(const char* filename, const char* value) {
676
677 bool inBpToolsMode() {
678 // In BP tools mode, do not disable IP forwarding
679+ #if 0
680 char bootmode[PROPERTY_VALUE_MAX] = {0};
681 property_get("ro.bootmode", bootmode, "unknown");
682 return !strcmp(BP_TOOLS_MODE, bootmode);
683+ #else
684+ return false;
685+ #endif
686 }
687
688 } // namespace
689diff --git a/system/netd/server/UidRanges.cpp b/system/netd/server/UidRanges.cpp
690index 10e445a..cd9ac1a 100644
691--- a/system/netd/server/UidRanges.cpp
692+++ b/system/netd/server/UidRanges.cpp
693@@ -19,6 +19,7 @@
694 #include "NetdConstants.h"
695
696 #include <stdlib.h>
697+#include <algorithm>
698
699 bool UidRanges::hasUid(uid_t uid) const {
700 auto iter = std::lower_bound(mRanges.begin(), mRanges.end(), Range(uid, uid));
701diff --git a/system/netd/server/main.cpp b/system/netd/server/main.cpp
702index 5e189cc..3feb10d 100644
703--- a/system/netd/server/main.cpp
704+++ b/system/netd/server/main.cpp
705@@ -33,7 +33,6 @@
706 #include "CommandListener.h"
707 #include "NetlinkManager.h"
708 #include "DnsProxyListener.h"
709-#include "MDnsSdListener.h"
710 #include "FwmarkServer.h"
711
712 static void blockSigpipe();
713@@ -49,7 +48,7 @@ int main() {
714 CommandListener *cl;
715 NetlinkManager *nm;
716 DnsProxyListener *dpl;
717- MDnsSdListener *mdnsl;
718+ //MDnsSdListener *mdnsl;
719 FwmarkServer* fwmarkServer;
720
721 ALOGI("Netd 1.0 starting");
722@@ -78,19 +77,19 @@ int main() {
723 ALOGE("Unable to start DnsProxyListener (%s)", strerror(errno));
724 exit(1);
725 }
726-
727- mdnsl = new MDnsSdListener();
728- if (mdnsl->startListener()) {
729+ //mdnsl = new MDnsSdListener();
730+ /*if (mdnsl->startListener()) {
731 ALOGE("Unable to start MDnsSdListener (%s)", strerror(errno));
732 exit(1);
733- }
734+ }*/
735
736+ #if 0
737 fwmarkServer = new FwmarkServer(CommandListener::sNetCtrl);
738 if (fwmarkServer->startListener()) {
739 ALOGE("Unable to start FwmarkServer (%s)", strerror(errno));
740 exit(1);
741 }
742-
743+ #endif
744 /*
745 * Now that we're up, we can respond to commands
746 */