summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej Żenczykowski <maze@google.com>2023-06-01 08:58:43 +0000
committerMaciej Żenczykowski <maze@google.com>2023-06-01 09:00:59 +0000
commit8fe16b0c52ff8edc9346a3951ff90787185b7fc8 (patch)
treefe932d0778e349dd8b4c50cff9a176f9069ce6ee
parent9c05f75eaa7d8e04c8f67c2cf6840ec9f79940d0 (diff)
downloadandroid-clat-8fe16b0c52ff8edc9346a3951ff90787185b7fc8.tar.gz
add more logging for missing tpacket_auxdata cmsg
Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: If4ee940d4694e3f3197e14c8da9f9cd80080eee7
-rw-r--r--clatd.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/clatd.c b/clatd.c
index 9a7a45a..bac8b1d 100644
--- a/clatd.c
+++ b/clatd.c
@@ -88,18 +88,29 @@ void process_packet_6_to_4(struct tun_data *tunnel) {
return;
}
+ bool ok = false;
__u32 tp_status = 0;
__u16 tp_net = 0;
for (struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msgh); cmsg != NULL; cmsg = CMSG_NXTHDR(&msgh,cmsg)) {
if (cmsg->cmsg_level == SOL_PACKET && cmsg->cmsg_type == PACKET_AUXDATA) {
struct tpacket_auxdata *aux = (struct tpacket_auxdata *)CMSG_DATA(cmsg);
+ ok = true;
tp_status = aux->tp_status;
tp_net = aux->tp_net;
break;
}
}
+ if (!ok) {
+ // theoretically this should not happen...
+ static bool logged = false;
+ if (!logged) {
+ logmsg(ANDROID_LOG_ERROR, "%s: failed to fetch tpacket_auxdata cmsg", __func__);
+ logged = true;
+ }
+ }
+
const int payload_offset = offsetof(typeof(buf), payload);
if (readlen < payload_offset + tp_net) {
logmsg(ANDROID_LOG_WARN, "%s: ignoring %zd byte pkt shorter than %d+%u L2 header",