net: ping: reset stored IP once the command finishes to avoid interrupting other...
authorMarek Szyprowski <m.szyprowski@samsung.com>
Wed, 25 Mar 2020 09:08:16 +0000 (10:08 +0100)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Tue, 16 Nov 2021 10:04:04 +0000 (11:04 +0100)
Reset stored ping IP address before leaving the netloop to ensure that the subsequent calls
to the netloop, especially for the other protocols, won't be interrupted by the received
ICMP_ECHO_REPLY packet.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Change-Id: I0d90b3a6e9481c8e8237874eff8a9a12df4190e0

net/ping.c

index 075df3663fe073132687212df5d385f6cb9f04b0..fcb247a57713f86143558733754184f362a42b19 100644 (file)
@@ -65,6 +65,7 @@ static int ping_send(void)
 static void ping_timeout_handler(void)
 {
        eth_halt();
+       net_ping_ip.s_addr = 0;
        net_set_state(NETLOOP_FAIL);    /* we did not get the reply */
 }
 
@@ -86,8 +87,10 @@ void ping_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)
        switch (icmph->type) {
        case ICMP_ECHO_REPLY:
                src_ip = net_read_ip((void *)&ip->ip_src);
-               if (src_ip.s_addr == net_ping_ip.s_addr)
+               if (src_ip.s_addr == net_ping_ip.s_addr) {
+                       net_ping_ip.s_addr = 0;
                        net_set_state(NETLOOP_SUCCESS);
+               }
                return;
        case ICMP_ECHO_REQUEST:
                if (net_ip.s_addr == 0)