clatd: skip over virtio_net_hdr
Test: TreeHugger, ping 1.1.1.1 on ipv6-only wifi works
Bug: 265591307
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I88ab5381bd144633ae3d3117c3b340cc2cb0b5fe
diff --git a/clatd.c b/clatd.c
index 284a676..e10bda1 100644
--- a/clatd.c
+++ b/clatd.c
@@ -36,6 +36,7 @@
#include <linux/if_ether.h>
#include <linux/if_packet.h>
#include <linux/if_tun.h>
+#include <linux/virtio_net.h>
#include <net/if.h>
#include <sys/uio.h>
@@ -83,6 +84,7 @@
// we don't really support vlans (or especially Q-in-Q)...
// but a few bytes of extra buffer space doesn't hurt...
struct {
+ struct virtio_net_hdr vnet;
uint8_t payload[22 + MAXMTU];
char pad; // +1 to make packet truncation obvious
} buf;
@@ -125,7 +127,7 @@
}
}
- if (readlen < tp_net) {
+ if (readlen < sizeof(struct virtio_net_hdr) + tp_net) {
logmsg(ANDROID_LOG_WARN, "%s: ignoring %zd byte pkt shorter than %u L2 header",
__func__, readlen, tp_net);
return;
@@ -140,7 +142,7 @@
}
}
- translate_packet(tunnel->fd4, 0 /* to_ipv6 */, buf.payload + tp_net, readlen - tp_net);
+ translate_packet(tunnel->fd4, 0 /* to_ipv6 */, buf.payload + tp_net, readlen - sizeof(struct virtio_net_hdr) - tp_net);
}
// reads TUN_PI + L3 IPv4 packet from tun, translates to IPv6, writes to AF_INET6/RAW socket