lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] [bug #64423] ICMP PING not working with bridge code (2.2.0


From: Cedric Berger
Subject: [lwip-devel] [bug #64423] ICMP PING not working with bridge code (2.2.0 RC1)
Date: Thu, 13 Jul 2023 09:18:30 -0400 (EDT)

URL:
  <https://savannah.nongnu.org/bugs/?64423>

                 Summary: ICMP PING not working with bridge code (2.2.0 RC1)
                   Group: lwIP - A Lightweight TCP/IP stack
               Submitter: ceedriic
               Submitted: Thu 13 Jul 2023 01:18:28 PM UTC
                Category: IPv4
                Severity: 3 - Normal
              Item Group: Faulty Behaviour
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None
            lwIP version: git head


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Thu 13 Jul 2023 01:18:28 PM UTC By: Cedric Berger <ceedriic>
I'm using LWIP on a stm32h7, and after I switched from a simple system with
one hardware interface to a bridge setup, everything worked, except PINGs.
The reason is that in icmp_output() the reply is reusing the received pbuf,
and therefore p->if_idx is set to the receiving port.
Then the reply gets dropped in bridgeif_send_to_port by this test:

        /* prevent sending out to rx port */
        if (netif_get_index(portif) != p->if_idx) {
          if (netif_is_link_up(portif)) {
            LWIP_DEBUGF(BRIDGEIF_FW_DEBUG, ("br -> flood(%p:%d) -> %d\n",
(void *)p, p->if_idx, netif_get_index(portif)));
            return portif->linkoutput(portif, p);
          }
        }

The whole stack is:

  bridgeif_send_to_port()
  bridgeif_send_to_ports()
  bridgeif_output()
  ethernet_output()
  etharp_output_to_arp_index()
  etharp_output()
  ip4_output_if_opt_src()
  ip4_output_if_opt()
  ip4_output_if()
  icmp_input()
  ip4_input()
  ethernet_input()
  netif_input()
  bridgeif_input()

The following patch fixes the problem for me:

Index: src/core/ipv4/icmp.c
===================================================================
--- src/core/ipv4/icmp.c        (revision 3430)
+++ src/core/ipv4/icmp.c        (working copy)
@@ -213,6 +213,7 @@
         ip4_addr_copy(iphdr->src, *src);
         ip4_addr_copy(iphdr->dest, *ip4_current_src_addr());
         ICMPH_TYPE_SET(iecho, ICMP_ER);
+        p->if_idx = 0; /* otherwise bridgeif_send_to_port will drop the reply
*/
 #if CHECKSUM_GEN_ICMP
         IF__NETIF_CHECKSUM_ENABLED(inp, NETIF_CHECKSUM_GEN_ICMP) {
           /* adjust the checksum */









    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?64423>

_______________________________________________
Message sent via Savannah
https://savannah.nongnu.org/




reply via email to

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