Pull request net-20250818.

This is mostly code cleanup and fixes, mainly for issues reported by the
Smatch tool, plus two small features for NET_LWIP as well as support for
the BCM54612E phy.

net-common:
- Fix a bunch of issues reported by Smatch
- Introduce CONFIG_DNS
- Add support for BCM54612E phy

net-legacy:
- Add missing SPDX-License-Identifier for files originating from LiMon

net-lwip:
- ping: initialize net_try_count to 1
- sntp: remove redundant sys_check_timeouts()
- tftp: resend initial request
- Add Kconfig option to show ICMP unreachable errors
This commit is contained in:
Tom Rini
2025-08-18 10:54:44 -06:00
48 changed files with 394 additions and 214 deletions

View File

@@ -2117,7 +2117,7 @@ config CMD_DHCP
config CMD_DNS config CMD_DNS
bool "dns" bool "dns"
select PROT_DNS_LWIP if NET_LWIP select DNS
help help
Lookup the IP of a hostname Lookup the IP of a hostname

View File

@@ -2,115 +2,7 @@
/* Copyright (C) 2024 Linaro Ltd. */ /* Copyright (C) 2024 Linaro Ltd. */
#include <command.h> #include <command.h>
#include <console.h>
#include <env.h>
#include <lwip/dns.h>
#include <lwip/timeouts.h>
#include <net.h> #include <net.h>
#include <time.h>
U_BOOT_CMD(dns, 3, 1, do_dns, "lookup the IP of a hostname", U_BOOT_CMD(dns, 3, 1, do_dns, "lookup the IP of a hostname",
"hostname [envvar]"); "hostname [envvar]");
#define DNS_RESEND_MS 1000
#define DNS_TIMEOUT_MS 10000
struct dns_cb_arg {
ip_addr_t host_ipaddr;
const char *var;
bool done;
};
static void do_dns_tmr(void *arg)
{
dns_tmr();
}
static void dns_cb(const char *name, const ip_addr_t *ipaddr, void *arg)
{
struct dns_cb_arg *dns_cb_arg = arg;
char *ipstr = ip4addr_ntoa(ipaddr);
dns_cb_arg->done = true;
if (!ipaddr) {
printf("DNS: host not found\n");
dns_cb_arg->host_ipaddr.addr = 0;
return;
}
dns_cb_arg->host_ipaddr.addr = ipaddr->addr;
if (dns_cb_arg->var)
env_set(dns_cb_arg->var, ipstr);
}
static int dns_loop(struct udevice *udev, const char *name, const char *var)
{
struct dns_cb_arg dns_cb_arg = { };
struct netif *netif;
ip_addr_t ipaddr;
ulong start;
int ret;
dns_cb_arg.var = var;
netif = net_lwip_new_netif(udev);
if (!netif)
return CMD_RET_FAILURE;
if (net_lwip_dns_init()) {
net_lwip_remove_netif(netif);
return CMD_RET_FAILURE;
}
dns_cb_arg.done = false;
ret = dns_gethostbyname(name, &ipaddr, dns_cb, &dns_cb_arg);
if (ret == ERR_OK) {
dns_cb(name, &ipaddr, &dns_cb_arg);
} else if (ret == ERR_INPROGRESS) {
start = get_timer(0);
sys_timeout(DNS_RESEND_MS, do_dns_tmr, NULL);
do {
net_lwip_rx(udev, netif);
if (dns_cb_arg.done)
break;
if (ctrlc()) {
printf("\nAbort\n");
break;
}
} while (get_timer(start) < DNS_TIMEOUT_MS);
sys_untimeout(do_dns_tmr, NULL);
}
net_lwip_remove_netif(netif);
if (dns_cb_arg.done && dns_cb_arg.host_ipaddr.addr != 0) {
if (!var)
printf("%s\n", ipaddr_ntoa(&ipaddr));
return CMD_RET_SUCCESS;
}
return CMD_RET_FAILURE;
}
int do_dns(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
char *name;
char *var = NULL;
if (argc == 1 || argc > 3)
return CMD_RET_USAGE;
name = argv[1];
if (argc == 3)
var = argv[2];
if (net_lwip_eth_start() < 0)
return CMD_RET_FAILURE;
return dns_loop(eth_get_dev(), name, var);
}

View File

