diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-07-23 01:08:03 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-07-23 01:08:03 +0000 |
commit | a8f77ed28b825291963edecff91c462dfe7b51f9 (patch) | |
tree | 00bf302e6b69c9c3b22f2e444bf0c510688dd38d | |
parent | d91543cda3edf47c21ed5655a77e201123339bd3 (diff) | |
parent | b614508cbb1a7b96d4a37dbd77141aa313a6256d (diff) | |
download | netd-android11-d1-s5-release.tar.gz |
Snap for 6701819 from b614508cbb1a7b96d4a37dbd77141aa313a6256d to rvc-d1-releaseandroid-11.0.0_r9android-11.0.0_r8android-11.0.0_r7android-11.0.0_r15android-11.0.0_r14android-11.0.0_r13android-11.0.0_r12android-11.0.0_r11android-11.0.0_r10android11-d1-s7-releaseandroid11-d1-s6-releaseandroid11-d1-s5-releaseandroid11-d1-s1-releaseandroid11-d1-release
Change-Id: I03621904a89a036ad363c2b5b368658dcb6de012
-rw-r--r-- | bpf_progs/clatd.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/bpf_progs/clatd.c b/bpf_progs/clatd.c index 102ecd96..e7586928 100644 --- a/bpf_progs/clatd.c +++ b/bpf_progs/clatd.c @@ -26,6 +26,10 @@ #include <stdbool.h> #include <stdint.h> +// bionic kernel uapi linux/udp.h header is munged... +#define __kernel_udphdr udphdr +#include <linux/udp.h> + #include "bpf_helpers.h" #include "bpf_net_helpers.h" #include "netdbpf/bpf_shared.h" @@ -226,9 +230,18 @@ int sched_cls_egress_clat_rawip(struct __sk_buff* skb) { switch (ip4->protocol) { case IPPROTO_TCP: // For TCP & UDP the checksum neutrality of the chosen IPv6 - case IPPROTO_UDP: // address means there is no need to update their checksums. - case IPPROTO_GRE: // We do not need to bother looking at GRE/ESP headers, - case IPPROTO_ESP: // since there is never a checksum to update. + case IPPROTO_GRE: // address means there is no need to update their checksums. + case IPPROTO_ESP: // We do not need to bother looking at GRE/ESP headers, + break; // since there is never a checksum to update. + + case IPPROTO_UDP: // See above comment, but must also have UDP header... + if (data + sizeof(*ip4) + sizeof(struct udphdr) > data_end) return TC_ACT_OK; + const struct udphdr* uh = (const struct udphdr*)(ip4 + 1); + // If IPv4/UDP checksum is 0 then fallback to clatd so it can calculate the + // checksum. Otherwise the network or more likely the NAT64 gateway might + // drop the packet because in most cases IPv6/UDP packets with a zero checksum + // are invalid. See RFC 6935. TODO: calculate checksum via bpf_csum_diff() + if (!uh->check) return TC_ACT_OK; break; default: // do not know how to handle anything else |