aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/eth-uclass.c18
-rw-r--r--net/eth_legacy.c2
-rw-r--r--net/net_rand.h19
-rw-r--r--net/ping.c3
-rw-r--r--net/tftp.c4
5 files changed, 37 insertions, 9 deletions
diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index 0156324032..8a22d8bf59 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -26,6 +26,7 @@ DECLARE_GLOBAL_DATA_PTR;
*/
struct eth_device_priv {
enum eth_state_t state;
+ bool running;
};
/**
@@ -290,6 +291,7 @@ int eth_init(void)
dev_get_uclass_priv(current);
priv->state = ETH_STATE_ACTIVE;
+ priv->running = true;
return 0;
}
} else {
@@ -319,13 +321,16 @@ void eth_halt(void)
struct eth_device_priv *priv;
current = eth_get_dev();
- if (!current || !eth_is_active(current))
+ if (!current)
return;
- eth_get_ops(current)->stop(current);
priv = dev_get_uclass_priv(current);
- if (priv)
- priv->state = ETH_STATE_PASSIVE;
+ if (!priv || !priv->running)
+ return;
+
+ eth_get_ops(current)->stop(current);
+ priv->state = ETH_STATE_PASSIVE;
+ priv->running = false;
}
int eth_is_active(struct udevice *dev)
@@ -534,6 +539,7 @@ static int eth_post_probe(struct udevice *dev)
#endif
priv->state = ETH_STATE_INIT;
+ priv->running = false;
/* Check if the device has a valid MAC address in device tree */
if (!eth_dev_get_mac_address(dev, pdata->enetaddr) ||
@@ -591,8 +597,8 @@ static int eth_pre_remove(struct udevice *dev)
return 0;
}
-UCLASS_DRIVER(eth) = {
- .name = "eth",
+UCLASS_DRIVER(ethernet) = {
+ .name = "ethernet",
.id = UCLASS_ETH,
.post_bind = eth_post_bind,
.pre_unbind = eth_pre_unbind,
diff --git a/net/eth_legacy.c b/net/eth_legacy.c
index 6e0c058761..6870afb505 100644
--- a/net/eth_legacy.c
+++ b/net/eth_legacy.c
@@ -365,7 +365,7 @@ int eth_send(void *packet, int length)
ret = eth_current->send(eth_current, packet, length);
#if defined(CONFIG_CMD_PCAP)
if (ret >= 0)
- pcap_post(packet, lengeth, true);
+ pcap_post(packet, length, true);
#endif
return ret;
}
diff --git a/net/net_rand.h b/net/net_rand.h
index 4bf9bd817e..6a52cda85e 100644
--- a/net/net_rand.h
+++ b/net/net_rand.h
@@ -10,6 +10,8 @@
#define __NET_RAND_H__
#include <common.h>
+#include <dm/uclass.h>
+#include <rng.h>
/*
* Return a seed for the PRNG derived from the eth0 MAC address.
@@ -37,7 +39,22 @@ static inline unsigned int seed_mac(void)
*/
static inline void srand_mac(void)
{
- srand(seed_mac());
+ int ret;
+ struct udevice *devp;
+ u32 randv = 0;
+
+ if (IS_ENABLED(CONFIG_DM_RNG)) {
+ ret = uclass_get_device(UCLASS_RNG, 0, &devp);
+ if (ret) {
+ ret = dm_rng_read(devp, &randv, sizeof(randv));
+ if (ret < 0)
+ randv = 0;
+ }
+ }
+ if (randv)
+ srand(randv);
+ else
+ srand(seed_mac());
}
#endif /* __NET_RAND_H__ */
diff --git a/net/ping.c b/net/ping.c
index 0e33660f6c..075df3663f 100644
--- a/net/ping.c
+++ b/net/ping.c
@@ -90,6 +90,9 @@ void ping_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)
net_set_state(NETLOOP_SUCCESS);
return;
case ICMP_ECHO_REQUEST:
+ if (net_ip.s_addr == 0)
+ return;
+
eth_hdr_size = net_update_ether(et, et->et_src, PROT_IP);
debug_cond(DEBUG_DEV_PKT,
diff --git a/net/tftp.c b/net/tftp.c
index 2cfa0b1486..03079ded34 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -630,8 +630,10 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
tftp_cur_block++;
tftp_cur_block %= TFTP_SEQUENCE_SIZE;
- if (tftp_state == STATE_SEND_RRQ)
+ if (tftp_state == STATE_SEND_RRQ) {
debug("Server did not acknowledge any options!\n");
+ tftp_next_ack = tftp_windowsize;
+ }
if (tftp_state == STATE_SEND_RRQ || tftp_state == STATE_OACK ||
tftp_state == STATE_RECV_WRQ) {