clat: enable PACKET_AUXDATA cmsg reception

(this should effectively still be a no-op, as the socket
is read() from in clatd, that will change in another commit)

Bug: 259872525
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ice6c0440a98219a54c51e9bd41f5bc77e4067d11
This commit is contained in:
Maciej Żenczykowski 2023-01-17 21:00:31 +00:00
commit c80fc96be2

View file

@ -19,6 +19,7 @@
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <linux/if_packet.h>
#include <linux/if_tun.h>
#include <linux/ioctl.h>
#include <log/log.h>
@ -184,6 +185,12 @@ static jint com_android_server_connectivity_ClatCoordinator_openPacketSocket(JNI
throwIOException(env, "packet socket failed", errno);
return -1;
}
int on = 1;
if (setsockopt(sock, SOL_PACKET, PACKET_AUXDATA, &on, sizeof(on))) {
throwIOException(env, "packet socket auxdata enablement failed", errno);
close(sock);
return -1;
}
return sock;
}