OSDN Git Service

Allow overlap in UidMarkMap
authorChad Brubaker <cbrubaker@google.com>
Mon, 24 Feb 2014 23:45:10 +0000 (15:45 -0800)
committerChad Brubaker <cbrubaker@google.com>
Sat, 15 Mar 2014 22:30:13 +0000 (15:30 -0700)
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

UidMarkMap.cpp

index d30ac53..5fc9ce0 100644 (file)
@@ -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<UidMarkEntry*>::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;
 };