This is the mail archive of the
ecos-patches@sourceware.org
mailing list for the eCos project.
lwip assertion trigger fix
- From: Uwe Kindler <uwe dot kindler at cetoni dot de>
- To: ecos-patches at sourceware dot org
- Date: Fri, 07 Oct 2005 08:19:37 +0200
- Subject: lwip assertion trigger fix
- Organization: cetoni GmbH
Hello,
the following patch fixes some small bugs in lwip stack. The patches for
the core lwip files are copied from lwip CVS.
Uwe Kindler
uwe.kindler@cetoni.de
http://www.cetoni.de
Index: current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/lwip_tcpip/current/ChangeLog,v
retrieving revision 1.2
diff -u -r1.2 ChangeLog
--- current/ChangeLog 5 May 2004 07:28:32 -0000 1.2
+++ current/ChangeLog 7 Oct 2005 05:56:05 -0000
@@ -1,3 +1,15 @@
+2005-10-07 Uwe Kindler <uwe_kindler@web.de>
+
+ * src/core/tcp_in.c: pbuf_free() assert triggered by
+ NULLified inseg.p
+ * include/lwip/tcp.h Do no longer try to free pbuf
+ when TCP_EVENT_RECV() is called without a callback
+ handler, and without packet.
+ * tests/nc_test_slave.c Fixed test_printf and diag_printf
+ format strings that caused errors or warnings.
+ * tests/nc_test_slave.c Included <lwip/inet.h> - required
+ for compilation
+
2004-05-05 Jani Monoses <jani@iv.ro>
* src/netif/ppp/ppp.c: Decrease sleep period in main thread
Index: current/include/lwip/tcp.h
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/lwip_tcpip/current/include/lwip/tcp.h,v
retrieving revision 1.1
diff -u -r1.1 tcp.h
--- current/include/lwip/tcp.h 4 May 2004 12:32:32 -0000 1.1
+++ current/include/lwip/tcp.h 6 Oct 2005 22:51:42 -0000
@@ -375,7 +375,7 @@
#define TCP_EVENT_RECV(pcb,p,err,ret) \
if((pcb)->recv != NULL) \
{ ret = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err)); } else { \
- pbuf_free(p); }
+ if (p) pbuf_free(p); }
#define TCP_EVENT_CONNECTED(pcb,err,ret) \
if((pcb)->connected != NULL) \
(ret = (pcb)->connected((pcb)->callback_arg,(pcb),(err)))
Index: current/src/core/tcp_in.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/lwip_tcpip/current/src/core/tcp_in.c,v
retrieving revision 1.1
diff -u -r1.1 tcp_in.c
--- current/src/core/tcp_in.c 4 May 2004 12:32:33 -0000 1.1
+++ current/src/core/tcp_in.c 6 Oct 2005 23:01:50 -0000
@@ -351,7 +351,7 @@
increase the reference counter in the pbuf. If so, the buffer
isn't actually deallocated by the call to pbuf_free(), only the
reference count is decreased. */
- pbuf_free(inseg.p);
+ if (inseg.p != NULL) pbuf_free(inseg.p);
#if TCP_INPUT_DEBUG
#if TCP_DEBUG
tcp_debug_print_state(pcb->state);
Index: current/tests/nc_test_slave.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/lwip_tcpip/current/tests/nc_test_slave.c,v
retrieving revision 1.1
diff -u -r1.1 nc_test_slave.c
--- current/tests/nc_test_slave.c 4 May 2004 12:32:33 -0000 1.1
+++ current/tests/nc_test_slave.c 16 Sep 2005 11:58:05 -0000
@@ -42,6 +42,7 @@
#include <lwip/inet.h>
#include <lwip/arch.h>
+#include <lwip/sys.h>
#define LWIP_TIMEVAL_PRIVATE
#include <lwip/sockets.h>
@@ -58,9 +59,14 @@
#define MAIN_THREAD_PRIORITY CYGPKG_NET_THREAD_PRIORITY-2
#define DESIRED_BACKGROUND_LOAD 20
#define CYGHWR_NET_DRIVERS 1
+
+#if 0
static char main_thread_stack[CYGHWR_NET_DRIVERS][STACK_SIZE];
static cyg_thread main_thread_data[CYGHWR_NET_DRIVERS];
static cyg_handle_t main_thread_handle[CYGHWR_NET_DRIVERS];
+#endif
+
+
static char idle_thread_stack[STACK_SIZE];
static cyg_thread idle_thread_data;
static cyg_handle_t idle_thread_handle;
@@ -185,7 +191,7 @@
seq_errors++;
}
} else {
- test_printf("Bad data packet - key: %x/%x, seq: %d\n",
+ test_printf("Bad data packet - key: %lx/%lx, seq: %d\n",
ntohl(tdp->key1), ntohl(tdp->key2),
ntohl(tdp->seq));
}
@@ -358,7 +364,7 @@
seq_errors++;
}
} else {
- test_printf("Bad data packet - key: %x/%x, seq: %d\n",
+ test_printf("Bad data packet - key: %lx/%lx, seq: %d\n",
ntohl(tdp->key1), ntohl(tdp->key2),
ntohl(tdp->seq));
}
@@ -514,8 +520,9 @@
}
void
-net_test(test_param_t param)
+net_test(void *arg)
{
+ test_param_t param = (test_param_t)arg;
// int i;
if (param == 0) {
test_printf("Start Network Characterization - SLAVE\n");
@@ -571,7 +578,7 @@
load_idle = idle_thread_count;
start_load(0); // Shut down background load
percent_load = 100 - ((load_idle * 100) / no_load_idle);
- diag_printf("High Load[%d] = %d => %d%%\n", load_thread_level,
+ diag_printf("High Load[%ld] = %d => %d%%\n", load_thread_level,
(int)idle_thread_count, percent_load);
if ( percent_load > desired_load )
break; // HIGH level is indeed higher
@@ -590,7 +597,7 @@
load_idle = idle_thread_count;
start_load(0); // Shut down background load
percent_load = 100 - ((load_idle * 100) / no_load_idle);
- diag_printf("Load[%d] = %d => %d%%\n", load_thread_level,
+ diag_printf("Load[%ld] = %d => %d%%\n", load_thread_level,
(int)idle_thread_count, percent_load);
if (((high-low) <= 1) || (abs(desired_load-percent_load) <= 2)) break;
if (percent_load < desired_load) {
@@ -612,7 +619,7 @@
load_idle = idle_thread_count;
start_load(0); // Shut down background load
percent_load = 100 - ((load_idle * 100) / no_load_idle);
- diag_printf("Final load[%d] = %d => %d%%\n", load_thread_level,
+ diag_printf("Final load[%ld] = %d => %d%%\n", load_thread_level,
(int)idle_thread_count, percent_load);
// no_load_idle_count_1_second = no_load_idle;
}
Index: current/tests/socket.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/lwip_tcpip/current/tests/socket.c,v
retrieving revision 1.1
diff -u -r1.1 socket.c
--- current/tests/socket.c 4 May 2004 12:32:33 -0000 1.1
+++ current/tests/socket.c 16 Sep 2005 11:37:37 -0000
@@ -32,9 +32,10 @@
/* Simple test-case for the BSD socket API : echo on TCP port 7 */
-#include "lwip/sys.h"
+#include <lwip/sys.h>
#define LWIP_COMPAT_SOCKETS 1
-#include "lwip/sockets.h"
+#include <lwip/sockets.h>
+#include <lwip/inet.h>
char buf[400];
static void