0
0
mirror of https://github.com/openwrt/packages.git synced 2025-07-31 10:21:34 +00:00
Files
packages/net/tayga/patches/002-bigendian_wrong_checksum.patch
Goetz Goerisch 96a1942995 tayga: move to net
* moving to net to align with similar package jool

Signed-off-by: Goetz Goerisch <ggoerisch@gmail.com>
2025-07-24 15:33:18 +02:00

54 lines
1.5 KiB
Diff

--- a/nat64.c
+++ b/nat64.c
@@ -129,6 +129,11 @@ static void log_pkt6(int err, struct pkt
type, saddr, daddr, (p->header_len + p->data_len),p->data_proto,msg);
}
+static uint16_t checksum_extend_byte(uint8_t b)
+{
+ return htons(b << 8);
+}
+
static uint16_t ip_checksum(void *d, int c)
{
uint32_t sum = 0xffff;
@@ -140,7 +145,7 @@ static uint16_t ip_checksum(void *d, int
}
if (c)
- sum += htons(*((uint8_t *)p) << 8);
+ sum += checksum_extend_byte(*((uint8_t *)p));
while (sum > 0xffff)
sum = (sum & 0xffff) + (sum >> 16);
@@ -296,10 +301,12 @@ static int xlate_payload_4to6(struct pkt
cksum = ones_add(p->icmp->cksum, cksum);
if (p->icmp->type == 8) {
p->icmp->type = 128;
- p->icmp->cksum = ones_add(cksum, ~(128 - 8));
+ p->icmp->cksum = ones_add(cksum,
+ ~checksum_extend_byte(128 - 8));
} else {
p->icmp->type = 129;
- p->icmp->cksum = ones_add(cksum, ~(129 - 0));
+ p->icmp->cksum = ones_add(cksum,
+ ~checksum_extend_byte(129 - 0));
}
return ERROR_NONE;
/* UDP */
@@ -892,10 +899,12 @@ static int xlate_payload_6to4(struct pkt
cksum = ones_add(p->icmp->cksum, cksum);
if (p->icmp->type == 128) {
p->icmp->type = 8;
- p->icmp->cksum = ones_add(cksum, 128 - 8);
+ p->icmp->cksum = ones_add(cksum,
+ checksum_extend_byte(128 - 8));
} else {
p->icmp->type = 0;
- p->icmp->cksum = ones_add(cksum, 129 - 0);
+ p->icmp->cksum = ones_add(cksum,
+ checksum_extend_byte(129 - 0));
}
return ERROR_NONE;
/* UDP */