diff mbox series

[v2] net: ping: reset stored IP address

Message ID 20200615091557.23364-1-m.szyprowski@samsung.com
State Accepted
Commit def7a5c00f4a84edf7a8a83c28bf9a7063e00731
Headers show
Series [v2] net: ping: reset stored IP address | expand

Commit Message

Marek Szyprowski June 15, 2020, 9:15 a.m. UTC
Reset the stored ping IP address before entering a netloop with different
protocol to ensure that it won't be interrupted by the received
correct ICMP_ECHO_REPLY packet.

Signed-off-by: Marek Szyprowski <m.szyprowski at samsung.com>
---
v2:
- Moved the net_ping_ip reset to the beginning of the net_loop() if the
  protocol is not equal to PING. This is required, because the netretry
  feature of the network framework relies on the fact that the internal
  state of the commands is preserved between net_loop() calls.

v1: https://patchwork.ozlabs.org/project/uboot/patch/20200325134200.18959-1-m.szyprowski at samsung.com/
- Initial version
---
 net/net.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Tom Rini Aug. 5, 2020, 8:26 p.m. UTC | #1
On Mon, Jun 15, 2020 at 11:15:57AM +0200, Marek Szyprowski wrote:

> Reset the stored ping IP address before entering a netloop with different

> protocol to ensure that it won't be interrupted by the received

> correct ICMP_ECHO_REPLY packet.

> 

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


Applied to u-boot/master, thanks!

-- 
Tom
diff mbox series

Patch

diff --git a/net/net.c b/net/net.c
index 37932919d04..72b445774f9 100644
--- a/net/net.c
+++ b/net/net.c
@@ -409,6 +409,10 @@  int net_loop(enum proto_t protocol)
 	int ret = -EINVAL;
 	enum net_loop_state prev_net_state = net_state;
 
+#if defined(CONFIG_CMD_PING)
+	if (protocol != PING)
+		net_ping_ip.s_addr = 0;
+#endif
 	net_restarted = 0;
 	net_dev_exists = 0;
 	net_try_count = 1;