On Sat, Mar 14, 2009 at 06:53:23PM +0200, Sergei Gavrikov wrote: > On Sat, Mar 14, 2009 at 06:05:31PM +0200, Sergei Gavrikov wrote: > > On Sat, Mar 14, 2009 at 09:46:46AM -0600, Gary Thomas wrote: > > > Sergei Gavrikov wrote: > > > > Hi > > > > > > > > A few days ago I needed to run lwIP on sl0. I ran into two problems. It > > > > seemed for me what a medice can be interesting. Please, look at the > > > > http://bugs.ecos.sourceware.org/show_bug.cgi?id=1000717 for details. > > > > > > is it working with these changes? > > > > It works with my tweaks the slipif.c and sio.c. I attach minimal ecm > > what I use on olpce2294 here. > > Garry, I would want tojthat another person test it on another platform. > Perhaps, I must investigate a bit more time to be sure that tweaks do > not break PPP stuff. I did not test eCos lwIP PPP with and without the > tweaks. I will do it and then report about.
It was surprise for me that I could not build PPP with CYGDBG_LWIP_DEBUG: http://bugs.ecos.sourceware.org/show_bug.cgi?id=1000719 Then I built it. It ran, my tweaks no break input. I'm sorry, I have no time this sunday to set up host side PPP things. Instead, I write a memo what I done _exactly_ when I tested SLIP. Perhaps, the next weekend, I'll get and PPP memo, but, I wonder, is eCos lwIP PPP worked without the dances before? Sergei Appendix The first run lwIP PPP in GDB Continuing. netif_set_ipaddr: netif address being changed netif: IP address of interface set to 127.0.0.1 netif: netmask of interface set to 255.0.0.0 netif: GW address of interface set to 127.0.0.1 netif: added interface lo IP addr 127.0.0.1 netmask 255.0.0.0 gw 127.0.0.1 lcp_init: xmit_accm=0 0 0 0 upap_init: 0 lcp_init: xmit_accm=0 0 0 0 pbuf_alloc(length=1504) pbuf_alloc(length=1504) == 0x8105a654 pppMain: unit 0: Connecting tcpip_thread: CALLBACK 0x8105be78 pppStartCB: unit 0 ppp_set_xaccm[0]: outACCM=0 0 0 0 ppp_send_config[0]: outACCM=FF FF FF FF ppp_recv_config[0]: inACCM=0 0 0 0 lcp_lowerup: asyncmap=0 0 0 0 LCP: lowerup state 0 -> 2 auth_reset: 0 lcp_addci: L opt=2 0 lcp_addci: L opt=5 52181044 lcp_addci: opt=7 lcp_addci: opt=8 pbuf_alloc(length=0) pbuf_alloc: allocated pbuf 0x8105bf78 pbuf_alloc(length=0) == 0x8105bf78 pppWrite[0]: len=46 pbuf_free(0x8105bf78) pbuf_free: deallocating 0x8105bf78 fsm_sdata(LCP): Sent code 1,1,20. LCP: sending Configure-Request, id 1 LCP: open state 2 -> 6 tcpip_thread: API message 0x8105be78 tcpip_thread: API message 0x8105be78 tcp_bind: bind to port 7 tcpip_thread: API message 0x8105be78 pppMainWakeup: unit 0 sio_read len=1504 returned 0 pppMainWakeup: unit 0 sio_read len=1504 returned 0 pppMainWakeup: unit 0 sio_read len=1504 returned 0 [snip] tcpip: ip_reass_tmr() pppMainWakeup: unit 0 sio_read len=1504 returned 0 pppMainWakeup: unit 0 sio_read len=1504 returned 0 pppMainWakeup: unit 0 sio_read len=1504 returned 0 pppMainWakeup: unit 0 sio_read len=1504 returned 0 LCP: timeout resending Config-Request state=6 lcp_addci: L opt=2 0 lcp_addci: L opt=5 52181044 lcp_addci: opt=7 lcp_addci: opt=8 pbuf_alloc(length=0) pbuf_alloc: allocated pbuf 0x8105bf78 pbuf_alloc(length=0) == 0x8105bf78 pppWrite[0]: len=47 pbuf_free(0x8105bf78) pbuf_free: deallocating 0x8105bf78 fsm_sdata(LCP): Sent code 1,1,20. LCP: sending Configure-Request, id 1 pppMainWakeup: unit 0 sio_read len=1504 returned 0 pppMainWakeup: unit 0 sio_read len=1504 returned 0 [snip]
eCos lwIP over serial (SLIP) It was written as memo for myself 2009/03/14. Note: All outputs is either original copy and paste stuff or redirected outputs just in this memo. *** i. Patching a proposed patch: http://ecos.sourceware.org/ml/ecos-patches/2009-03/msg00020.html Note: Then I found that sio.c does not use buffered sio_{read,write} for SLIP. It uses sio_{recv,send} only. To be sure what I use a clean CVS (cd $ECOS_REPOSITORY/net/lwip_tcpip/current && cvs -qz3 up -d -P) I seen no output. Try the patch patch --dry-run -p0 -d $ECOS_REPOSITORY/net/lwip_tcpip/current <lwip_slip.patch patching file ChangeLog patching file src/ecos/sio.c patching file src/netif/slipif.c So far, so good. Apply the patch patch -p0 -d $ECOS_REPOSITORY/net/lwip_tcpip/current <lwip_slip.patch patching file ChangeLog patching file src/ecos/sio.c patching file src/netif/slipif.c *** ii. Build tests for SLIP interface Let's build lwip_tcpip tests to run them in GDB. My target (olpce2294) has two serial ports. I'll change some defaults to be able to set up SLIP interface on the target's interface '/dev/ser1', I will plan to use CPU's UART0 for GDB as I do it as well. export target=olpce2294 mkdir lwip_slip cd !$ ecosconfig new $target lwip_ppp U CYGHWR_HAL_ARM_LPC2XXX, new inferred value LPC2294 U CYGPKG_IO_SERIAL_GENERIC_16X5X_XMIT_REQUIRE_PRIME, new inferred value 1 U CYGPKG_IO_SERIAL_DEVICES, new inferred value 1 U CYGPKG_LWIP_ETH, new inferred value 0 vi ecos.ecc ecosconfig resolve What I changed exactly? The below is a real filtered output which I commented. It seems for me that exported ECM is not good thing for an illustration, because it will contains and target specific and extra things. grep -v \# ecos.ecc|grep -B2 ' user_value' # s/ -O2// cdl_option CYGBLD_GLOBAL_CFLAGS { user_value "-Wall -Wpointer-arith -Wstrict-prototypes -Wundef -Woverloaded-virtual -Wno-write-strings -mno-thumb-interwork -mcpu=arm7tdmi -g -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions" -- # sio_open() needs it. cdl_option CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING { user_value 1 -- # Ditto. cdl_component CYGPKG_IO_SERIAL_FLOW_CONTROL { user_value 1 -- # No, thanks. cdl_component CYGOPT_IO_SERIAL_FLOW_CONTROL_SOFTWARE { user_value 0 -- # Don't break my debug channel. cdl_component CYGPKG_IO_SERIAL_ARM_LPC2XXX_SERIAL0 { user_value 0 -- # I like it more than 38400. cdl_option CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL1_BAUD { user_value 115200 -- # My target has enough RAM, default is 128. cdl_option CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL1_BUFSIZE { user_value 4096 -- # When I digged in the hangs three the below options were very useful # for me, but, keep in a mind that does penalty a throughput in 20 # times. Now I can unset the setting. cdl_component CYGDBG_LWIP_DEBUG { user_value 0 -- cdl_option CYGDBG_LWIP_DEBUG_TCP { user_value 0 -- cdl_option CYGDBG_LWIP_ASSERTS { user_value 0 -- # Host's side. cdl_option CYGDAT_LWIP_SERV_ADDR { user_value 192,168,1,1 -- # Target's side. cdl_option CYGDAT_LWIP_MY_ADDR { user_value 192,168,1,222 -- # It's p-t-p. cdl_option CYGDAT_LWIP_NETMASK { user_value 255,255,255,255 -- # It's what I want. cdl_component CYGPKG_LWIP_SLIP { user_value 1 -- # The 2nd serial port uses itself to set up SLIP. cdl_option CYGDAT_LWIP_SLIP_DEV { user_value "\"/dev/ser1\"" -- # Reject PPP code. cdl_component CYGPKG_LWIP_PPP { user_value 0 -- cdl_option CYGDAT_LWIP_PPP_DEV { user_value "\"/dev/ser1\"" That's all. make make -C net/lwip_tcpip/current tests *** iii. Prepare a host (today I use Ubuntu) 1) I do not want to have ipv6 anywere when I will be to test lwIP. On Ubuntu I can disable IPV6 support editing /etc/modprobe.d/aliases #alias net-pf-10 ipv6 alias net-pf-10 off alias ipv6 off Reboot PC and check that it went away ping6 localhost unknow host 2) Insert 'slip' module into kernel dmesg | grep -q SLIP || modprobe slip dmesg | grep SLIP [ 6573.657552] SLIP: version 0.8.4-NET3.019-NEWTTY (dynamic channels, max=256) (6 bit encapsulation enabled). [ 6573.657561] CSLIP: code copyright 1989 Regents of the University of California. [ 6573.657564] SLIP linefill/keepalive option. 3) Running forward, I want to say what a step the below was a paranoia. I have many static routes on ppp0, vmware service (vmnet interfaces) is run on my PC, some scripts try to reconnect ppp connections via cron, etc. So, I will set my networking down. I want to be sure that nothing will spoil my P-t-P. /etc/init.d/cron stop /etc/init.d/anacron stop /etc/init.d/vmware stop /etc/init.d/networking stop for l in lo eth0; do ip l set $l down; done ip route flush all ip route show No output. 4) My target's SERIAL1 does not use RTSCTS flow control stty -crtscts -F /dev/ttyS0 Run slattach as slattach -d -L -s 115200 -p slip /dev/ttyS0 slattach: tty_open: looking for lock slattach: tty_open: trying to open /dev/ttyS0 slattach: tty_open: /dev/ttyS0 (fd=3) slattach: tty_set_speed: 115200 slattach: tty_set_databits: 8 slattach: tty_set_stopbits: 1 slattach: tty_set_parity: N slip started on /dev/ttyS0 interface sl0 check that 'crtscts' is not changed stty -a -F /dev/ttyS0 | grep crtscts -parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts I expect to see new sl0 interface ip link sh sl0 7: sl0: <POINTOPOINT,MULTICAST,NOARP> mtu 296 qdisc noop qlen 10 link/slip 5) Setup a very minimal networking lo ip link set lo up ip route add default dev lo ip route add 127.0.0.0/8 via 127.0.0.1 dev lo sl0 ip addr add 192.168.1.1 peer 192.168.1.222 dev sl0 ip link set sl0 up ip link show sl0 7: sl0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 296 qdisc pfifo_fast qlen 10 link/sli a route table is ip route show 192.168.1.222 dev sl0 proto kernel scope link src 192.168.1.1 127.0.0.0/8 via 127.0.0.1 dev lo default dev lo scope link If 'route -n' is yours Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.222 0.0.0.0 255.255.255.255 UH 0 0 0 sl0 127.0.0.0 127.0.0.1 255.0.0.0 UG 0 0 0 lo 0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 lo Let's try to ping interfaces ping -c 1 127.0.0.1 PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data. 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.048 ms --- 127.0.0.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.048/0.048/0.048/0.000 ms ping -c 1 192.168.1.1 PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data. 64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.044 ms --- 192.168.1.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.044/0.044/0.044/0.000 ms ping -c 1 192.168.1.222 PING 192.168.1.222 (192.168.1.222) 56(84) bytes of data. --- 192.168.1.222 ping statistics --- 1 packets transmitted, 0 received, 100% packet loss, time 0ms It's okay. I have not run a lwIP test on the target. *** iv. run lwip's tcpecho on the target arm-eabi-gdb -q install/tests/net/lwip_tcpip/current/tests/tcpecho 0x00008028 in ?? () Loading section .rom_vectors, size 0x40 lma 0x81010000 Loading section .text, size 0x1f23c lma 0x81010040 Loading section .rodata, size 0x365 lma 0x8102f27c Loading section .data, size 0x4b8 lma 0x8102f5e4 Start address 0x81010040, load size 129689 Transfer rate: 18 KB/sec, 303 bytes/write. Breakpoint 1 at 0x81015cf4: file /opt/trunk/devo/ecos/packages/infra/current/src/tcdiag.cxx, line 197. [Switching to Thread 1] Breakpoint 1, cyg_test_init () at /opt/trunk/devo/ecos/packages/infra/current/src/tcdiag.cxx:197 197 } Current language: auto; currently c++ (gdb) c Continuing. Try to ping the target ping -c 1 192.168.1.222 PING 192.168.1.222 (192.168.1.222) 56(84) bytes of data. 64 bytes from 192.168.1.222: icmp_seq=1 ttl=64 time=38.2 ms --- 192.168.1.222 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 38.283/38.283/38.283/0.000 ms Test echo server telnet 192.168.1.222 7 Trying 192.168.1.222... Connected to 192.168.1.222. Escape character is '^]'. foo foo bar bar baz baz ^] telnet> q Connection closed. Let's load the interface: run ping and echo requests together ping -A 192.168.1.222 PING 192.168.1.222 (192.168.1.222) 56(84) bytes of data. 64 bytes from 192.168.1.222: icmp_seq=1 ttl=64 time=36.6 ms 64 bytes from 192.168.1.222: icmp_seq=2 ttl=64 time=34.9 ms 64 bytes from 192.168.1.222: icmp_seq=3 ttl=64 time=34.9 ms 64 bytes from 192.168.1.222: icmp_seq=4 ttl=64 time=35.9 ms 64 bytes from 192.168.1.222: icmp_seq=5 ttl=64 time=35.9 ms 64 bytes from 192.168.1.222: icmp_seq=6 ttl=64 time=35.9 ms 64 bytes from 192.168.1.222: icmp_seq=7 ttl=64 time=35.9 ms 64 bytes from 192.168.1.222: icmp_seq=8 ttl=64 time=35.9 ms 64 bytes from 192.168.1.222: icmp_seq=9 ttl=64 time=35.9 ms ... while [ 1 ];do echo `date +%s`|socat - tcp4:192.168.1.222:7;sleep 1;done 1237064569 1237064570 1237064571 1237064572 1237064573 1237064574 1237064575 ... It worked very long time without the fails. It was possible to telnet on port 7 during the pinging and batch echoing. But, that was no load. Let's try to kill the service yes|socat - tcp4:192.168.1.222:7 y y y y y y y y y y y y [snip] This DoS attack made the service unreachable. Good news: the application has not hung in GDB. When I break run and enter the breakpoints at {ip,icmp,tcp,udp}_input (gdb) b .*p_input (gdb) c a run stops exactly here Breakpoint 2, tcpip_input (p=0x810405b8, inp=0x8104c994) at /opt/trunk/devo/ecos/packages/net/lwip_tcpip/current/src/api/tcpip.c:143 143 msg = memp_malloc(MEMP_TCPIP_MSG); Current language: auto; currently c (gdb) n 144 if (msg == NULL) { (gdb) 145 pbuf_free(p); (gdb) 146 return ERR_MEM; (gdb) n 154 } allocator could not get new room. When I tried to ping the board on every ping the application stops there too. At the least my sio's tweaks have not broken serial input, on every ping then I got no reply, but, slipif_input() worked (see a listing the below) and then tcpip_input tried to allocate memory without a success. (gdb) l slipif_loop,190 179 { 180 struct pbuf *p; 181 struct netif *netif = (struct netif *)nf; 182 183 while (1) { 184 p = slipif_input(netif); 185 netif->input(p, netif); 186 } 187 } 188