@@ -170,6 +170,7 @@ int do_ping(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
if (net_lwip_dns_resolve(argv[1], &addr)) if (net_lwip_dns_resolve(argv[1], &addr))
return CMD_RET_USAGE; return CMD_RET_USAGE;
net_try_count = 1;
restart: restart:
if (net_lwip_eth_start() < 0 || ping_loop(eth_get_dev(), &addr) < 0) { if (net_lwip_eth_start() < 0 || ping_loop(eth_get_dev(), &addr) < 0) {
if (net_start_again() == 0) if (net_start_again() == 0)

View File

@@ -79,7 +79,6 @@ static int sntp_loop(struct udevice *udev, ip_addr_t *srvip)
sys_timeout(SNTP_TIMEOUT, no_response, NULL); sys_timeout(SNTP_TIMEOUT, no_response, NULL);
while (sntp_state == NOT_DONE) { while (sntp_state == NOT_DONE) {
net_lwip_rx(udev, netif); net_lwip_rx(udev, netif);
sys_check_timeouts();
if (ctrlc()) { if (ctrlc()) {
printf("\nAbort\n"); printf("\nAbort\n");
sntp_state = ABORTED; sntp_state = ABORTED;

View File

@@ -12,7 +12,7 @@ Synopsis
:: ::
sntp [serverip] sntp [serverip]
sntp [servername] # NET_LWIP=y && CMD_DNS=y only sntp [servername] # NET_LWIP=y && DNS=y only
Description Description
@@ -27,8 +27,8 @@ The address of the NTP server does not need to be given if the DHCP server
provides one. The legacy network stack (`CONFIG_NET=y`) can only use the provides one. The legacy network stack (`CONFIG_NET=y`) can only use the
first NTP server provided in the `ntp-servers` DHCP option. first NTP server provided in the `ntp-servers` DHCP option.
When the network stack is lwIP (`CONFIG_NET_LWIP=y`) and the dns command When the network stack is lwIP (`CONFIG_NET_LWIP=y`) and DNS resolution
is enabled (`CONFIG_CMD_DNS=y`), then the sntp command accepts a server is enabled (`CONFIG_DNS=y`), then the sntp command accepts a server
name as an argument. name as an argument.
The network time is sent as UTC. So, if you want to set the RTC to any local The network time is sent as UTC. So, if you want to set the RTC to any local
@@ -61,7 +61,7 @@ Examples
=> date => date
Date: 2025-06-16 (Monday) Time: 17:19:57 Date: 2025-06-16 (Monday) Time: 17:19:57
With `CONFIG_NET_LWIP=y` and `CONFIG_CMD_DNS=y`: With `CONFIG_NET_LWIP=y` and `CONFIG_DNS=y`:
:: ::

View File

@@ -38,7 +38,7 @@ address
memory address for the data downloaded memory address for the data downloaded
host host
IP address (or host name if `CONFIG_CMD_DNS` is enabled) of the HTTP IP address (or host name if `CONFIG_DNS` is enabled) of the HTTP
server, defaults to the value of environment variable *serverip*. server, defaults to the value of environment variable *serverip*.
path path

View File

@@ -499,7 +499,7 @@ static int ca_phy_probe(struct udevice *dev)
dev, priv->phy_interface); dev, priv->phy_interface);
if (ext_phydev) { if (ext_phydev) {
ext_phydev->supported &= PHY_GBIT_FEATURES; ext_phydev->supported &= PHY_GBIT_FEATURES;
ext_phydev->advertising = int_phydev->supported; ext_phydev->advertising = ext_phydev->supported;
phy_config(ext_phydev); phy_config(ext_phydev);
} else { } else {
printf("CA NI %s: There is no external phy device\n", __func__); printf("CA NI %s: There is no external phy device\n", __func__);

View File

@@ -486,7 +486,7 @@ static int dw_adjust_link(struct dw_eth_dev *priv, struct eth_mac_regs *mac_p,
#ifdef CONFIG_ARCH_NPCM8XX #ifdef CONFIG_ARCH_NPCM8XX
if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
unsigned int start; ulong start;
/* Indirect access to VR_MII_MMD registers */ /* Indirect access to VR_MII_MMD registers */
writew((VR_MII_MMD >> 9), PCS_BA + PCS_IND_AC); writew((VR_MII_MMD >> 9), PCS_BA + PCS_IND_AC);
@@ -532,7 +532,7 @@ int designware_eth_init(struct dw_eth_dev *priv, u8 *enetaddr)
{ {
struct eth_mac_regs *mac_p = priv->mac_regs_p; struct eth_mac_regs *mac_p = priv->mac_regs_p;
struct eth_dma_regs *dma_p = priv->dma_regs_p; struct eth_dma_regs *dma_p = priv->dma_regs_p;
unsigned int start; ulong start;
int ret; int ret;
writel(readl(&dma_p->busmode) | DMAMAC_SRST, &dma_p->busmode); writel(readl(&dma_p->busmode) | DMAMAC_SRST, &dma_p->busmode);

View File

@@ -347,11 +347,6 @@ static int ks8851_mll_detect_chip(struct ks_net *ks)
debug("Read back KS8851 id 0x%x\n", val); debug("Read back KS8851 id 0x%x\n", val);
if ((val & 0xfff0) != CIDER_ID) {
printf(DRIVERNAME ": Unknown chip ID %04x\n", val);
return -1;
}
return 0; return 0;
} }

View File

@@ -458,7 +458,7 @@ static int ldpaa_eth_open(struct udevice *dev)
link_state.up == 1 ? printf("up\n") : printf("error state\n"); link_state.up == 1 ? printf("up\n") : printf("error state\n");
#endif #endif
memset(&d_queue, 0, sizeof(struct dpni_queue)); memset(&d_queue, 0, sizeof(struct dpni_queue_id));
err = dpni_get_queue(dflt_mc_io, MC_CMD_NO_FLAGS, err = dpni_get_queue(dflt_mc_io, MC_CMD_NO_FLAGS,
dflt_dpni->dpni_handle, DPNI_QUEUE_RX, dflt_dpni->dpni_handle, DPNI_QUEUE_RX,
0, 0, &d_queue_cfg, &d_queue); 0, 0, &d_queue_cfg, &d_queue);

View File

@@ -1461,7 +1461,7 @@ static int mtk_eth_of_to_plat(struct udevice *dev)
priv->phy_addr = ofnode_read_s32_default(args.node, "reg", -1); priv->phy_addr = ofnode_read_s32_default(args.node, "reg", -1);
if (priv->phy_addr < 0) { if (priv->phy_addr < 0) {
printf("error: phy address is not specified\n"); printf("error: phy address is not specified\n");
return ret; return priv->phy_addr;
} }
} }

View File

@@ -631,7 +631,7 @@ static int mv88e6xxx_port_enable(struct udevice *dev, int port, struct phy_devic
dev_dbg(dev, "configure internal RGMII delays\n"); dev_dbg(dev, "configure internal RGMII delays\n");
/* RGMII delays */ /* RGMII delays */
val &= ~(PORT_REG_PHYS_CTRL_RGMII_DELAY_RXCLK || val &= ~(PORT_REG_PHYS_CTRL_RGMII_DELAY_RXCLK |
PORT_REG_PHYS_CTRL_RGMII_DELAY_TXCLK); PORT_REG_PHYS_CTRL_RGMII_DELAY_TXCLK);
if (phy->interface == PHY_INTERFACE_MODE_RGMII_ID || if (phy->interface == PHY_INTERFACE_MODE_RGMII_ID ||
phy->interface == PHY_INTERFACE_MODE_RGMII_RXID) phy->interface == PHY_INTERFACE_MODE_RGMII_RXID)

View File

@@ -1722,8 +1722,7 @@ static struct mvpp2_prs_entry *mvpp2_prs_flow_find(struct mvpp2 *priv, int flow)
} }
/* Return first free tcam index, seeking from start to end */ /* Return first free tcam index, seeking from start to end */
static int mvpp2_prs_tcam_first_free(struct mvpp2 *priv, unsigned char start, static int mvpp2_prs_tcam_first_free(struct mvpp2 *priv, int start, int end)
unsigned char end)
{ {
int tid; int tid;
@@ -2330,7 +2329,7 @@ static int mvpp2_prs_mac_da_accept(struct mvpp2 *priv, int port,
pe = kzalloc(sizeof(*pe), GFP_KERNEL); pe = kzalloc(sizeof(*pe), GFP_KERNEL);
if (!pe) if (!pe)
return -1; return -ENOMEM;
mvpp2_prs_tcam_lu_set(pe, MVPP2_PRS_LU_MAC); mvpp2_prs_tcam_lu_set(pe, MVPP2_PRS_LU_MAC);
pe->index = tid; pe->index = tid;
@@ -4735,7 +4734,7 @@ static int phy_info_parse(struct udevice *dev, struct mvpp2_port *port)
int port_node = dev_of_offset(dev); int port_node = dev_of_offset(dev);
int phy_node; int phy_node;
u32 id; u32 id;
u32 phyaddr = 0; int phyaddr = 0;
int fixed_link = 0; int fixed_link = 0;
int ret; int ret;
@@ -5354,7 +5353,7 @@ static int mvpp2_probe(struct udevice *dev)
} else { } else {
port->gop_id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), port->gop_id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"gop-port-id", -1); "gop-port-id", -1);
if (port->id == -1) { if (port->gop_id == -1) {
dev_err(dev, "missing gop-port-id value\n"); dev_err(dev, "missing gop-port-id value\n");
return -EINVAL; return -EINVAL;
} }

View File

@@ -232,7 +232,7 @@ static int nicvf_rcv_pkt_handler(struct nicvf *nic,
size_t pkt_len; size_t pkt_len;
struct cqe_rx_t *cqe_rx = (struct cqe_rx_t *)cq_desc; struct cqe_rx_t *cqe_rx = (struct cqe_rx_t *)cq_desc;
int err = 0; int err;
/* Check for errors */ /* Check for errors */
err = nicvf_check_cqe_rx_errs(nic, cq, cq_desc); err = nicvf_check_cqe_rx_errs(nic, cq, cq_desc);
@@ -245,8 +245,7 @@ static int nicvf_rcv_pkt_handler(struct nicvf *nic,
return -1; return -1;
} }
if (pkt) *ppkt = pkt;
*ppkt = pkt;
return pkt_len; return pkt_len;
} }
@@ -274,31 +273,29 @@ int nicvf_cq_handler(struct nicvf *nic, void **ppkt, int *pkt_len)
cqe_head >>= 9; cqe_head >>= 9;
cqe_head &= 0xFFFF; cqe_head &= 0xFFFF;
if (cqe_count) { /* Get the CQ descriptor */
/* Get the CQ descriptor */ cq_desc = (struct cqe_rx_t *)GET_CQ_DESC(cq, cqe_head);
cq_desc = (struct cqe_rx_t *)GET_CQ_DESC(cq, cqe_head); cqe_head++;
cqe_head++; cqe_head &= (cq->dmem.q_len - 1);
cqe_head &= (cq->dmem.q_len - 1);
switch (cq_desc->cqe_type) { switch (cq_desc->cqe_type) {
case CQE_TYPE_RX: case CQE_TYPE_RX:
debug("%s: Got Rx CQE\n", nic->dev->name); debug("%s: Got Rx CQE\n", nic->dev->name);
*pkt_len = nicvf_rcv_pkt_handler(nic, cq, cq_desc, *pkt_len = nicvf_rcv_pkt_handler(nic, cq, cq_desc,
ppkt, CQE_TYPE_RX); ppkt, CQE_TYPE_RX);
processed_rq_cqe++; processed_rq_cqe++;
break; break;
case CQE_TYPE_SEND: case CQE_TYPE_SEND:
debug("%s: Got Tx CQE\n", nic->dev->name); debug("%s: Got Tx CQE\n", nic->dev->name);
nicvf_snd_pkt_handler(nic, cq, cq_desc, CQE_TYPE_SEND); nicvf_snd_pkt_handler(nic, cq, cq_desc, CQE_TYPE_SEND);
processed_sq_cqe++; processed_sq_cqe++;
break; break;
default: default:
debug("%s: Got CQ type %u\n", nic->dev->name, debug("%s: Got CQ type %u\n", nic->dev->name,
cq_desc->cqe_type); cq_desc->cqe_type);
break; break;
}
processed_cqe++;
} }
processed_cqe++;
/* Dequeue CQE */ /* Dequeue CQE */
nicvf_queue_reg_write(nic, NIC_QSET_CQ_0_7_DOOR, nicvf_queue_reg_write(nic, NIC_QSET_CQ_0_7_DOOR,

View File

@@ -338,7 +338,8 @@ int octeontx_smi_probe(struct udevice *dev)
if (!bus || !priv) { if (!bus || !priv) {
printf("Failed to allocate OcteonTX MDIO bus # %u\n", printf("Failed to allocate OcteonTX MDIO bus # %u\n",
dev_seq(dev)); dev_seq(dev));
return -1; ret = -ENOMEM;
goto error_ret;
} }
bus->read = octeontx_phy_read; bus->read = octeontx_phy_read;
@@ -355,9 +356,16 @@ int octeontx_smi_probe(struct udevice *dev)
ret = mdio_register(bus); ret = mdio_register(bus);
if (ret) if (ret)
return ret; goto error_ret;
} }
return 0; return 0;
error_ret:
if (bus)
free(bus);
if (priv)
free(priv);
return ret;
} }
static const struct udevice_id octeontx_smi_ids[] = { static const struct udevice_id octeontx_smi_ids[] = {

View File

@@ -298,6 +298,8 @@ int nix_lf_setup(struct nix *nix)
goto error; goto error;
} }
err = -1;
/* Alloc memory for Qints HW contexts */ /* Alloc memory for Qints HW contexts */
nix->qint_base = nix_memalloc(nix_af->qints, nix_af->qint_ctx_sz, nix->qint_base = nix_memalloc(nix_af->qints, nix_af->qint_ctx_sz,
"Qint CTX"); "Qint CTX");

View File

@@ -114,7 +114,7 @@ struct nix_af *rvu_af_init(struct rvu_af *rvu_af)
return nix_af; return nix_af;
error: error:
if (nix_af->npa_af) { if (nix_af && nix_af->npa_af) {
free(nix_af->npa_af); free(nix_af->npa_af);
memset(nix_af, 0, sizeof(*nix_af)); memset(nix_af, 0, sizeof(*nix_af));
} }

View File

@@ -134,6 +134,33 @@ static void bcm_phy_write_misc(struct phy_device *phydev,
phy_write(phydev, MDIO_DEVAD_NONE, MIIM_BCM54XX_EXP_DATA, value); phy_write(phydev, MDIO_DEVAD_NONE, MIIM_BCM54XX_EXP_DATA, value);
} }
/* Broadcom BCM54612E */
static int bcm54612e_config(struct phy_device *phydev)
{
u32 reg = 0;
genphy_config_aneg(phydev);
phy_reset(phydev);
/* 125Mhz Clock Output Enable */
reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_BCM54XX_EXP_SEL);
reg |= 0xD34;
phy_write(phydev, MDIO_DEVAD_NONE, MIIM_BCM54XX_EXP_SEL, reg);
reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_BCM54XX_EXP_DATA);
reg |= (1 << 1);
phy_write(phydev, MDIO_DEVAD_NONE, MIIM_BCM54XX_EXP_DATA, reg);
reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_BCM54XX_EXP_SEL);
reg &= 0xfffff000;
phy_write(phydev, MDIO_DEVAD_NONE, MIIM_BCM54XX_EXP_SEL, reg);
genphy_restart_aneg(phydev);
return 0;
}
/* Broadcom BCM5461S */ /* Broadcom BCM5461S */
static int bcm5461_config(struct phy_device *phydev) static int bcm5461_config(struct phy_device *phydev)
{ {
@@ -434,6 +461,16 @@ U_BOOT_PHY_DRIVER(bcm5461s) = {
.shutdown = &genphy_shutdown, .shutdown = &genphy_shutdown,
}; };
U_BOOT_PHY_DRIVER(bcm54612e) = {
.name = "Broadcom BCM54612E",
.uid = 0x03625e6a,
.mask = 0xfffff0,
.features = PHY_GBIT_FEATURES,
.config = &bcm54612e_config,
.startup = &bcm54xx_startup,
.shutdown = &genphy_shutdown,
};
U_BOOT_PHY_DRIVER(bcm5464s) = { U_BOOT_PHY_DRIVER(bcm5464s) = {
.name = "Broadcom BCM5464S", .name = "Broadcom BCM5464S",
.uid = 0x2060b0, .uid = 0x2060b0,

View File

@@ -239,7 +239,7 @@ static int vsc8514_config(struct phy_device *phydev)
while ((val & MIIM_VSC8514_18G_CMDSTAT) && timeout--) while ((val & MIIM_VSC8514_18G_CMDSTAT) && timeout--)
val = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_VSC8514_GENERAL18); val = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_VSC8514_GENERAL18);
if (0 == timeout) { if (timeout == -1) {
printf("PHY 8514 config failed\n"); printf("PHY 8514 config failed\n");
return -1; return -1;
} }

View File

@@ -225,11 +225,6 @@ static const struct reg_field pllctrl_lock =
static const struct reg_field phy_iso_link_ctrl_1 = static const struct reg_field phy_iso_link_ctrl_1 =
REG_FIELD(SIERRA_PHY_ISO_LINK_CTRL, 1, 1); REG_FIELD(SIERRA_PHY_ISO_LINK_CTRL, 1, 1);
static const char * const clk_names[] = {
[CDNS_SIERRA_PLL_CMNLC] = "pll_cmnlc",
[CDNS_SIERRA_PLL_CMNLC1] = "pll_cmnlc1",
};
enum cdns_sierra_cmn_plllc { enum cdns_sierra_cmn_plllc {
CMN_PLLLC, CMN_PLLLC,
CMN_PLLLC1, CMN_PLLLC1,
@@ -602,7 +597,7 @@ static int cdns_sierra_pll_bind_of_clocks(struct cdns_sierra_phy *sp)
struct udevice *dev = sp->dev; struct udevice *dev = sp->dev;
struct driver *cdns_sierra_clk_drv; struct driver *cdns_sierra_clk_drv;
struct cdns_sierra_pll_mux_sel *data = pll_clk_mux_sel; struct cdns_sierra_pll_mux_sel *data = pll_clk_mux_sel;
int i, rc; int rc;
cdns_sierra_clk_drv = lists_driver_lookup_name("cdns_sierra_mux_clk"); cdns_sierra_clk_drv = lists_driver_lookup_name("cdns_sierra_mux_clk");
if (!cdns_sierra_clk_drv) { if (!cdns_sierra_clk_drv) {
@@ -612,10 +607,8 @@ static int cdns_sierra_pll_bind_of_clocks(struct cdns_sierra_phy *sp)
rc = device_bind(dev, cdns_sierra_clk_drv, "pll_mux_clk", rc = device_bind(dev, cdns_sierra_clk_drv, "pll_mux_clk",
data, dev_ofnode(dev), NULL); data, dev_ofnode(dev), NULL);
if (rc) { if (rc)
dev_err(dev, "cannot bind driver for clock %s\n", dev_err(dev, "cannot bind driver for clock pll_mux_clk\n");
clk_names[i]);
}
return 0; return 0;
} }

View File

@@ -719,6 +719,7 @@ static int cdns_torrent_phy_probe(struct udevice *dev)
if (total_num_lanes > MAX_NUM_LANES) { if (total_num_lanes > MAX_NUM_LANES) {
dev_err(dev, "Invalid lane configuration\n"); dev_err(dev, "Invalid lane configuration\n");
ret = -EINVAL;
goto put_lnk_rst; goto put_lnk_rst;
} }

View File

@@ -28,7 +28,7 @@ static const char *get_speed_string(u32 speed)
"10.3125 Gbps" "10.3125 Gbps"
}; };
if (speed < 0 || speed > COMPHY_SPEED_MAX) if (speed < 0 || speed >= COMPHY_SPEED_MAX)
return "invalid"; return "invalid";
return speed_strings[speed]; return speed_strings[speed];
@@ -44,7 +44,7 @@ static const char *get_type_string(u32 type)
"IGNORE" "IGNORE"
}; };
if (type < 0 || type > COMPHY_TYPE_MAX) if (type < 0 || type >= COMPHY_TYPE_MAX)
return "invalid"; return "invalid";
return type_strings[type]; return type_strings[type];

