clat: enable PACKET_VNET_HDR on v6 ingress
We need the checksum information this 10-byte extra header provides.
Note: this must be merged in combination with a change to userspace
clatd to at least skip over the new 10 byte header (and increase
the read buffer size).
Test: TreeHugger, ping 1.1.1.1 on v6-only wifi
Bug: 265591307
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I35948a7ac463473300e45f37bc16b5b8d629d63c
diff --git a/service/jni/com_android_server_connectivity_ClatCoordinator.cpp b/service/jni/com_android_server_connectivity_ClatCoordinator.cpp
index dae45f3..062d272 100644
--- a/service/jni/com_android_server_connectivity_ClatCoordinator.cpp
+++ b/service/jni/com_android_server_connectivity_ClatCoordinator.cpp
@@ -182,12 +182,19 @@
throwIOException(env, "packet socket failed", errno);
return -1;
}
- int on = 1;
+ const int on = 1;
+ // enable tpacket_auxdata cmsg delivery, which includes L2 header length
if (setsockopt(sock, SOL_PACKET, PACKET_AUXDATA, &on, sizeof(on))) {
throwIOException(env, "packet socket auxdata enablement failed", errno);
close(sock);
return -1;
}
+ // needed for virtio_net_hdr prepending, which includes checksum metadata
+ if (setsockopt(sock, SOL_PACKET, PACKET_VNET_HDR, &on, sizeof(on))) {
+ throwIOException(env, "packet socket vnet_hdr enablement failed", errno);
+ close(sock);
+ return -1;
+ }
return sock;
}