From: Chad Brubaker Date: Mon, 24 Feb 2014 23:45:10 +0000 (-0800) Subject: Allow overlap in UidMarkMap X-Git-Tag: android-x86-7.1-r1~209^2~2^2~1^2^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=2ebaf119e2bfd566910020d7ba01c8b12bc5fdf1;p=android-x86%2Fsystem-netd.git Allow overlap in UidMarkMap To support simultaneous tuns UidMarkMap now allows for overlaping/duplicate rules. If there are multiple rules for a given uid the most recently added rule will be used in all cases. When overlapping rules are added in addUidRule there may be multiple iptables rules matching the uid. Since addUidRule appends it will use the most recent rule as well, no change required. Previously UidMarkMap->add would fail and the rule would never be added. Bug: 12134439 Change-Id: I5f2976dd3ee334584a9f98f6eacd5edbe5c9bb6b --- diff --git a/UidMarkMap.cpp b/UidMarkMap.cpp index d30ac53..5fc9ce0 100644 --- a/UidMarkMap.cpp +++ b/UidMarkMap.cpp @@ -27,16 +27,9 @@ bool UidMarkMap::add(int uid_start, int uid_end, int mark) { if (uid_start > uid_end) { return false; } - android::netd::List::iterator it; - for (it = mMap.begin(); it != mMap.end(); it++) { - UidMarkEntry *entry = *it; - if (entry->uid_start <= uid_end && uid_start <= entry->uid_end) { - return false; - } - } UidMarkEntry *e = new UidMarkEntry(uid_start, uid_end, mark); - mMap.push_back(e); + mMap.push_front(e); return true; };