lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Problem by IP REASSEMBLY and pbuf


From: Amir Bukhari
Subject: [lwip-users] Problem by IP REASSEMBLY and pbuf
Date: Mon, 23 Oct 2006 16:49:17 +0200

When I activate IP_REASSEMBLY and ping my system with big packets (30Kb), the 
pbuf got currupted,

Exactly here (in ip_reass(..) :
###############
for (q = p; q != NULL; q = q->next) {
          /* Copy enough bytes to fill this pbuf in the chain. The
             available data in the pbuf is given by the q->len variable. */
          LWIP_DEBUGF(IP_REASS_DEBUG,
           ("ip_reass: memcpy from %p (%"S16_F") to %p, %"S16_F" bytes\n",
            (void *)&ip_reassbuf[i], i, q->payload,
            q->len > ip_reasslen - i ? ip_reasslen - i : q->len));
            //kprintf("q=%p i=%d q->next = %p \n", q, i, q->next);
          memcpy(q->payload, &ip_reassbuf[i],
            q->len > ip_reasslen - i ? ip_reasslen - i : q->len);
          i += q->len;
        }
##########
The q->next at somepoint it point to invalid memory address!!
It seems to be a compiler problem. I use lwip with MPC5200 and powerpc is very 
sensitive to memory alignment.
I solved the problem by using __attribute__ ((__aligned__(32))). 32 is optimise 
for cache line.
In ip_frags I set the following:
static u8_t ip_reassbuf[IP_HLEN + IP_REASS_BUFSIZE]  __attribute__ 
((__aligned__(32)));
static u8_t ip_reassbitmap[IP_REASS_BUFSIZE / (8 * 8) + 1]  __attribute__ 
((__aligned__(32)));

in pbuf.c
static u8_t pbuf_pool_memory[MEM_ALIGNMENT - 1 + PBUF_POOL_SIZE * 
MEM_ALIGN_SIZE(PBUF_POOL_BUFSIZE + sizeof(struct pbuf))] __attribute__ 
((__aligned__(32)));

is any idea to make this universal, for example using struct as different 
compiler can determine the align here.

Note:
I have arrived a ping of 50Kb in my system with:
ping 192.168.1.231 -s 50024 -f
and lost only one packet like:
163 packets transmitted, 162 received, 0% packet loss, time 1959ms
rtt min/avg/max/mdev = 11.106/11.130/11.567/0.103 ms, pipe 2, ipg/ewma 
12.097/11.128 ms

but over 650024 I got 100% lost. 
I use pbuf pools and PBUF_POOL_BUFSIZE size is a 1536 bytes and PBUF_POOL_SIZE 
is 2048.

-------------------------------------------------------------
Amir Bukhari
aquintos GmbH * integration experts
Lammstraße 21 * 76133 Karlsruhe * GERMANY
phone: 0721 / 516 38-0
Mobile +49-179-7318737
Mail: address@hidden
Web: http://www.aquintos.com




reply via email to

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