Hi Sylvain, Thank you for your reply. I really appreciate your help. The below are a few comments and more observations.
>Well, ip_forward() should call netif->output(), which in our case is >ppp_netif_output_ip4(), could you first check that ? Sorry, I may confuse you about which direction the problem is. Actually, the problem is it doesn't output the corresponding Ethernet packets based on the incoming PPP packets. >You can also enable PPP_DEBUG in your lwipopts.h, this will display discarded >frames in ppp_netif_output_ip4() if any. The following logging messages are captured with PPP_DEBUG enabled. I also enabled ETHARP_DEBUG & NETIF_DEBUG. >From the newly captured messages below(last line), it seems there's a memory >issue. etharp_timer etharp_timer ethernet_input: dest:00:bd:33:06:68:22, src:c8:d7:19:ee:1f:fc, type:800 ip_input: iphdr->dest 0x6a01a8c0 netif->ip_addr 0x3200a8c0 (0x1a8c0, 0xa8c0, 0x6a000000) ip_input: iphdr->dest 0x6a01a8c0 netif->ip_addr 0x6901a8c0 (0x6a01a8c0, 0x6901a8c0, 0x0) ip_input: packet not for us. ip_forward: forward packets to interface.pp ip_forward: forwarding packet to 192.168.1.106 ip_input: iphdr->dest 0xd300a8c0 netif->ip_addr 0x6901a8c0 (0xd300a8c0, 0x6901a8c0, 0x0) ip_input: iphdr->dest 0xd300a8c0 netif->ip_addr 0x3200a8c0 (0xa8c0, 0xa8c0, 0xd3000000) ip_input: packet not for us. ip_forward: forward packets to interface.em ip_forward: forwarding packet to 192.168.0.211 etharp_output: could not allocate room for header. I looked at the code of etharp_output function, it seems pbuf_header function cannot find room for Ethernet header (code snippet is shown below). /* make room for Ethernet header - should not fail */ #if ETHARP_SUPPORT_VLAN && defined(LWIP_HOOK_VLAN_SET) if (pbuf_header(q, sizeof(struct eth_hdr) + SIZEOF_VLAN_HDR) != 0) { #else /* ETHARP_SUPPORT_VLAN && defined(LWIP_HOOK_VLAN_SET) */ if (pbuf_header(q, sizeof(struct eth_hdr)) != 0) { #endif /* ETHARP_SUPPORT_VLAN && defined(LWIP_HOOK_VLAN_SET) */ /* bail out */ LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("etharp_output: could not allocate room for header.\n")); LINK_STATS_INC(link.lenerr); return ERR_BUF; However, the non-forwarded IP packets have no problem to be sent out. For example, if I ping 192.168.1.105 which is the PPP interface on the gateway device, we can IP packet is sent out without problem (log messages are shown below). etharp_timer etharp_timer ethernet_input: dest:ff:ff:ff:ff:ff:ff, src:c8:d7:19:ee:1f:fc, type:806 etharp_update_arp_entry: 192.168.0.211 - c8:d7:19:ee:1f:fc etharp_find_entry: found matching entry 0 etharp_update_arp_entry: updating stable entry 0 etharp_arp_input: incoming ARP request etharp_arp_input: replying to ARP request for our IP address ethernet_input: dest:00:bd:33:06:68:22, src:c8:d7:19:ee:1f:fc, type:800 ip_input: iphdr->dest 0x6901a8c0 netif->ip_addr 0x3200a8c0 (0x1a8c0, 0xa8c0, 0x69000000) ip_input: iphdr->dest 0x6901a8c0 netif->ip_addr 0x6901a8c0 (0x6901a8c0, 0x6901a8c0, 0x0) ip_input: packet accepted on interface pp ip_input: IP header: +-------------------------------+ | 4 | 5 | 0x00 | 60 | (v, hl, tos, len) +-------------------------------+ | 3005 |000| 0 | (id, flags, offset) +-------------------------------+ | 128 | 1 | 0xab77 | (ttl, proto, chksum) +-------------------------------+ | 192 | 168 | 0 | 211 | (src) +-------------------------------+ | 192 | 168 | 1 | 105 | (dest) +-------------------------------+ ip_input: p->len 60 p->tot_len 60 ip_output_if: em0 IP header: +-------------------------------+ | 4 | 5 | 0x00 | 60 | (v, hl, tos, len) +-------------------------------+ | 3005 |000| 0 | (id, flags, offset) +-------------------------------+ | 255 | 1 | 0x2c77 | (ttl, proto, chksum) +-------------------------------+ | 192 | 168 | 1 | 105 | (src) +-------------------------------+ | 192 | 168 | 0 | 211 | (dest) +-------------------------------+ netif->output() etharp_send_ip: sending packet 0020cf34 etharp_timer etharp_timer Now, what I really don't understand is the forwarded and non-forwarded IP packets both need room for Ethernet header before sending out, why one succeeded in making room for Ethernet header and the other failed. Is it because these two type packets use different types of PBUF? Charles _______________________________________________ lwip-users mailing list lwip-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/lwip-users