[OpenWrt-Devel] [PATCH 1/3] [packages] tayga: fix broken ICMP checksum on big-endian machines

2014-06-23 Thread Ondřej Caletka
This patches fixes wrong ICMP checksum of translated packets on
big-endian machines #16715
The patch is authored by upstream author
Nathan Lutchansky lutch...@litech.org
Source of the patch: http://forum.mikrotik.com/viewtopic.php?f=15t=82329

Signed-off-by: Ondrej Caletka ond...@caletka.cz
---
 .../patches/002-bigendian_wrong_checksum.patch | 53 ++
 1 file changed, 53 insertions(+)
 create mode 100644 ipv6/tayga/patches/002-bigendian_wrong_checksum.patch

diff --git a/ipv6/tayga/patches/002-bigendian_wrong_checksum.patch 
b/ipv6/tayga/patches/002-bigendian_wrong_checksum.patch
new file mode 100644
index 000..d8deac3
--- /dev/null
+++ b/ipv6/tayga/patches/002-bigendian_wrong_checksum.patch
@@ -0,0 +1,53 @@
+--- a/nat64.c
 b/nat64.c
+@@ -19,6 +19,11 @@
+ 
+ extern struct config *gcfg;
+ 
++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 = 0x;
+@@ -30,7 +35,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  0x)
+   sum = (sum  0x) + (sum  16);
+@@ -180,10 +185,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 0;
+   case 17:
+@@ -668,10 +675,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 0;
+   case 17:
-- 
1.8.5.5
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 1/3] [packages] tayga: fix broken ICMP checksum on big-endian machines

2014-06-23 Thread Steven Barth

Hi Ondrej,

thanks for your efforts. However we are not accepting patches for the 
old packages feed any more. However feel free to import, update and 
maintain the 2 packages in the new feed at

https://github.com/openwrt/packages. You can send a Pull Request there.


Cheers,

Stevem
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel