diff options
author | Maciej Żenczykowski <maze@google.com> | 2023-03-14 23:22:19 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2023-03-14 23:22:19 +0000 |
commit | b13f6a4f50646226dbc7b56758a809d5152ec882 (patch) | |
tree | 002567566a4b11c3630baeb1ade674cc126fd6e3 | |
parent | 43de18bce93fab415f6e08a4e8747a5a9444e511 (diff) | |
parent | 206b238eb9ac4d634fa2bd515819a0b480bab067 (diff) | |
download | android-clat-b13f6a4f50646226dbc7b56758a809d5152ec882.tar.gz |
Merge "clatd: use struct instead of direct u8[] for buffer"
-rw-r--r-- | clatd.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -77,14 +77,17 @@ int ipv6_address_changed(const char *interface) { } } -// reads L3 IPv6 packet from AF_PACKET socket, translates to IPv4, writes to tun +// reads IPv6 packet from AF_PACKET socket, translates to IPv4, writes to tun void process_packet_6_to_4(struct tun_data *tunnel) { // ethernet header is 14 bytes, plus 4 for a normal VLAN tag or 8 for Q-in-Q // we don't really support vlans (or especially Q-in-Q)... // but a few bytes of extra buffer space doesn't hurt... - uint8_t buf[22 + MAXMTU + 1]; // +1 to make packet truncation obvious + struct { + uint8_t payload[22 + MAXMTU]; + char pad; // +1 to make packet truncation obvious + } buf; struct iovec iov = { - .iov_base = buf, + .iov_base = &buf, .iov_len = sizeof(buf), }; char cmsg_buf[CMSG_SPACE(sizeof(struct tpacket_auxdata))]; @@ -137,7 +140,7 @@ void process_packet_6_to_4(struct tun_data *tunnel) { } } - translate_packet(tunnel->fd4, 0 /* to_ipv6 */, buf + tp_net, readlen - tp_net); + translate_packet(tunnel->fd4, 0 /* to_ipv6 */, buf.payload + tp_net, readlen - tp_net); } // reads TUN_PI + L3 IPv4 packet from tun, translates to IPv6, writes to AF_INET6/RAW socket |