From: Denis Kenzior <denkenz@gmail.com>
To: connman@lists.linux.dev
Cc: Denis Kenzior <denkenz@gmail.com>
Subject: [PATCH] gdhcp: Allow client to work on veth devices
Date: Wed, 17 Apr 2024 11:22:24 -0500 [thread overview]
Message-ID: <20240417162243.3373629-1-denkenz@gmail.com> (raw)
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.
---
gdhcp/client.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/gdhcp/client.c b/gdhcp/client.c
index c58c7be91143..2afa19e6e2ea 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)));
--
2.44.0
next reply other threads:[~2024-04-17 16:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-17 16:22 Denis Kenzior [this message]
2024-04-17 17:00 ` [PATCH] gdhcp: Allow client to work on veth devices patchwork-bot+connman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240417162243.3373629-1-denkenz@gmail.com \
--to=denkenz@gmail.com \
--cc=connman@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.