diff options
author | Aaron Huang <huangaaron@google.com> | 2019-05-14 16:58:39 +0800 |
---|---|---|
committer | Aaron Huang <huangaaron@google.com> | 2019-05-14 19:58:16 +0800 |
commit | 47178cfcd8247c87e340a9d32ffa3432dcd48198 (patch) | |
tree | 68834d28c03eef339185b4f283cfb4b29c1abcba /tests/src/android/net/apf/ApfTest.java | |
parent | 1b362169ec921ab9a00a5ce4da85b6a42a5797a9 (diff) |
apf: Remove IPv6 NAT-T keepalive related codes and ApfTest improvement
Remove IPv6 related codes since we don't support IPv6 NAT-T keepalive
as the kernel doesn't support IPv6 UDP encapsulation.
Renaming keepaliveAck to keepaliveResponce since NAT-T keeaplive
response is not an ack. Also, add generateV4NattKeepaliveFilters()
if multicast filter is disabled.
Verify incoming packet contains 1 byte payload but it is not 0xff will
pass NAT-T keepalive filter.
Bug: 33530442
Test: atest FrameworksNetTests
atest NetworkStackTests
Change-Id: Ifb9e088c0c8d71c763ebd9ad122103d0f97ca278
Diffstat (limited to 'tests/src/android/net/apf/ApfTest.java')
-rw-r--r-- | tests/src/android/net/apf/ApfTest.java | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/tests/src/android/net/apf/ApfTest.java b/tests/src/android/net/apf/ApfTest.java index 41c3fab..8f2b968 100644 --- a/tests/src/android/net/apf/ApfTest.java +++ b/tests/src/android/net/apf/ApfTest.java @@ -1734,7 +1734,8 @@ public class ApfTest { final int dstPort = 4500; final int slot1 = 1; // NAT-T keepalive - final byte[] payload = {(byte) 0xff}; + final byte[] kaPayload = {(byte) 0xff}; + final byte[] nonKaPayload = {(byte) 0xfe}; // src: 10.0.0.5, port: 1024 // dst: 10.0.0.6, port: 4500 @@ -1753,15 +1754,21 @@ public class ApfTest { // Verify IPv4 keepalive packet is dropped // src: 10.0.0.6, port: 4500 // dst: 10.0.0.5, port: 1024 - final byte[] nattKaPkt = ipv4UdpPacket(IPV4_KEEPALIVE_DST_ADDR, + byte[] pkt = ipv4UdpPacket(IPV4_KEEPALIVE_DST_ADDR, IPV4_KEEPALIVE_SRC_ADDR, dstPort, srcPort, 1 /* dataLength */); - System.arraycopy(payload, 0, nattKaPkt, IPV4_UDP_PAYLOAD_OFFSET, payload.length); - assertDrop(program, nattKaPkt); - // Verify IPv4 non-keepalive packet from the same source address is passed + System.arraycopy(kaPayload, 0, pkt, IPV4_UDP_PAYLOAD_OFFSET, kaPayload.length); + assertDrop(program, pkt); + + // Verify a packet with payload length 1 byte but it is not 0xff will pass the filter. + System.arraycopy(nonKaPayload, 0, pkt, IPV4_UDP_PAYLOAD_OFFSET, nonKaPayload.length); + assertPass(program, pkt); + + // Verify IPv4 non-keepalive response packet from the same source address is passed assertPass(program, ipv4UdpPacket(IPV4_KEEPALIVE_DST_ADDR, IPV4_KEEPALIVE_SRC_ADDR, dstPort, srcPort, 10 /* dataLength */)); - // Verify IPv4 non-keepalive packet from other source address is passed + + // Verify IPv4 non-keepalive response packet from other source address is passed assertPass(program, ipv4UdpPacket(IPV4_ANOTHER_ADDR, IPV4_KEEPALIVE_SRC_ADDR, dstPort, srcPort, 10 /* dataLength */)); |