View File

@@ -47,8 +47,8 @@ struct chip_serdes_phy_config {
int (*rx_training)(struct chip_serdes_phy_config *, u32); int (*rx_training)(struct chip_serdes_phy_config *, u32);
void __iomem *comphy_base_addr; void __iomem *comphy_base_addr;
void __iomem *hpipe3_base_addr; void __iomem *hpipe3_base_addr;
u32 comphy_lanes_count; int comphy_lanes_count;
u32 comphy_mux_bitcount; int comphy_mux_bitcount;
const fdt32_t *comphy_mux_lane_order; const fdt32_t *comphy_mux_lane_order;
u32 cp_index; u32 cp_index;
struct comphy_map comphy_map_data[MAX_LANE_OPTIONS]; struct comphy_map comphy_map_data[MAX_LANE_OPTIONS];

View File

@@ -1,9 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0 */ /* SPDX-License-Identifier: GPL-2.0-only */
/* /*
* LiMon Monitor (LiMon) - Network. * LiMon Monitor (LiMon) - Network.
* *
* Copyright 1994 - 2000 Neil Russell. * Copyright 1994 - 2000 Neil Russell.
* (See License)
* *
* History * History
* 9/16/00 bor adapted to TQM823L/STK8xxL board, RARP/TFTP boot added * 9/16/00 bor adapted to TQM823L/STK8xxL board, RARP/TFTP boot added
@@ -316,7 +315,7 @@ extern u32 net_boot_file_size;
/* Boot file size in blocks as reported by the DHCP server */ /* Boot file size in blocks as reported by the DHCP server */
extern u32 net_boot_file_expected_size_in_blocks; extern u32 net_boot_file_expected_size_in_blocks;
#if defined(CONFIG_CMD_DNS) #if defined(CONFIG_DNS)
extern char *net_dns_resolve; /* The host to resolve */ extern char *net_dns_resolve; /* The host to resolve */
extern char *net_dns_env_var; /* the env var to put the ip into */ extern char *net_dns_env_var; /* the env var to put the ip into */
#endif #endif

View File

@@ -18,6 +18,8 @@ extern size_t cacert_size;
extern enum auth_mode cacert_auth_mode; extern enum auth_mode cacert_auth_mode;
extern bool cacert_initialized; extern bool cacert_initialized;
extern int net_try_count;
int set_cacert_builtin(void); int set_cacert_builtin(void);
enum proto_t { enum proto_t {

View File

@@ -1,10 +1,10 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/* /*
* LiMon - BOOTP/TFTP. * LiMon - BOOTP/TFTP.
* *
* Copyright 1994, 1995, 2000 Neil Russell. * Copyright 1994, 1995, 2000 Neil Russell.
* Copyright 2011 Comelit Group SpA * Copyright 2011 Comelit Group SpA
* Luca Ceresoli <luca.ceresoli@comelit.it> * Luca Ceresoli <luca.ceresoli@comelit.it>
* (See License)
*/ */
#ifndef __TFTP_H__ #ifndef __TFTP_H__

View File

@@ -79,6 +79,14 @@ enum tftp_error {
#include <string.h> #include <string.h>
struct tftp_req {
ip_addr_t addr;
u16_t port;
u16_t opcode;
enum tftp_transfer_mode mode;
char* fname;
};
struct tftp_state { struct tftp_state {
const struct tftp_context *ctx; const struct tftp_context *ctx;
void *handle; void *handle;
@@ -97,14 +105,33 @@ struct tftp_state {
}; };
static struct tftp_state tftp_state; static struct tftp_state tftp_state;
static struct tftp_req tftp_req;
static void tftp_tmr(void *arg); static void tftp_tmr(void *arg);
static void tftp_req_tmr(void *arg);
static const char *mode_to_string(enum tftp_transfer_mode mode);
static void
clear_req(void)
{
ip_addr_set_any(0, &tftp_req.addr);
tftp_req.port = 0;
tftp_req.opcode = 0;
free(tftp_req.fname);
tftp_req.fname = NULL;
tftp_req.mode = 0;
sys_untimeout(tftp_req_tmr, NULL);
}
static void static void
close_handle(void) close_handle(void)
{ {
clear_req();
tftp_state.port = 0; tftp_state.port = 0;
ip_addr_set_any(0, &tftp_state.addr); ip_addr_set_any(0, &tftp_state.addr);
tftp_state.retries = 0;
if (tftp_state.last_data != NULL) { if (tftp_state.last_data != NULL) {
pbuf_free(tftp_state.last_data); pbuf_free(tftp_state.last_data);
@@ -209,6 +236,12 @@ send_ack(const ip_addr_t *addr, u16_t port, u16_t blknum)
return ret; return ret;
} }
static err_t
resend_request(void)
{
return send_request(&tftp_req.addr, tftp_req.port, tftp_req.opcode, tftp_req.fname, mode_to_string(tftp_req.mode));
}
static err_t static err_t
resend_data(const ip_addr_t *addr, u16_t port) resend_data(const ip_addr_t *addr, u16_t port)
{ {
@@ -336,6 +369,9 @@ tftp_recv(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr
tftp_state.last_pkt = tftp_state.timer; tftp_state.last_pkt = tftp_state.timer;
tftp_state.retries = 0; tftp_state.retries = 0;
if (tftp_req.fname)
clear_req();
switch (opcode) { switch (opcode) {
case PP_HTONS(TFTP_RRQ): /* fall through */ case PP_HTONS(TFTP_RRQ): /* fall through */
case PP_HTONS(TFTP_WRQ): { case PP_HTONS(TFTP_WRQ): {
@@ -542,6 +578,26 @@ tftp_tmr(void *arg)
} }
} }
static void
tftp_req_tmr(void *arg)
{
if (tftp_state.handle == NULL) {
return;
}
sys_timeout(TFTP_TIMER_MSECS, tftp_req_tmr, NULL);
if (tftp_state.retries < TFTP_MAX_RETRIES) {
LWIP_DEBUGF(TFTP_DEBUG | LWIP_DBG_STATE, ("tftp: req timeout, retrying\n"));
resend_request();
tftp_state.retries++;
} else {
LWIP_DEBUGF(TFTP_DEBUG | LWIP_DBG_STATE, ("tftp: req timeout\n"));
tftp_state.ctx->error(tftp_state.handle, -1, "Request timeout", strlen("Request timeout"));
close_handle();
}
}
/** /**
* Initialize TFTP client/server. * Initialize TFTP client/server.
* @param mode TFTP mode (client/server) * @param mode TFTP mode (client/server)
@@ -637,6 +693,20 @@ mode_to_string(enum tftp_transfer_mode mode)
return NULL; return NULL;
} }
err_t
start_send_requests(const ip_addr_t *addr, u16_t port, u16_t opcode, const char* fname, enum tftp_transfer_mode mode)
{
tftp_req.addr = *addr;
tftp_req.port = port;
tftp_req.opcode = opcode;
tftp_req.fname = strdup(fname);
tftp_req.mode = mode;
if (!tftp_req.fname)
return ERR_MEM;
sys_timeout(TFTP_TIMER_MSECS, tftp_req_tmr, NULL);
return resend_request();
}
err_t err_t
tftp_get(void* handle, const ip_addr_t *addr, u16_t port, const char* fname, enum tftp_transfer_mode mode) tftp_get(void* handle, const ip_addr_t *addr, u16_t port, const char* fname, enum tftp_transfer_mode mode)
{ {
@@ -647,7 +717,7 @@ tftp_get(void* handle, const ip_addr_t *addr, u16_t port, const char* fname, enu
tftp_state.handle = handle; tftp_state.handle = handle;
tftp_state.blknum = 1; tftp_state.blknum = 1;
tftp_state.mode_write = 1; /* We want to receive data */ tftp_state.mode_write = 1; /* We want to receive data */
return send_request(addr, port, TFTP_RRQ, fname, mode_to_string(mode)); return start_send_requests(addr, port, TFTP_RRQ, fname, mode);
} }
err_t err_t
@@ -660,7 +730,7 @@ tftp_put(void* handle, const ip_addr_t *addr, u16_t port, const char* fname, enu
tftp_state.handle = handle; tftp_state.handle = handle;
tftp_state.blknum = 1; tftp_state.blknum = 1;
tftp_state.mode_write = 0; /* We want to send data */ tftp_state.mode_write = 0; /* We want to send data */
return send_request(addr, port, TFTP_WRQ, fname, mode_to_string(mode)); return start_send_requests(addr, port, TFTP_WRQ, fname, mode);
} }
#endif /* LWIP_UDP */ #endif /* LWIP_UDP */

View File

@@ -80,9 +80,9 @@ void
icmp_input(struct pbuf *p, struct netif *inp) icmp_input(struct pbuf *p, struct netif *inp)
{ {
u8_t type; u8_t type;
#ifdef LWIP_DEBUG #if defined(LWIP_DEBUG) || defined(ICMP_DEST_UNREACH_CB)
u8_t code; u8_t code;
#endif /* LWIP_DEBUG */ #endif
struct icmp_echo_hdr *iecho; struct icmp_echo_hdr *iecho;
const struct ip_hdr *iphdr_in; const struct ip_hdr *iphdr_in;
u16_t hlen; u16_t hlen;
@@ -103,11 +103,11 @@ icmp_input(struct pbuf *p, struct netif *inp)
} }
type = *((u8_t *)p->payload); type = *((u8_t *)p->payload);
#ifdef LWIP_DEBUG #if defined(LWIP_DEBUG) || defined(ICMP_DEST_UNREACH_CB)
code = *(((u8_t *)p->payload) + 1); code = *(((u8_t *)p->payload) + 1);
/* if debug is enabled but debug statement below is somehow disabled: */ /* if debug is enabled but debug statement below is somehow disabled: */
LWIP_UNUSED_ARG(code); LWIP_UNUSED_ARG(code);
#endif /* LWIP_DEBUG */ #endif
switch (type) { switch (type) {
case ICMP_ER: case ICMP_ER:
/* This is OK, echo reply might have been parsed by a raw PCB /* This is OK, echo reply might have been parsed by a raw PCB
@@ -257,6 +257,15 @@ icmp_input(struct pbuf *p, struct netif *inp)
default: default:
if (type == ICMP_DUR) { if (type == ICMP_DUR) {
MIB2_STATS_INC(mib2.icmpindestunreachs); MIB2_STATS_INC(mib2.icmpindestunreachs);
#ifdef ICMP_DEST_UNREACH_CB
/*
* The callback receives the IP packet (not the ICMP message) so that
* it can extract the source address for example
*/
pbuf_add_header(p, IP_HLEN);
ICMP_DEST_UNREACH_CB(code, p);
pbuf_remove_header(p, IP_HLEN);
#endif
} else if (type == ICMP_TE) { } else if (type == ICMP_TE) {
MIB2_STATS_INC(mib2.icmpintimeexcds); MIB2_STATS_INC(mib2.icmpintimeexcds);
} else if (type == ICMP_PP) { } else if (type == ICMP_PP) {

View File

@@ -56,4 +56,11 @@ static inline const char *sntp_format_time(time_t t)
} }
#define sntp_format_time sntp_format_time #define sntp_format_time sntp_format_time
#ifdef CONFIG_LWIP_ICMP_SHOW_UNREACH
struct pbuf;
void net_lwip_icmp_dest_unreach(int code, struct pbuf *p);
#define ICMP_DEST_UNREACH_CB(_c, _p) net_lwip_icmp_dest_unreach(_c, _p)
#endif
#endif /* LWIP_ARCH_CC_H */ #endif /* LWIP_ARCH_CC_H */

View File

@@ -80,7 +80,11 @@
#define IP_DEFAULT_TTL 255 #define IP_DEFAULT_TTL 255
#if defined(CONFIG_PROT_ICMP_LWIP)
#define LWIP_ICMP 1
#else
#define LWIP_ICMP 0 #define LWIP_ICMP 0
#endif
#if defined(CONFIG_PROT_RAW_LWIP) #if defined(CONFIG_PROT_RAW_LWIP)
#define LWIP_RAW 1 #define LWIP_RAW 1

View File

@@ -244,11 +244,17 @@ config NET_RANDOM_ETHADDR
generated. It will be saved to the appropriate environment variable, generated. It will be saved to the appropriate environment variable,
too. too.
config DNS
bool "Enable DNS resolutions"
select PROT_DNS_LWIP if NET_LWIP
help
Selecting this will allow the network stack to use server names
in addition to IP addresses.
config WGET config WGET
bool "Enable wget" bool "Enable wget"
select PROT_TCP if NET select PROT_TCP if NET
select PROT_TCP_LWIP if NET_LWIP select PROT_TCP_LWIP if NET_LWIP
select PROT_DNS_LWIP if NET_LWIP
help help
Selecting this will enable wget, an interface to send HTTP requests Selecting this will enable wget, an interface to send HTTP requests
via the network stack. via the network stack.

View File

@@ -10,7 +10,7 @@ ifeq ($(CONFIG_NET),y)
obj-$(CONFIG_NET) += arp.o obj-$(CONFIG_NET) += arp.o
obj-$(CONFIG_CMD_BOOTP) += bootp.o obj-$(CONFIG_CMD_BOOTP) += bootp.o
obj-$(CONFIG_CMD_CDP) += cdp.o obj-$(CONFIG_CMD_CDP) += cdp.o
obj-$(CONFIG_CMD_DNS) += dns.o obj-$(CONFIG_DNS) += dns.o
obj-$(CONFIG_CMD_LINK_LOCAL) += link_local.o obj-$(CONFIG_CMD_LINK_LOCAL) += link_local.o
obj-$(CONFIG_IPV6) += ndisc.o obj-$(CONFIG_IPV6) += ndisc.o
obj-$(CONFIG_$(PHASE_)DM_ETH) += net.o obj-$(CONFIG_$(PHASE_)DM_ETH) += net.o

View File

@@ -1,9 +1,8 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copied from Linux Monitor (LiMon) - Networking. * Copied from Linux Monitor (LiMon) - Networking.
* *
* Copyright 1994 - 2000 Neil Russell. * Copyright 1994 - 2000 Neil Russell.
* (See License)
* Copyright 2000 Roland Borde * Copyright 2000 Roland Borde
* Copyright 2000 Paolo Scaffardi * Copyright 2000 Paolo Scaffardi
* Copyright 2000-2002 Wolfgang Denk, wd@denx.de * Copyright 2000-2002 Wolfgang Denk, wd@denx.de

View File

@@ -1,9 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0 */ /* SPDX-License-Identifier: GPL-2.0-only */
/* /*
* Copied from Linux Monitor (LiMon) - Networking. * Copied from Linux Monitor (LiMon) - Networking.
* *
* Copyright 1994 - 2000 Neil Russell. * Copyright 1994 - 2000 Neil Russell.
* (See License)
* Copyright 2000 Roland Borde * Copyright 2000 Roland Borde
* Copyright 2000 Paolo Scaffardi * Copyright 2000 Paolo Scaffardi
* Copyright 2000-2002 Wolfgang Denk, wd@denx.de * Copyright 2000-2002 Wolfgang Denk, wd@denx.de

View File

@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/* /*
* Based on LiMon - BOOTP. * Based on LiMon - BOOTP.
* *
* Copyright 1994, 1995, 2000 Neil Russell. * Copyright 1994, 1995, 2000 Neil Russell.
* (See License)
* Copyright 2000 Roland Borde * Copyright 2000 Roland Borde
* Copyright 2000 Paolo Scaffardi * Copyright 2000 Paolo Scaffardi
* Copyright 2000-2004 Wolfgang Denk, wd@denx.de * Copyright 2000-2004 Wolfgang Denk, wd@denx.de

View File

@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/* /*
* Copied from LiMon - BOOTP. * Copied from LiMon - BOOTP.
* *
* Copyright 1994, 1995, 2000 Neil Russell. * Copyright 1994, 1995, 2000 Neil Russell.
* (See License)
* Copyright 2000 Paolo Scaffardi * Copyright 2000 Paolo Scaffardi
*/ */

View File

@@ -1,9 +1,8 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copied from Linux Monitor (LiMon) - Networking. * Copied from Linux Monitor (LiMon) - Networking.
* *
* Copyright 1994 - 2000 Neil Russell. * Copyright 1994 - 2000 Neil Russell.
* (See License)
* Copyright 2000 Roland Borde * Copyright 2000 Roland Borde
* Copyright 2000 Paolo Scaffardi * Copyright 2000 Paolo Scaffardi
* Copyright 2000-2002 Wolfgang Denk, wd@denx.de * Copyright 2000-2002 Wolfgang Denk, wd@denx.de

View File

@@ -1,9 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0 */ /* SPDX-License-Identifier: GPL-2.0-only */
/* /*
* Copied from Linux Monitor (LiMon) - Networking. * Copied from Linux Monitor (LiMon) - Networking.
* *
* Copyright 1994 - 2000 Neil Russell. * Copyright 1994 - 2000 Neil Russell.
* (See License)
* Copyright 2000 Roland Borde * Copyright 2000 Roland Borde
* Copyright 2000 Paolo Scaffardi * Copyright 2000 Paolo Scaffardi
* Copyright 2000-2002 Wolfgang Denk, wd@denx.de * Copyright 2000-2002 Wolfgang Denk, wd@denx.de

View File

@@ -4,6 +4,16 @@
if NET_LWIP if NET_LWIP
config LWIP_ICMP_SHOW_UNREACH
bool "Print ICMP Destination Unreachable messages"
default y
depends on CMD_TFTPBOOT || CMD_SNTP
select PROT_ICMP_LWIP
help
Prints a message whenever an ICMP Destination Unreachable message is
received while running a network command that sends requests via UDP.
Enabling this can make troubleshooting easier.
config LWIP_DEBUG config LWIP_DEBUG
bool "Enable debug traces in the lwIP library" bool "Enable debug traces in the lwIP library"
help help
@@ -31,6 +41,9 @@ config PROT_DNS_LWIP
bool bool
select PROT_UDP_LWIP select PROT_UDP_LWIP
config PROT_ICMP_LWIP
bool
config PROT_RAW_LWIP config PROT_RAW_LWIP
bool bool

View File

@@ -2,6 +2,8 @@ ccflags-y += -I$(srctree)/lib/lwip/lwip/src/include -I$(srctree)/lib/lwip/u-boot
obj-$(CONFIG_$(PHASE_)DM_ETH) += net-lwip.o obj-$(CONFIG_$(PHASE_)DM_ETH) += net-lwip.o
obj-$(CONFIG_CMD_DHCP) += dhcp.o obj-$(CONFIG_CMD_DHCP) += dhcp.o
obj-$(CONFIG_DNS) += dns.o
obj-$(CONFIG_LWIP_ICMP_SHOW_UNREACH) += icmp_unreach.o
obj-$(CONFIG_CMD_TFTPBOOT) += tftp.o obj-$(CONFIG_CMD_TFTPBOOT) += tftp.o
obj-$(CONFIG_WGET) += wget.o obj-$(CONFIG_WGET) += wget.o

113
net/lwip/dns.c Normal file
View File

@@ -0,0 +1,113 @@
// SPDX-License-Identifier: GPL-2.0+
/* Copyright (C) 2024 Linaro Ltd. */
#include <command.h>
#include <console.h>
#include <env.h>
#include <lwip/dns.h>
#include <lwip/timeouts.h>
#include <net.h>
#include <time.h>
#define DNS_RESEND_MS 1000
#define DNS_TIMEOUT_MS 10000
struct dns_cb_arg {
ip_addr_t host_ipaddr;
const char *var;
bool done;
};
static void do_dns_tmr(void *arg)
{
dns_tmr();
}
static void dns_cb(const char *name, const ip_addr_t *ipaddr, void *arg)
{
struct dns_cb_arg *dns_cb_arg = arg;
char *ipstr = ip4addr_ntoa(ipaddr);
dns_cb_arg->done = true;
if (!ipaddr) {
printf("DNS: host not found\n");
dns_cb_arg->host_ipaddr.addr = 0;
return;
}
dns_cb_arg->host_ipaddr.addr = ipaddr->addr;
if (dns_cb_arg->var)
env_set(dns_cb_arg->var, ipstr);
}
static int dns_loop(struct udevice *udev, const char *name, const char *var)
{
struct dns_cb_arg dns_cb_arg = { };
struct netif *netif;
ip_addr_t ipaddr;
ulong start;
int ret;
dns_cb_arg.var = var;
netif = net_lwip_new_netif(udev);
if (!netif)
return CMD_RET_FAILURE;
if (net_lwip_dns_init()) {
net_lwip_remove_netif(netif);
return CMD_RET_FAILURE;
}
dns_cb_arg.done = false;
ret = dns_gethostbyname(name, &ipaddr, dns_cb, &dns_cb_arg);
if (ret == ERR_OK) {
dns_cb(name, &ipaddr, &dns_cb_arg);
} else if (ret == ERR_INPROGRESS) {
start = get_timer(0);
sys_timeout(DNS_RESEND_MS, do_dns_tmr, NULL);
do {
net_lwip_rx(udev, netif);
if (dns_cb_arg.done)
break;
if (ctrlc()) {
printf("\nAbort\n");
break;
}
} while (get_timer(start) < DNS_TIMEOUT_MS);
sys_untimeout(do_dns_tmr, NULL);
}
net_lwip_remove_netif(netif);
if (dns_cb_arg.done && dns_cb_arg.host_ipaddr.addr != 0) {
if (!var)
printf("%s\n", ipaddr_ntoa(&ipaddr));
return CMD_RET_SUCCESS;
}
return CMD_RET_FAILURE;
}
int do_dns(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
char *name;
char *var = NULL;
if (argc == 1 || argc > 3)
return CMD_RET_USAGE;
name = argv[1];
if (argc == 3)
var = argv[2];
if (net_lwip_eth_start() < 0)
return CMD_RET_FAILURE;
return dns_loop(eth_get_dev(), name, var);
}

38
net/lwip/icmp_unreach.c Normal file
View File

@@ -0,0 +1,38 @@
// SPDX-License-Identifier: GPL-2.0+
/* Copyright (C) 2025 Linaro Ltd. */
#include <lwip/icmp.h>
#include <lwip/ip4_addr.h>
#include <lwip/pbuf.h>
#include <lwip/prot/ip4.h>
static const char *code_to_str(int code)
{
switch (code) {
case ICMP_DUR_NET:
return "network unreachable";
case ICMP_DUR_HOST:
return "host unreachable";
case ICMP_DUR_PROTO:
return "protocol unreachable";
case ICMP_DUR_PORT:
return "port unreachable";
case ICMP_DUR_FRAG:
return "fragmentation needed and DF set";
case ICMP_DUR_SR:
return "source route failed";
default:
break;
}
return "unknown cause";
}
void net_lwip_icmp_dest_unreach(int code, struct pbuf *p)
{
struct ip_hdr *iphdr = (struct ip_hdr *)p->payload;
ip4_addr_t src;
ip4_addr_copy(src, iphdr->src);
printf("ICMP destination unreachable (%s) from %s\n",
code_to_str(code), ip4addr_ntoa(&src));
}

View File

@@ -27,7 +27,7 @@
#if defined(CONFIG_API) || defined(CONFIG_EFI_LOADER) #if defined(CONFIG_API) || defined(CONFIG_EFI_LOADER)
void (*push_packet)(void *, int len) = 0; void (*push_packet)(void *, int len) = 0;
#endif #endif
static int net_try_count; int net_try_count;
static int net_restarted; static int net_restarted;
int net_restart_wrap; int net_restart_wrap;
static uchar net_pkt_buf[(PKTBUFSRX) * PKTSIZE_ALIGN + PKTALIGN]; static uchar net_pkt_buf[(PKTBUFSRX) * PKTSIZE_ALIGN + PKTALIGN];
@@ -147,7 +147,7 @@ static int get_udev_ipv4_info(struct udevice *dev, ip4_addr_t *ip,
*/ */
int net_lwip_dns_init(void) int net_lwip_dns_init(void)
{ {
#if CONFIG_IS_ENABLED(CMD_DNS) #if CONFIG_IS_ENABLED(DNS)
bool has_server = false; bool has_server = false;
ip_addr_t ns; ip_addr_t ns;
char *nsenv; char *nsenv;
@@ -364,7 +364,7 @@ int net_lwip_rx(struct udevice *udev, struct netif *netif)
*/ */
int net_lwip_dns_resolve(char *name_or_ip, ip_addr_t *ip) int net_lwip_dns_resolve(char *name_or_ip, ip_addr_t *ip)
{ {
#if defined(CONFIG_CMD_DNS) #if defined(CONFIG_DNS)
char *var = "_dnsres"; char *var = "_dnsres";
char *argv[] = { "dns", name_or_ip, var, NULL }; char *argv[] = { "dns", name_or_ip, var, NULL };
int argc = ARRAY_SIZE(argv) - 1; int argc = ARRAY_SIZE(argv) - 1;
@@ -373,7 +373,7 @@ int net_lwip_dns_resolve(char *name_or_ip, ip_addr_t *ip)
if (ipaddr_aton(name_or_ip, ip)) if (ipaddr_aton(name_or_ip, ip))
return 0; return 0;
#if defined(CONFIG_CMD_DNS) #if defined(CONFIG_DNS)
if (do_dns(NULL, 0, argc, argv) != CMD_RET_SUCCESS) if (do_dns(NULL, 0, argc, argv) != CMD_RET_SUCCESS)
return -1; return -1;

View File

@@ -1,9 +1,8 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copied from Linux Monitor (LiMon) - Networking. * Copied from Linux Monitor (LiMon) - Networking.
* *
* Copyright 1994 - 2000 Neil Russell. * Copyright 1994 - 2000 Neil Russell.
* (See License)
* Copyright 2000 Roland Borde * Copyright 2000 Roland Borde
* Copyright 2000 Paolo Scaffardi * Copyright 2000 Paolo Scaffardi
* Copyright 2000-2002 Wolfgang Denk, wd@denx.de * Copyright 2000-2002 Wolfgang Denk, wd@denx.de
@@ -115,7 +114,7 @@
#include "bootp.h" #include "bootp.h"
#include "cdp.h" #include "cdp.h"
#include "dhcpv6.h" #include "dhcpv6.h"
#if defined(CONFIG_CMD_DNS) #if defined(CONFIG_DNS)
#include "dns.h" #include "dns.h"
#endif #endif
#include "link_local.h" #include "link_local.h"
@@ -288,7 +287,7 @@ static int on_vlan(const char *name, const char *value, enum env_op op,
} }
U_BOOT_ENV_CALLBACK(vlan, on_vlan); U_BOOT_ENV_CALLBACK(vlan, on_vlan);
#if defined(CONFIG_CMD_DNS) #if defined(CONFIG_DNS)
static int on_dnsip(const char *name, const char *value, enum env_op op, static int on_dnsip(const char *name, const char *value, enum env_op op,
int flags) int flags)
{ {
@@ -582,7 +581,7 @@ restart:
nc_start(); nc_start();
break; break;
#endif #endif
#if defined(CONFIG_CMD_DNS) #if defined(CONFIG_DNS)
case DNS: case DNS:
dns_start(); dns_start();
break; break;
@@ -1507,7 +1506,7 @@ static int net_check_prereq(enum proto_t protocol)
} }
goto common; goto common;
#endif #endif
#if defined(CONFIG_CMD_DNS) #if defined(CONFIG_DNS)
case DNS: case DNS:
if (net_dns_server.s_addr == 0) { if (net_dns_server.s_addr == 0) {
puts("*** ERROR: DNS server address not given\n"); puts("*** ERROR: DNS server address not given\n");
@@ -1540,7 +1539,7 @@ static int net_check_prereq(enum proto_t protocol)
return 1; return 1;
} }
#if defined(CONFIG_CMD_PING) || \ #if defined(CONFIG_CMD_PING) || \
defined(CONFIG_CMD_DNS) || defined(CONFIG_PROT_UDP) defined(CONFIG_DNS) || defined(CONFIG_PROT_UDP)
common: common:
#endif #endif
/* Fall through */ /* Fall through */

View File

@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/* /*
* Copied from LiMon - BOOTP. * Copied from LiMon - BOOTP.
* *
* Copyright 1994, 1995, 2000 Neil Russell. * Copyright 1994, 1995, 2000 Neil Russell.
* (See License)
* Copyright 2000 Paolo Scaffardi * Copyright 2000 Paolo Scaffardi
*/ */

View File

@@ -1,9 +1,8 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copied from Linux Monitor (LiMon) - Networking. * Copied from Linux Monitor (LiMon) - Networking.
* *
* Copyright 1994 - 2000 Neil Russell. * Copyright 1994 - 2000 Neil Russell.
* (See License)
* Copyright 2000 Roland Borde * Copyright 2000 Roland Borde
* Copyright 2000 Paolo Scaffardi * Copyright 2000 Paolo Scaffardi
* Copyright 2000-2002 Wolfgang Denk, wd@denx.de * Copyright 2000-2002 Wolfgang Denk, wd@denx.de

View File

@@ -1,9 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0 */ /* SPDX-License-Identifier: GPL-2.0-only */
/* /*
* Copied from Linux Monitor (LiMon) - Networking. * Copied from Linux Monitor (LiMon) - Networking.
* *
* Copyright 1994 - 2000 Neil Russell. * Copyright 1994 - 2000 Neil Russell.
* (See License)
* Copyright 2000 Roland Borde * Copyright 2000 Roland Borde
* Copyright 2000 Paolo Scaffardi * Copyright 2000 Paolo Scaffardi
* Copyright 2000-2002 Wolfgang Denk, wd@denx.de * Copyright 2000-2002 Wolfgang Denk, wd@denx.de

View File

@@ -393,7 +393,7 @@ int wget_do_request(ulong dst_addr, char *uri)
if (string_to_ip(host_name).s_addr) { if (string_to_ip(host_name).s_addr) {
s = host_name; s = host_name;
} else { } else {
#if IS_ENABLED(CONFIG_CMD_DNS) #if IS_ENABLED(CONFIG_DNS)
net_dns_resolve = host_name; net_dns_resolve = host_name;
net_dns_env_var = "httpserverip"; net_dns_env_var = "httpserverip";
if (net_loop(DNS) < 0) { if (net_loop(DNS) < 0) {