lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] ip_frag buf alignment


From: Marc Boucher
Subject: [lwip-users] ip_frag buf alignment
Date: Mon, 14 Apr 2003 13:45:26 -0400
User-agent: Mutt/1.5.1i

Hi folks,

It seems that there is a memory alignment issue
in core/ipv4/ip_frag.c: buf[] isn't guaranteed
to be properly aligned for 16 bit accesses on all
platforms as presently declared. This causes
traps on some systems. The patch below attempts
to fix the issue (and eliminate an unused argument
warning while we're there).

Regards
Marc

--- ip_frag.c.old       2003-04-14 13:19:24.000000000 -0400
+++ ip_frag.c   2003-04-14 13:27:05.000000000 -0400
@@ -93,6 +93,7 @@
 static void 
 ip_reass_timer(void *arg)
 {
+  (void)arg;
   if(ip_reasstmr > 1) {
     ip_reasstmr--;
     sys_timeout(IP_REASS_TMO, ip_reass_timer, NULL);
@@ -276,7 +277,7 @@
 }
 
 #define MAX_MTU 1500
-static u8_t buf[MAX_MTU];
+static u8_t buf[MEM_ALIGN_SIZE(MAX_MTU)];
 
 /**
  * Fragment an IP packet if too large
@@ -301,7 +302,7 @@
   /* Get a RAM based MTU sized pbuf */
   rambuf = pbuf_alloc(PBUF_LINK, 0, PBUF_REF);
   rambuf->tot_len = rambuf->len = mtu;
-  rambuf->payload = buf;
+  rambuf->payload = MEM_ALIGN((void *)buf);
 
 
   /* Copy the IP header in it */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]