Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

system-netd: Commit

system/netd


Commit MetaInfo

Revisión738fbfd8a2a6efc5a2f076ad7e492aeca42c75ca (tree)
Tiempo2017-10-26 05:42:48
Autormeijjaa <jjmeijer88@gmai...>
Commitermeijjaa

Log Message

Merge remote-tracking branch 'x86/nougat-x86' into cm-14.1-x86

Cambiar Resumen

Diferencia

--- a/server/NetworkController.cpp
+++ b/server/NetworkController.cpp
@@ -47,6 +47,8 @@
4747 #include "RouteController.h"
4848 #include "VirtualNetwork.h"
4949
50+#define DBG 0
51+
5052 namespace {
5153
5254 // Keep these in sync with ConnectivityService.java.
@@ -284,12 +286,17 @@ void NetworkController::getNetworkContext(
284286 Fwmark fwmark;
285287 fwmark.netId = nc.app_netid;
286288 fwmark.explicitlySelected = explicitlySelected;
287- fwmark.protectedFromVpn = canProtect(uid);
289+ fwmark.protectedFromVpn = explicitlySelected && canProtect(uid);
288290 fwmark.permission = getPermissionForUser(uid);
289291 nc.app_mark = fwmark.intValue;
290292
291293 nc.dns_mark = getNetworkForDns(&(nc.dns_netid), uid);
292294
295+ if (DBG) {
296+ ALOGD("app_netid:0x%x app_mark:0x%x dns_netid:0x%x dns_mark:0x%x uid:%d",
297+ nc.app_netid, nc.app_mark, nc.dns_netid, nc.dns_mark, uid);
298+ }
299+
293300 if (netcontext) {
294301 *netcontext = nc;
295302 }
--- a/server/NetworkController.h
+++ b/server/NetworkController.h
@@ -113,7 +113,6 @@ private:
113113 std::map<unsigned, Network*> mNetworks; // Map keys are NetIds.
114114 std::map<uid_t, Permission> mUsers;
115115 std::set<uid_t> mProtectableUsers;
116-
117116 };
118117
119118 #endif // NETD_SERVER_NETWORK_CONTROLLER_H
--- a/server/RouteController.cpp
+++ b/server/RouteController.cpp
@@ -73,15 +73,13 @@ const char* const ROUTE_TABLE_NAME_LEGACY_SYSTEM = "legacy_system";
7373 const char* const ROUTE_TABLE_NAME_LOCAL = "local";
7474 const char* const ROUTE_TABLE_NAME_MAIN = "main";
7575
76-// TODO: These values aren't defined by the Linux kernel, because our UID routing changes are not
77-// upstream (yet?), so we can't just pick them up from kernel headers. When (if?) the changes make
78-// it upstream, we'll remove this and rely on the kernel header values. For now, add a static assert
79-// that will warn us if upstream has given these values some other meaning.
80-const uint16_t FRA_UID_START = 18;
81-const uint16_t FRA_UID_END = 19;
82-static_assert(FRA_UID_START > FRA_MAX,
83- "Android-specific FRA_UID_{START,END} values also assigned in Linux uapi. "
84- "Check that these values match what the kernel does and then update this assertion.");
76+// These values are upstream, but not yet in our headers.
77+// TODO: delete these definitions when updating the headers.
78+const uint16_t FRA_UID_RANGE = 20;
79+struct fib_rule_uid_range {
80+ __u32 start;
81+ __u32 end;
82+};
8583
8684 const uint16_t NETLINK_REQUEST_FLAGS = NLM_F_REQUEST | NLM_F_ACK;
8785 const uint16_t NETLINK_CREATE_REQUEST_FLAGS = NETLINK_REQUEST_FLAGS | NLM_F_CREATE | NLM_F_EXCL;
@@ -113,15 +111,14 @@ constexpr uint16_t U16_RTA_LENGTH(uint16_t x) {
113111
114112 // These are practically const, but can't be declared so, because they are used to initialize
115113 // non-const pointers ("void* iov_base") in iovec arrays.
116-rtattr FRATTR_PRIORITY = { U16_RTA_LENGTH(sizeof(uint32_t)), FRA_PRIORITY };
117-rtattr FRATTR_TABLE = { U16_RTA_LENGTH(sizeof(uint32_t)), FRA_TABLE };
118-rtattr FRATTR_FWMARK = { U16_RTA_LENGTH(sizeof(uint32_t)), FRA_FWMARK };
119-rtattr FRATTR_FWMASK = { U16_RTA_LENGTH(sizeof(uint32_t)), FRA_FWMASK };
120-rtattr FRATTR_UID_START = { U16_RTA_LENGTH(sizeof(uid_t)), FRA_UID_START };
121-rtattr FRATTR_UID_END = { U16_RTA_LENGTH(sizeof(uid_t)), FRA_UID_END };
114+rtattr FRATTR_PRIORITY = { U16_RTA_LENGTH(sizeof(uint32_t)), FRA_PRIORITY };
115+rtattr FRATTR_TABLE = { U16_RTA_LENGTH(sizeof(uint32_t)), FRA_TABLE };
116+rtattr FRATTR_FWMARK = { U16_RTA_LENGTH(sizeof(uint32_t)), FRA_FWMARK };
117+rtattr FRATTR_FWMASK = { U16_RTA_LENGTH(sizeof(uint32_t)), FRA_FWMASK };
118+rtattr FRATTR_UID_RANGE = { U16_RTA_LENGTH(sizeof(fib_rule_uid_range)), FRA_UID_RANGE };
122119
123-rtattr RTATTR_TABLE = { U16_RTA_LENGTH(sizeof(uint32_t)), RTA_TABLE };
124-rtattr RTATTR_OIF = { U16_RTA_LENGTH(sizeof(uint32_t)), RTA_OIF };
120+rtattr RTATTR_TABLE = { U16_RTA_LENGTH(sizeof(uint32_t)), RTA_TABLE };
121+rtattr RTATTR_OIF = { U16_RTA_LENGTH(sizeof(uint32_t)), RTA_OIF };
125122
126123 uint8_t PADDING_BUFFER[RTA_ALIGNTO] = {0, 0, 0, 0};
127124
@@ -308,6 +305,7 @@ WARN_UNUSED_RESULT int modifyIpRule(uint16_t action, uint32_t priority, uint8_t
308305
309306 rtattr fraIifName = { U16_RTA_LENGTH(iifLength), FRA_IIFNAME };
310307 rtattr fraOifName = { U16_RTA_LENGTH(oifLength), FRA_OIFNAME };
308+ struct fib_rule_uid_range uidRange = { uidStart, uidEnd };
311309
312310 iovec iov[] = {
313311 { NULL, 0 },
@@ -320,10 +318,8 @@ WARN_UNUSED_RESULT int modifyIpRule(uint16_t action, uint32_t priority, uint8_t
320318 { &fwmark, mask ? sizeof(fwmark) : 0 },
321319 { &FRATTR_FWMASK, mask ? sizeof(FRATTR_FWMASK) : 0 },
322320 { &mask, mask ? sizeof(mask) : 0 },
323- { &FRATTR_UID_START, isUidRule ? sizeof(FRATTR_UID_START) : 0 },
324- { &uidStart, isUidRule ? sizeof(uidStart) : 0 },
325- { &FRATTR_UID_END, isUidRule ? sizeof(FRATTR_UID_END) : 0 },
326- { &uidEnd, isUidRule ? sizeof(uidEnd) : 0 },
321+ { &FRATTR_UID_RANGE, isUidRule ? sizeof(FRATTR_UID_RANGE) : 0 },
322+ { &uidRange, isUidRule ? sizeof(uidRange) : 0 },
327323 { &fraIifName, iif != IIF_NONE ? sizeof(fraIifName) : 0 },
328324 { iifName, iifLength },
329325 { PADDING_BUFFER, iifPadding },
Show on old repository browser