connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] gdhcp: Allow client to work on veth devices
@ 2024-04-17 16:22 Denis Kenzior
  2024-04-17 17:00 ` patchwork-bot+connman
  0 siblings, 1 reply; 2+ messages in thread
From: Denis Kenzior @ 2024-04-17 16:22 UTC (permalink / raw)
  To: connman; +Cc: Denis Kenzior

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] gdhcp: Allow client to work on veth devices
  2024-04-17 16:22 [PATCH] gdhcp: Allow client to work on veth devices Denis Kenzior
@ 2024-04-17 17:00 ` patchwork-bot+connman
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+connman @ 2024-04-17 17:00 UTC (permalink / raw)
  To: Denis Kenzior; +Cc: connman

Hello:

This patch was applied to connman.git (master)
by Denis Kenzior <denkenz@gmail.com>:

On Wed, 17 Apr 2024 11:22:24 -0500 you wrote:
> 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(-)

Here is the summary with links:
  - gdhcp: Allow client to work on veth devices
    https://git.kernel.org/pub/scm/network/connman/connman.git/?id=1d064a14ce45

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-17 17:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-17 16:22 [PATCH] gdhcp: Allow client to work on veth devices Denis Kenzior
2024-04-17 17:00 ` patchwork-bot+connman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).