diff options
author | Denis Kenzior <denkenz@gmail.com> | 2024-04-05 17:16:50 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2024-04-17 11:21:40 -0500 |
commit | 1d064a14ce457ac1ddf123ddff3a44dff904ec48 (patch) | |
tree | 838f0bb496f47f6f1e3a673d826ab68eb9ab37c7 | |
parent | 49b16df36de0604c55d596119b2350c5c327a517 (diff) | |
download | connman-1d064a14ce457ac1ddf123ddff3a44dff904ec48.tar.gz |
gdhcp: Allow client to work on veth devices
veth devices do not compute a checksum over the entire message. They
simply pre-compute the pseudo-header portion and include this in the
checksum field. Support such devices by computing the partial checksum.
If the partial checksum matches, accept the packet.
-rw-r--r-- | gdhcp/client.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gdhcp/client.c b/gdhcp/client.c index c58c7be91..2afa19e6e 100644 --- a/gdhcp/client.c +++ b/gdhcp/client.c @@ -1355,8 +1355,13 @@ static int dhcp_recv_l2_packet(struct dhcp_packet *dhcp_pkt, int fd, packet.ip.tot_len = packet.udp.len; /* yes, this is needed */ check = packet.udp.check; packet.udp.check = 0; - if (check && check != dhcp_checksum(&packet, bytes)) - return -1; + + if (check) { + uint16_t partial = ~dhcp_checksum(&packet, sizeof(struct iphdr)); + + if (check != partial && check != dhcp_checksum(&packet, bytes)) + return -1; + } memcpy(dhcp_pkt, &packet.data, bytes - (sizeof(packet.ip) + sizeof(packet.udp))); |