clatd: fix endianness of multicast drop

This is a *critical* fix for http://go/aog/3514294
  'Drop egress multicast on clat interface'

Bug: 404457155
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If14ef730f78c7e991842a678260dd20df607b1ec
This commit is contained in:
Maciej Żenczykowski 2025-03-21 12:36:45 -07:00
commit 30020a513a
2 changed files with 3 additions and 3 deletions

View file

@ -289,7 +289,7 @@ DEFINE_BPF_PROG("schedcls/egress4/clat_rawip", AID_ROOT, AID_SYSTEM, sched_cls_e
if (ip4->ihl != 5) return TC_ACT_PIPE;
// Packet must not be multicast
if ((ip4->daddr & 0xf0000000) == 0xe0000000) return TC_ACT_PIPE;
if ((ip4->daddr & htonl(0xf0000000)) == htonl(0xe0000000)) return TC_ACT_PIPE;
// Calculate the IPv4 one's complement checksum of the IPv4 header.
__wsum sum4 = 0;

View file

@ -85,8 +85,8 @@ int ipv4_packet(clat_packet out, clat_packet_index pos, const uint8_t *packet, s
return 0;
}
if ((header->daddr & 0xf0000000) == 0xe0000000) {
logmsg_dbg(ANDROID_LOG_INFO, "ip_packet/daddr is multicast: %x", header->daddr);
if ((header->daddr & htonl(0xf0000000)) == htonl(0xe0000000)) {
logmsg_dbg(ANDROID_LOG_INFO, "ip_packet/daddr is multicast: %x", ntohl(header->daddr));
return 0;
}