summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Paul Jensen <pauljensen@google.com> 2016-03-22 14:23:46 -0400
committer Paul Jensen <pauljensen@google.com> 2016-03-22 14:23:46 -0400
commit7c34b15f749fdc4889cf2ee77edab9f017281c65 (patch)
tree6f2a8406a4d76309b6fe9526e32238e1e1b53cef
parent39c0d42f8120eae5f8c56a6acd223998a1debc3e (diff)
Fix APF programs to not generate a failing compare of size 0
Don't generate JNEBS instruction for 0 bytes as it always fails the ASSERT_FORWARD_IN_PROGRAM(pc + cmp_imm - 1) check where cmp_imm is the number of bytes to compare. ApfFilter currently attempts to generate JNEBS for 0 bytes for the non-lifetime piece between the valid and preferred lifetimes in the prefix option. From my testing this fixes RA filtering on bullhead on GoogleGuest. Bug: 27768019 Change-Id: Id409da55d02767799fb5e3f9d0e9f72ac94d497f
-rw-r--r--services/core/java/com/android/server/connectivity/ApfFilter.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/connectivity/ApfFilter.java b/services/core/java/com/android/server/connectivity/ApfFilter.java
index 001466515c17..824db6541001 100644
--- a/services/core/java/com/android/server/connectivity/ApfFilter.java
+++ b/services/core/java/com/android/server/connectivity/ApfFilter.java
@@ -411,11 +411,17 @@ public class ApfFilter {
for (int i = 0; i < mNonLifetimes.size(); i++) {
// Generate code to match the packet bytes
Pair<Integer, Integer> nonLifetime = mNonLifetimes.get(i);
- gen.addLoadImmediate(Register.R0, nonLifetime.first);
- gen.addJumpIfBytesNotEqual(Register.R0,
- Arrays.copyOfRange(mPacket.array(), nonLifetime.first,
- nonLifetime.first + nonLifetime.second),
- nextFilterLabel);
+ // Don't generate JNEBS instruction for 0 bytes as it always fails the
+ // ASSERT_FORWARD_IN_PROGRAM(pc + cmp_imm - 1) check where cmp_imm is
+ // the number of bytes to compare. nonLifetime is zero between the
+ // valid and preferred lifetimes in the prefix option.
+ if (nonLifetime.second != 0) {
+ gen.addLoadImmediate(Register.R0, nonLifetime.first);
+ gen.addJumpIfBytesNotEqual(Register.R0,
+ Arrays.copyOfRange(mPacket.array(), nonLifetime.first,
+ nonLifetime.first + nonLifetime.second),
+ nextFilterLabel);
+ }
// Generate code to test the lifetimes haven't gone down too far
if ((i + 1) < mNonLifetimes.size()) {
Pair<Integer, Integer> nextNonLifetime = mNonLifetimes.get(i + 1);