net/lwip: add lwip library for the network stack
Subsystems (2)
v8 cover net/lwip: add lwip library for the network stack
Before apply these patches it is needed to create lwIP merge into U-Boot:
git subtree add --prefix net/lwip/lwip-external https://git.savannah.nongnu.org/git/lwip.git master --squash or
create git submodule, depends how it's more easy to maintain external
library.
changelog:
v8: - comments for previous review
- removed lwip timeout callback pointer
- made lwip timeouts works, that also allowed to remove
static vars.
- setenv for filesize tftp and wget has to be in hex.
- Makefile changes always compile it tftp,dns,wget,ping due
to it can be used not only by CONFIG_CMD_.
- Kconfig changes - simplify lwIP settings and support only
one configuration.
- tested with mini debian.iso load over http or tftp, mount
and boot it (qemu, arm64).
v7: - more review fixes.
- support of multiply eth devices, were "ethact" selects the
active device.
v6: - fixed review comments for v5 (thanks Ilias and Simon).
- lwip is not under /net, so prior applying patch following
commit is needed to create lwIP merge into U-Boot:
git subtree add --prefix net/lwip/lwip-external https://git.savannah.nongnu.org/git/lwip.git master --squash
v5: - fixed Iliases comments and split big patch on the small
ones.
You also need to issue command:
git subtree add --prefix lib/lwip/lwip-external https://git.savannah.nongnu.org/git/lwip.git master --squash Which will create merge commit of lwip library placing sources
into lib/lwip/lwip-external directory. I do not send it a patch
due to 1. merges are not friendly with git format-patch and 2.
the source code of lwip is 78kb.
v4: - tested with tests/py/ did some minor fixes (out of tree
build, variables set after downloads).
- accounted review comments for documentation.
- implemented dns command
- corrected wget command to not use serverip variable and use just
url string.
v3: - use lwip commands for ping,tftp,wget,dhcp if this patch
applied. Drop CONFIG_LIB_LWIP_REPLACE_<COMMAND> option.
- docs: use rst variant and drop references to RFC.
Maxim Uvarov (15):
net/lwip: add doc/develop/net_lwip.rst net/lwip: integrate lwIP library net/lwip: implement dns cmd
net/lwip: implement dhcp cmd
net/lwip: implement tftp cmd
net/lwip: implement wget cmd
net/lwip: implement ping cmd
net/lwip: add lwIP configuration net/lwip: implement lwIP port to U-Boot net/lwip: update .gitignore with lwIP net/lwip: connection between cmd and lwip apps net/lwip: replace original net commands with lwip net/lwip: split net.h to net.h, arp.h and eth.h net/lwip: drop old net/wget
net/lwip/wget add port selection
boot/bootmeth_efi.c | 18 +- boot/bootmeth_pxe.c | 21 +- cmd/Makefile | 1 + cmd/net-lwip.c | 286 +++++++++++++++++ cmd/net.c | 86 +---- cmd/pxe.c | 19 +- doc/develop/index.rst | 1 + doc/develop/net_lwip.rst | 75 +++++ include/net.h | 197 +----------- include/net/arp.h | 7 + include/net/eth.h | 190 +++++++++++ include/net/lwip.h | 73 +++++ include/net/ulwip.h | 64 ++++ include/net/wget.h | 22 -- net/Kconfig | 3 + net/Makefile | 2 +- net/eth-uclass.c | 8 + net/lwip/.gitignore | 8 + net/lwip/Kconfig | 25 ++ net/lwip/Makefile | 70 ++++ net/lwip/apps/dhcp/lwip-dhcp.c | 61 ++++ net/lwip/apps/dns/lwip-dns.c | 63 ++++ net/lwip/apps/http/Makefile | 6 + net/lwip/apps/http/lwip-wget.c | 126 ++++++++ net/lwip/apps/ping/Makefile | 12 + net/lwip/apps/ping/lwip_ping.c | 40 +++ net/lwip/apps/ping/lwip_ping.h | 15 + net/lwip/apps/ping/ping.h | 19 ++ net/lwip/apps/tftp/Makefile | 7 + net/lwip/apps/tftp/lwip-tftp.c | 129 ++++++++ net/lwip/lwipopts.h | 178 +++++++++++ net/lwip/port/if.c | 332 +++++++++++++++++++ net/lwip/port/include/arch/cc.h | 38 +++ net/lwip/port/include/arch/sys_arch.h | 10 + net/lwip/port/include/limits.h | 0 net/lwip/port/sys-arch.c | 13 + net/net.c | 26 +- net/wget.c | 440 -------------------------- 38 files changed, 1933 insertions(+), 758 deletions(-) create mode 100644 cmd/net-lwip.c create mode 100644 doc/develop/net_lwip.rst create mode 100644 include/net/arp.h create mode 100644 include/net/eth.h create mode 100644 include/net/lwip.h create mode 100644 include/net/ulwip.h delete mode 100644 include/net/wget.h create mode 100644 net/lwip/.gitignore create mode 100644 net/lwip/Kconfig create mode 100644 net/lwip/Makefile create mode 100644 net/lwip/apps/dhcp/lwip-dhcp.c create mode 100644 net/lwip/apps/dns/lwip-dns.c create mode 100644 net/lwip/apps/http/Makefile create mode 100644 net/lwip/apps/http/lwip-wget.c create mode 100644 net/lwip/apps/ping/Makefile create mode 100644 net/lwip/apps/ping/lwip_ping.c create mode 100644 net/lwip/apps/ping/lwip_ping.h create mode 100644 net/lwip/apps/ping/ping.h create mode 100644 net/lwip/apps/tftp/Makefile create mode 100644 net/lwip/apps/tftp/lwip-tftp.c create mode 100644 net/lwip/lwipopts.h create mode 100644 net/lwip/port/if.c create mode 100644 net/lwip/port/include/arch/cc.h create mode 100644 net/lwip/port/include/arch/sys_arch.h create mode 100644 net/lwip/port/include/limits.h create mode 100644 net/lwip/port/sys-arch.c delete mode 100644 net/wget.c
Signature · 1 line
2.30.2
PATCH v8 1/15 net/lwip: add doc/develop/net_lwip.rst
Add initial documentation of lwIP network IP stack integration to the U-Boot (net_lwip.rst).
--- doc/develop/index.rst | 1 + doc/develop/net_lwip.rst | 75 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 doc/develop/net_lwip.rst
doc/develop/index.rst +1 -0
@@ -48,6 +48,7 @@ Implementation spl falcon uefi/index + net_lwip vbe version
doc/develop/net_lwip.rst new file +75 -0
75 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [PATCHv8 01/15] net/lwip: add doc/develop/net_lwip.rst
Quoted 107 lines · Maxim Uvarov
Add initial documentation of lwIP network IP stack integration to the U-Boot (
net_lwip.rst).Signed-off-by Maxim Uvarov <[email protected]>Reviewed-by Simon Glass <[email protected]>--- doc/develop/index.rst | 1 + doc/develop/net_lwip.rst | 75 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 doc/develop/net_lwip.rstdoc/develop/index.rst +1
-0@@ -48,6 +48,7 @@ Implementation spl falcon uefi/index + net_lwip vbe versiondoc/develop/net_lwip.rst new file +75
-0@@ -0,0 +1,75 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +lwIP IP stack integration for U-Boot +==================================== + +Intro +----- + +lwIP is a library implementing network protocols, which is commonly used +on embedded devices. + +https://savannah.nongnu.org/projects/lwip/ +lwIP license: +lwIP is licensed under a BSD-style license: http://lwip.wikia.com/wiki/License. + +Main features include: + +* Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE + +* DHCP client, DNS client (incl. mDNS hostname resolver), + AutoIP/APIPA (Zeroconf), SNMP agent (v1, v2c, v3, private MIB support + & MIB compiler) + +* APIs: specialized APIs for enhanced performance, optional Berkeley-alike + socket API + +* Extended features: IP forwarding over multiple network interfaces, TCP + congestion control, RTT estimation and fast recovery/fast retransmit + +* Addon applications: HTTP(S) server, SNTP client, SMTP(S) client, ping, + NetBIOS nameserver, mDNS responder, MQTT client, TFTP server + +U-Boot implementation details +----------------------------- + +1. In general we can build lwIP as a library and link it against U-Boot or + compile it in the U-Boot tree in the same way as other U-Boot files. There + are few reasons why second variant was selected: lwIP is very customizable + with defines for features, memory size, types of allocation, some internal + types and platform specific code. It turned out easier to enable/disable + debug which is also done with defines, and is needed periodically. + +2. lwIP has 2 APIs - raw mode and sequential (as lwIP names it, or socket API + as we name it in Linux). For now only raw API is supported. + +In raw IP mode a callback function for RX path is registered and will be called +when packet is passed to the IP stack and is ready for the application. + +One example is the unmodified working ping example from lwip sources which +registered the callback: + +.. code-block:: c + + ping_pcb = raw_new(IP_PROTO_ICMP); + raw_recv(ping_pcb, ping_recv, NULL); <- ping_recv is app callback. + raw_bind(ping_pcb, IP_ADDR_ANY) + +3. Input and output + +RX packet path is injected to U-Boot eth_rx() polling loop and TX patch is in +eth_send() accordingly. That way we can leave the driver code unmodified and +consume packets once they are ready. So we do not touch any drivers code and +just eat packets when they are ready. + +U-Boot lwIP Applications +======================== + +.. kernel-doc:: include/net/lwip.h + :internal: + +lwIP API to control polling loop +================================ + +.. kernel-doc:: include/net/ulwip.h + :internal:Signature · 1 line
2.30.2
PATCH v8 2/15 net/lwip: integrate lwIP library
In reply to Maxim UvarovDefine Makefile and Kconfig to build lwIP inside the U-Boot. We compile lwIP the same as the main code, plus we can do optimization for size at compile time with disabling not needed debug asserts, or not used protocols. So we can tune lwIP configuration specially for U-Boot environments.
--- net/Kconfig | 3 +++ net/Makefile | 1 + net/lwip/Kconfig | 25 ++++++++++++++++++ net/lwip/Makefile | 64 +++++++++++++++++++++++++++++++++++++++++++++++ net/net.c | 20 ++++++++++++++- 5 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 net/lwip/Kconfig create mode 100644 net/lwip/Makefile
net/Kconfig +3 -0
@@ -5,9 +5,12 @@ menuconfig NET bool "Networking support" default y + imply LWIP if NET +source net/lwip/Kconfig + config ARP_TIMEOUT int "Milliseconds before trying ARP again" default 5000
net/Makefile +1 -0
@@ -33,6 +33,7 @@ obj-$(CONFIG_CMD_WOL) += wol.o obj-$(CONFIG_PROT_UDP) += udp.o obj-$(CONFIG_PROT_TCP) += tcp.o obj-$(CONFIG_CMD_WGET) += wget.o +obj-$(CONFIG_LWIP) += lwip/ # Disable this warning as it is triggered by: # sprintf(buf, index ? "foo%d" : "foo", index)
net/lwip/Kconfig new file +25 -0
@@ -0,0 +1,25 @@ +menu "lwIP" +config LWIP + bool "Support LWIP library" + help + Enable the lwIP library code with + all dependencies (commands are implemented with lwIP + library. This option is automatically enabled if CONFIG_NET=y. + lwIP library (https://git.savannah.nongnu.org/git/lwip.git) provides + network stack and application code for U-Boot commands. + Please see doc/develop/net_lwip.rst for more details. + +menu "LWIP options" + +config LWIP_LIB_DEBUG + bool "enable debug" + default n + +config LWIP_LIB_NOASSERT + bool "disable asserts" + default y + help + Disabling asserts reduces binary size by 16k. +endmenu + +endmenu
net/lwip/Makefile new file +64 -0
64 lines not on this page · raw message
net/net.c +19 -1
@@ -125,6 +125,7 @@#endif #include "dhcpv6.h" #include "net_rand.h" +#include <net/ulwip.h> /** BOOTP EXTENTIONS **/
@@ -452,7 +453,9 @@ int net_loop(enum proto_t protocol)#endif bootstage_mark_name (BOOTSTAGE_ID_ETH_START ,"eth_start" ); -net_init (); +if (!ulwip_enabled () || !ulwip_in_loop ()) +net_init (); +if (eth_is_on_demand_init ()) {eth_halt ();eth_set_current ();
@@ -649,6 +652,16 @@ restart:*/ eth_rx (); +if (ulwip_enabled ()) { +net_set_state (NETLOOP_CONTINUE ); +if (!ulwip_in_loop ()) { +if (ulwip_app_get_err ()) +net_set_state (NETLOOP_FAIL ); +else +net_set_state (NETLOOP_SUCCESS ); + goto done; + } + }/* * Abort if ctrl-c was pressed. */
@@ -1213,6 +1226,11 @@ void net_process_received_packet(uchar *in_packet, int len)if (len <ETHER_HDR_SIZE )return ; +if (ulwip_enabled ()) { +ulwip_poll (); +return ; + } +#if defined(CONFIG_API ) || defined(CONFIG_EFI_LOADER )if (push_packet) { (*push_packet)(in_packet, len);
Signature · 1 line
2.30.2
PATCH v8 3/15 net/lwip: implement dns cmd
In reply to Maxim UvarovU-Boot recently got support for an alternative network stack using LWIP. Replace dns command with the LWIP variant while keeping the output and error messages identical.
--- include/net/lwip.h | 19 +++++++++++ net/lwip/Makefile | 2 ++ net/lwip/apps/dns/lwip-dns.c | 63 ++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 include/net/lwip.h create mode 100644 net/lwip/apps/dns/lwip-dns.c
include/net/lwip.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +int do_lwip_dns (struct cmd_tbl *cmdtp,int flag,int argc, +char *const argv[]); + +/** +* ulwip_dns() - creates the DNS request to resolve a domain host name +* +* This function creates the DNS request to resolve a domain host name. Function +* can return immediately if previous request was cached or it might require +* entering the polling loop for a request to a remote server. +* +* @name: dns name to resolve +* @varname: (optional) U-Boot variable name to store the result +* Returns: ERR_OK(0) for fetching entry from the cache +* -EINPROGRESS success, can go to the polling loop +* Other value < 0, if error +*/ +int ulwip_dns (char *name,char *varname);
net/lwip/Makefile +2 -0
@@ -62,3 +62,5 @@ obj-$(CONFIG_NET) += lwip-external/src/netif/ethernet.o obj-$(CONFIG_NET) += port/if.o obj-$(CONFIG_NET) += port/sys-arch.o + +obj-y += apps/dns/lwip-dns.o
net/lwip/apps/dns/lwip-dns.c new file +63 -0
63 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [PATCHv8 03/15] net/lwip: implement dns cmd
Quoted 96 lines · Maxim Uvarov
U-Boot recently got support for an alternative network stack using LWIP. Replace dns command with the LWIP variant while keeping the output and error messages identical.
Signed-off-by Maxim Uvarov <[email protected]>--- include/net/lwip.h | 19 +++++++++++ net/lwip/Makefile | 2 ++ net/lwip/apps/dns/lwip-dns.c | 63 ++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 include/net/lwip.h create mode 100644 net/lwip/apps/dns/lwip-dns.cinclude/net/lwip.h new file +19
-0@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +int do_lwip_dns (struct cmd_tbl *cmdtp,int flag,int argc, +char *const argv[]); + +/** +* ulwip_dns() - creates the DNS request to resolve a domain host name +* +* This function creates the DNS request to resolve a domain host name. Function +* can return immediately if previous request was cached or it might require +* entering the polling loop for a request to a remote server. +* +* @name: dns name to resolve +* @varname: (optional) U-Boot variable name to store the result +* Returns: ERR_OK(0) for fetching entry from the cache +* -EINPROGRESS success, can go to the polling loop +* Other value < 0, if error +*/ +int ulwip_dns (char *name,char *varname);net/lwip/Makefile +2
-0@@ -62,3 +62,5 @@ obj-$(CONFIG_NET) += lwip-external/src/netif/ethernet.o obj-$(CONFIG_NET) += port/if.o obj-$(CONFIG_NET) += port/sys-arch.o + +obj-y += apps/dns/lwip-dns.onet/lwip/apps/dns/lwip-dns.c new file +42
-0@@ -0,0 +1,63 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* +* (C) Copyright 2023 Linaro Ltd. <[email protected]> +*/ + +#include <common.h> +#include <command.h> +#include <console.h> + +#include <lwip/dns.h> +#include <lwip/ip_addr.h> + +#include <net/ulwip.h> + +static void dns_found_cb (const char *name,const ip_addr_t *ipaddr,void *callback_arg) +{ +char *varname = (char *)callback_arg; +char *ipstr =ip4addr_ntoa (ipaddr); + +if (varname) +env_set (varname, ipstr); +log_info ("resolved %s to %s\n" , name, ipstr); +ulwip_exit (0 ); +} + +int ulwip_dns (char *name,char *varname) +{ +int err; +ip_addr_t ipaddr;/* not used */ +ip_addr_t dns1; +ip_addr_t dns2; +char *dnsenv =env_get ("dnsip" ); +char *dns2env =env_get ("dnsip2" ); + +if (!dnsenv && !dns2env) { +log_err ("nameserver is not set with dnsip and dnsip2 vars\n" ); +return -ENOENT ; + } + +if (!dnsenv) +log_warning ("dnsip var is not set\n" );
net/lwip/apps/dns/lwip-dns.c line 52
Quoted 10 lines
net/lwip/apps/dns/lwip-dns.c new file +10
-0+if (!dns2env) +log_warning ("dnsip2 var is not set\n" ); + +dns_init (); + +if (ipaddr_aton (dnsenv, &dns1)) +dns_setserver (0 , &dns1); + +if (ipaddr_aton (dns2env, &dns2)) +dns_setserver (1 , &dns2);
env_get will return NULL if any of these is not set. Looking at ipaddr_aton() of lwip that might lead to a NULL deref in ip_2_ip6()
Quoted 14 lines
net/lwip/apps/dns/lwip-dns.c new file +11
-1+ + err =dns_gethostbyname (name, &ipaddr, dns_found_cb, varname); +if (err ==ERR_OK ) +dns_found_cb (name, &ipaddr, varname); + +/* convert lwIP ERR_INPROGRESS to U-Boot -EINPROGRESS */ +if (err ==ERR_INPROGRESS ) + err = -EINPROGRESS ; + +return err; +} --2.30.2
Re: [PATCHv8 03/15] net/lwip: implement dns cmd
Quoted 102 lines · Ilias Apalodimas
Quoted 101 lines · Maxim Uvarov
U-Boot recently got support for an alternative network stack using LWIP. Replace dns command with the LWIP variant while keeping the output and error messages identical.
Signed-off-by Maxim Uvarov <[email protected]>--- include/net/lwip.h | 19 +++++++++++ net/lwip/Makefile | 2 ++ net/lwip/apps/dns/lwip-dns.c | 63 ++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+)create mode 100644
include/net/lwip.h
create mode 100644net/lwip/apps/dns/lwip-dns.cinclude/net/lwip.h new file +19
-0@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +int do_lwip_dns (struct cmd_tbl *cmdtp,int flag,int argc, +char *const argv[]); + +/** +* ulwip_dns() - creates the DNS request to resolve a domain host name +* +* This function creates the DNS request to resolve a domain host name. Function +* can return immediately if previous request was cached or it might require +* entering the polling loop for a request to a remote server. +* +* @name: dns name to resolve +* @varname: (optional) U-Boot variable name to store the result +* Returns: ERR_OK(0) for fetching entry from the cache +* -EINPROGRESS success, can go to the polling loop +* Other value < 0, if error +*/ +int ulwip_dns (char *name,char *varname);net/lwip/Makefile +2
-0@@ -62,3 +62,5 @@ obj-$(CONFIG_NET) += lwip-external/src/netif/ethernet.o obj-$(CONFIG_NET) += port/if.o obj-$(CONFIG_NET) += port/sys-arch.o + +obj-y += apps/dns/lwip-dns.onet/lwip/apps/dns/lwip-dns.c new file +47
-0@@ -0,0 +1,63 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* +* (C) Copyright 2023 Linaro Ltd. <[email protected]> +*/ + +#include <common.h> +#include <command.h> +#include <console.h> + +#include <lwip/dns.h> +#include <lwip/ip_addr.h> + +#include <net/ulwip.h> + +static void dns_found_cb (const char *name,const ip_addr_t *ipaddr,void *callback_arg) +{ +char *varname = (char *)callback_arg; +char *ipstr =ip4addr_ntoa (ipaddr); + +if (varname) +env_set (varname, ipstr); +log_info ("resolved %s to %s\n" , name, ipstr); +ulwip_exit (0 ); +} + +int ulwip_dns (char *name,char *varname) +{ +int err; +ip_addr_t ipaddr;/* not used */ +ip_addr_t dns1; +ip_addr_t dns2; +char *dnsenv =env_get ("dnsip" ); +char *dns2env =env_get ("dnsip2" ); + +if (!dnsenv && !dns2env) { +log_err ("nameserver is not set with dnsip and dnsip2 vars\n" ); +return -ENOENT ; + } + +if (!dnsenv) +log_warning ("dnsip var is not set\n" ); +if (!dns2env) +log_warning ("dnsip2 var is not set\n" ); + +dns_init (); +
Quoted 8 lines
net/lwip/apps/dns/lwip-dns.c line 52
Quoted 5 lines
net/lwip/apps/dns/lwip-dns.c new file +5
-0+if (ipaddr_aton (dnsenv, &dns1)) +dns_setserver (0 , &dns1); + +if (ipaddr_aton (dns2env, &dns2)) +dns_setserver (1 , &dns2);
env_getwill return NULL if any of these is not set. Looking atipaddr_aton()of lwip that might lead to a NULL deref inip_2_ip6()
Looking at the NULL checks in ipaddr_aton(), you found a bug in lwIP. I'd vote to leave the above code as is and rely on the bug being fixed in lwIP before U-Boot enables IPv6 (this is only a bug in dual-stack mode where IPv4 and IPv6 is enabled).
Regards,
Simon
Quoted 15 lines
Quoted 15 lines
net/lwip/apps/dns/lwip-dns.c new file +11
-1+ + err =dns_gethostbyname (name, &ipaddr, dns_found_cb, varname); +if (err ==ERR_OK ) +dns_found_cb (name, &ipaddr, varname); + +/* convert lwIP ERR_INPROGRESS to U-Boot -EINPROGRESS */ +if (err ==ERR_INPROGRESS ) + err = -EINPROGRESS ; + +return err; +} --2.30.2
Re: [PATCHv8 03/15] net/lwip: implement dns cmd
Quoted 119 lines · Simon Goldschmidt
Quoted 14 lines · Ilias Apalodimas
Quoted 13 lines · Maxim Uvarov
U-Boot recently got support for an alternative network stack using LWIP. Replace dns command with the LWIP variant while keeping the output and error messages identical.
Signed-off-by Maxim Uvarov <[email protected]>--- include/net/lwip.h | 19 +++++++++++ net/lwip/Makefile | 2 ++ net/lwip/apps/dns/lwip-dns.c | 63 ++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+)create mode 100644
include/net/lwip.h
create mode 100644net/lwip/apps/dns/lwip-dns.cQuoted 15 lines
Quoted 6 lines
include/net/lwip.h new file +0
-0include/net/lwip.h line 9
Quoted 9 lines
include/net/lwip.h new file +9
-0@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +int do_lwip_dns (struct cmd_tbl *cmdtp,int flag,int argc, +char *const argv[]); + +/** +* ulwip_dns() - creates the DNS request to resolve a domain host name +* +* This function creates the DNS request to resolve a domain host name. Function
Quoted 1 line
include/net/lwip.h line 10
Quoted 1 line
include/net/lwip.h new file +1
-0+* can return immediately if previous request was cached or it might require
Quoted 6 lines
Quoted 6 lines
include/net/lwip.h new file +6
-0+* entering the polling loop for a request to a remote server. +* +* @name: dns name to resolve +* @varname: (optional) U-Boot variable name to store the result +* Returns: ERR_OK(0) for fetching entry from the cache +* -EINPROGRESS success, can go to the polling loop Quoted 8 lines
net/lwip/Makefile obj-$(CONFIG_NET) +=
Quoted 8 lines
include/net/lwip.h new file +3
-0+* Other value < 0, if error +*/ +int ulwip_dns (char *name,char *varname);net/lwip/Makefile +0
-0@@ -62,3 +62,5 @@ obj-$(CONFIG_NET) +=
lwip-external/src/netif/ethernet.oQuoted 19 lines
Quoted 19 lines
net/lwip/Makefile +2
-0obj-$(CONFIG_NET) += port/if.o obj-$(CONFIG_NET) += port/sys-arch.o + +obj-y += apps/dns/lwip-dns.onet/lwip/apps/dns/lwip-dns.c new file +8
-0@@ -0,0 +1,63 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* +* (C) Copyright 2023 Linaro Ltd. <[email protected]> +*/ + +#include <common.h> +#include <command.h> Quoted 8 lines
net/lwip/apps/dns/lwip-dns.c
Quoted 8 lines
net/lwip/apps/dns/lwip-dns.c new file +8
-0+#include <console.h> + +#include <lwip/dns.h> +#include <lwip/ip_addr.h> + +#include <net/ulwip.h> + +static void dns_found_cb(const char *name, const ip_addr_t *ipaddr,void
*callback_arg)Quoted 13 lines
Quoted 13 lines
net/lwip/apps/dns/lwip-dns.c new file +13
-0+{ +char *varname = (char *)callback_arg; +char *ipstr =ip4addr_ntoa (ipaddr); + +if (varname) +env_set (varname, ipstr); +log_info ("resolved %s to %s\n" , name, ipstr); +ulwip_exit (0 ); +} + +int ulwip_dns (char *name,char *varname) +{ +int err;Quoted 8 lines
net/lwip/apps/dns/lwip-dns.c
Quoted 8 lines
net/lwip/apps/dns/lwip-dns.c new file +8
-0+ip_addr_t ipaddr;/* not used */ +ip_addr_t dns1; +ip_addr_t dns2; +char *dnsenv =env_get ("dnsip" ); +char *dns2env =env_get ("dnsip2" ); + +if (!dnsenv && !dns2env) { + log_err("nameserver is not set with dnsip and dnsip2vars\n");
Quoted 10 lines
Quoted 10 lines
net/lwip/apps/dns/lwip-dns.c new file +10
-0+return -ENOENT ; + } + +if (!dnsenv) +log_warning ("dnsip var is not set\n" ); +if (!dns2env) +log_warning ("dnsip2 var is not set\n" ); + +dns_init (); +Quoted 8 lines
net/lwip/apps/dns/lwip-dns.c line 52
Quoted 5 lines
net/lwip/apps/dns/lwip-dns.c new file +5
-0+if (ipaddr_aton (dnsenv, &dns1)) +dns_setserver (0 , &dns1); + +if (ipaddr_aton (dns2env, &dns2)) +dns_setserver (1 , &dns2);
env_getwill return NULL if any of these is not set. Looking atipaddr_aton()of lwip that might lead to a NULL deref inip_2_ip6()
Quoted 9 lines
Looking at the NULL checks in
ipaddr_aton(), you found a bug in lwIP. I'd vote to leave the above code as is and rely on the bug being fixed in lwIP before U-Boot enables IPv6 (this is only a bug in dual-stack mode where IPv4 and IPv6 is enabled).Regards,
Simon
Yes, I looked for an ipv4 case with null check. But I think here we can go with:
if (dns2env && ipaddr_aton(dns2env, &dns2))
Quoted 16 lines
Quoted 15 lines
Quoted 15 lines
net/lwip/apps/dns/lwip-dns.c new file +11
-1+ + err =dns_gethostbyname (name, &ipaddr, dns_found_cb, varname); +if (err ==ERR_OK ) +dns_found_cb (name, &ipaddr, varname); + +/* convert lwIP ERR_INPROGRESS to U-Boot -EINPROGRESS */ +if (err ==ERR_INPROGRESS ) + err = -EINPROGRESS ; + +return err; +} --2.30.2
PATCH v8 4/15 net/lwip: implement dhcp cmd
In reply to Maxim UvarovU-Boot recently got support for an alternative network stack using LWIP. Replace dhcp command with the LWIP variant while keeping the output and error messages identical.
--- include/net/lwip.h | 12 +++++++ net/lwip/Makefile | 1 + net/lwip/apps/dhcp/lwip-dhcp.c | 61 ++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 net/lwip/apps/dhcp/lwip-dhcp.c
include/net/lwip.h +12 -0
@@ -17,3 +17,15 @@ int do_lwip_dns(struct cmd_tbl *cmdtp, int flag, int argc,* Other value < 0, if error */ int ulwip_dns (char *name,char *varname); + +/** +* ulwip_dhcp() - create the DHCP request to obtain IP address. +* +* This function creates the DHCP request to obtain IP address. If DHCP server +* returns file name, this file will be downloaded with tftp. After this +* function you need to invoke the polling loop to process network communication. +* +* Returns: 0 if success +* Other value < 0, if error +*/ +int ulwip_dhcp (void );
net/lwip/Makefile +1 -0
@@ -63,4 +63,5 @@ obj-$(CONFIG_NET) += lwip-external/src/netif/ethernet.o obj-$(CONFIG_NET) += port/if.o obj-$(CONFIG_NET) += port/sys-arch.o +obj-y += apps/dhcp/lwip-dhcp.o obj-y += apps/dns/lwip-dns.o
net/lwip/apps/dhcp/lwip-dhcp.c new file +61 -0
61 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [PATCHv8 04/15] net/lwip: implement dhcp cmd
net/lwip/apps/dhcp/lwip-dhcp.c line 18
Quoted 13 lines · Maxim Uvarov
net/lwip/apps/dhcp/lwip-dhcp.c new file +13
-0+ +#include <common.h> +#include <command.h> +#include <console.h> + +#include <lwip/dhcp.h> +#include <lwip/prot/dhcp.h> +#include "lwip/timeouts.h" + +#include <net/eth.h> +#include <net/ulwip.h> + +#define DHCP_WAIT_MS 2000
Is this the time we wait for a dhcp reply? If so we should bump it to something higher
Quoted 26 lines
net/lwip/apps/dhcp/lwip-dhcp.c new file +26
-0+ +static void dhcp_tmo (void *arg) +{ +struct netif *netif = (struct netif *)arg; +struct dhcp *dhcp; +int err =0 ; + + dhcp =netif_get_client_data (netif,LWIP_NETIF_CLIENT_DATA_INDEX_DHCP ); +if (!dhcp) +return ; + +switch (dhcp->state) { +case DHCP_STATE_BOUND : + err +=env_set ("bootfile" , dhcp->boot_file_name); + err +=env_set ("ipaddr" ,ip4addr_ntoa (&dhcp->offered_ip_addr)); + err +=env_set ("netmask" ,ip4addr_ntoa (&dhcp->offered_sn_mask)); + err +=env_set ("serverip" ,ip4addr_ntoa (&dhcp->server_ip_addr)); +if (err) +log_err ("error update envs\n" ); +log_info ("DHCP client bound to address %s\n" ,ip4addr_ntoa (&dhcp->offered_ip_addr)); +break ; +default : +return ; + } +} +
net/lwip/apps/dhcp/lwip-dhcp.c line 54
Quoted 10 lines
net/lwip/apps/dhcp/lwip-dhcp.c new file +10
-0+int ulwip_dhcp (void ) +{ +struct netif *netif; +int eth_idx; + + eth_idx =eth_get_dev_index (); +if (eth_idx <0 ) +return -EPERM ; + + netif =netif_get_by_index (eth_idx +1 );
Why is the +1 needed here?
Quoted 10 lines
net/lwip/apps/dhcp/lwip-dhcp.c new file +7
-1+if (!netif) +return -ENOENT ; + +sys_timeout (DHCP_WAIT_MS , dhcp_tmo, netif); + +return dhcp_start (netif) ?0 : -EPERM ; +} --2.30.2
Re: [PATCHv8 04/15] net/lwip: implement dhcp cmd
Quoted 48 lines · Ilias Apalodimas
net/lwip/apps/dhcp/lwip-dhcp.c line 18
Quoted 13 lines · Maxim Uvarov
net/lwip/apps/dhcp/lwip-dhcp.c new file +13
-0+ +#include <common.h> +#include <command.h> +#include <console.h> + +#include <lwip/dhcp.h> +#include <lwip/prot/dhcp.h> +#include "lwip/timeouts.h" + +#include <net/eth.h> +#include <net/ulwip.h> + +#define DHCP_WAIT_MS 2000Is this the time we wait for a dhcp reply? If so we should bump it to something higher
Quoted 30 lines
net/lwip/apps/dhcp/lwip-dhcp.c new file +30
-0+ +static void dhcp_tmo (void *arg) +{ +struct netif *netif = (struct netif *)arg; +struct dhcp *dhcp; +int err =0 ; + + dhcp =netif_get_client_data (netif,LWIP_NETIF_CLIENT_DATA_INDEX_DHCP ); +if (!dhcp) +return ; + +switch (dhcp->state) { +case DHCP_STATE_BOUND : + err +=env_set ("bootfile" , dhcp->boot_file_name); + err +=env_set ("ipaddr" ,ip4addr_ntoa (&dhcp->offered_ip_addr)); + err +=env_set ("netmask" ,ip4addr_ntoa (&dhcp->offered_sn_mask)); + err +=env_set ("serverip" ,ip4addr_ntoa (&dhcp->server_ip_addr)); +if (err) +log_err ("error update envs\n" ); +log_info ("DHCP client bound to address %s\n" ,ip4addr_ntoa (&dhcp->offered_ip_addr)); +break ; +default : +return ; + } +} + +int ulwip_dhcp (void ) +{ +struct netif *netif; +int eth_idx;
Quoted 8 lines
net/lwip/apps/dhcp/lwip-dhcp.c line 54
Quoted 6 lines
net/lwip/apps/dhcp/lwip-dhcp.c new file +6
-0+ + eth_idx =eth_get_dev_index (); +if (eth_idx <0 ) +return -EPERM ; + + netif =netif_get_by_index (eth_idx +1 );Why is the +1 needed here?
Netif index is driven by posix design and is 1-based in contrast to U-Boot's 0-based dev index. A comment noting that would probably help the ones not knowing lwIP.
Regards,
Simon
Quoted 11 lines
Quoted 11 lines
net/lwip/apps/dhcp/lwip-dhcp.c new file +7
-1+if (!netif) +return -ENOENT ; + +sys_timeout (DHCP_WAIT_MS , dhcp_tmo, netif); + +return dhcp_start (netif) ?0 : -EPERM ; +} --2.30.2
PATCH v8 5/15 net/lwip: implement tftp cmd
In reply to Maxim UvarovU-Boot recently got support for an alternative network stack using LWIP. Replace tftp command with the LWIP variant while keeping the output and error messages identical.
--- include/net/lwip.h | 14 +++- net/lwip/Makefile | 1 + net/lwip/apps/tftp/Makefile | 7 ++ net/lwip/apps/tftp/lwip-tftp.c | 129 +++++++++++++++++++++++++++++++++ 4 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 net/lwip/apps/tftp/Makefile create mode 100644 net/lwip/apps/tftp/lwip-tftp.c
include/net/lwip.h +13 -1
@@ -28,4 +28,16 @@ int ulwip_dns(char *name, char *varname);* Returns: 0 if success * Other value < 0, if error */ -int ulwip_dhcp (void ); + +/** +* ulwip_tftp() - load file with tftp +* +* Load file with tftp to specific address +* +* @addr: Address to store downloaded file +* @filename: File name on remote tftp server to download +* +* +* Returns: 0 if success, !0 if error +*/ +int ulwip_tftp (ulong addr,const char *filename);
net/lwip/Makefile +1 -0
@@ -65,3 +65,4 @@ obj-$(CONFIG_NET) += port/sys-arch.o obj-y += apps/dhcp/lwip-dhcp.o obj-y += apps/dns/lwip-dns.o +obj-y += apps/tftp/
net/lwip/apps/tftp/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +ccflags-y += -I$(srctree)/net/lwip/port/include +ccflags-y += -I$(srctree)/net/lwip/lwip-external/src/include -I$(srctree)/net/lwip +ccflags-y += -I$(srctree)/net/lwip/lwip-external/src/include/lwip/apps +ccflags-y += -I$(srctree)/net/lwip/lwip-external/contrib/examples/tftp/ + +obj-y += ../../lwip-external/src/apps/tftp/tftp.o +obj-y += lwip-tftp.o
net/lwip/apps/tftp/lwip-tftp.c new file +129 -0
129 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [PATCHv8 05/15] net/lwip: implement tftp cmd
Quoted 70 lines
net/lwip/apps/tftp/lwip-tftp.c new file +70
-0+ +/* +* (C) Copyright 2023 Linaro Ltd. <[email protected]> +*/ + +#include <common.h> +#include <command.h> +#include <console.h> +#include <bootstage.h> + +#include "tftp_client.h" +#include "tftp_server.h" +#include <tftp_example.h> + +#include <string.h> + +#include <net/ulwip.h> + +static ulong daddr; +static ulong size; + +static void *tftp_open (const char *fname,const char *mode,u8_t is_write) +{ +return NULL ; +} + +static void tftp_close (void *handle) +{ +log_info ("\ndone\n" ); +log_info ("Bytes transferred = %ld (0x%lx hex)\n" , size, size); + +bootstage_mark_name (BOOTSTAGE_KERNELREAD_STOP ,"tftp_done" ); +if (env_set_hex ("filesize" , size)) { +log_err ("filesize not updated\n" ); +ulwip_exit (-1 ); +return ; + } +ulwip_exit (0 ); +} + +static int tftp_read (void *handle,void *buf,int bytes) +{ +return 0 ; +} + +static int tftp_write (void *handle,struct pbuf *p) +{ +struct pbuf *q; + +for (q = p; q !=NULL ; q = q->next) { +memcpy ((void *)daddr, q->payload, q->len); + daddr += q->len; + size += q->len; +log_info ("#" ); + } + +return 0 ; +} + +static void tftp_error (void *handle,int err,const char *msg,int size) +{ +char message[100 ]; + +memset (message,0 ,sizeof (message)); +memcpy (message, msg,LWIP_MIN (sizeof (message) -1 , (size_t )size)); + +log_info ("TFTP error: %d (%s)" , err, message); +} + +static const struct tftp_context tftp = {
net/lwip/apps/tftp/lwip-tftp.c line 81
Quoted 10 lines
net/lwip/apps/tftp/lwip-tftp.c new file +10
-0+ tftp_open, + tftp_close, + tftp_read, + tftp_write, + tftp_error +}; + +int ulwip_tftp (ulong addr,char *fname) +{ +void *f = (void *)0x1 ;/* unused fake file handle*/
I haven't dug into lwip details yet, but I am not sure this is safe to use. Simon, since you maintain the lwip part can you elaborate a bit more?
Quoted 49 lines
net/lwip/apps/tftp/lwip-tftp.c new file +48
-1+err_t err; +ip_addr_t srv; +int ret; +char *server_ip; + +if (!fname || addr ==0 ) +return CMD_RET_FAILURE ; + + size =0 ; + daddr = addr; + server_ip =env_get ("serverip" ); +if (!server_ip) { +log_err ("error: serverip variable has to be set\n" ); +return CMD_RET_FAILURE ; + } + + ret =ipaddr_aton (server_ip, &srv); +if (!ret) { +log_err ("error: ipaddr_aton\n" ); +return CMD_RET_FAILURE ; + } + +log_info ("TFTP from server %s; our IP address is %s\n" , + server_ip,env_get ("ipaddr" )); +log_info ("Filename '%s'.\n" , fname); +log_info ("Load address: 0x%lx\n" , daddr); +log_info ("Loading:" ); + +bootstage_mark_name (BOOTSTAGE_KERNELREAD_START ,"tftp_start" ); + + err =tftp_init_client (&tftp); +if (!(err ==ERR_OK || err ==ERR_USE )) +log_err ("tftp_init_client err: %d\n" , err); + + err =tftp_get (f, &srv,TFTP_PORT , fname,TFTP_MODE_OCTET ); +/* might return different errors, like routing problems */ +if (err !=ERR_OK ) { +log_err ("tftp_get err=%d\n" , err); +return CMD_RET_FAILURE ; + } + +if (env_set_hex ("fileaddr" , addr)) { +log_err ("fileaddr not updated\n" ); +return CMD_RET_FAILURE ; + } + +return CMD_RET_SUCCESS ; +} --
Quoted 2 lines
2.30.2
Thanks
/Ilias
Re: [PATCHv8 05/15] net/lwip: implement tftp cmd
Quoted 75 lines · Ilias Apalodimas
Quoted 75 lines
net/lwip/apps/tftp/lwip-tftp.c new file +75
-0+ +/* +* (C) Copyright 2023 Linaro Ltd. <[email protected]> +*/ + +#include <common.h> +#include <command.h> +#include <console.h> +#include <bootstage.h> + +#include "tftp_client.h" +#include "tftp_server.h" +#include <tftp_example.h> + +#include <string.h> + +#include <net/ulwip.h> + +static ulong daddr; +static ulong size; + +static void *tftp_open (const char *fname,const char *mode,u8_t is_write) +{ +return NULL ; +} + +static void tftp_close (void *handle) +{ +log_info ("\ndone\n" ); +log_info ("Bytes transferred = %ld (0x%lx hex)\n" , size, size); + +bootstage_mark_name (BOOTSTAGE_KERNELREAD_STOP ,"tftp_done" ); +if (env_set_hex ("filesize" , size)) { +log_err ("filesize not updated\n" ); +ulwip_exit (-1 ); +return ; + } +ulwip_exit (0 ); +} + +static int tftp_read (void *handle,void *buf,int bytes) +{ +return 0 ; +} + +static int tftp_write (void *handle,struct pbuf *p) +{ +struct pbuf *q; + +for (q = p; q !=NULL ; q = q->next) { +memcpy ((void *)daddr, q->payload, q->len); + daddr += q->len; + size += q->len; +log_info ("#" ); + } + +return 0 ; +} + +static void tftp_error (void *handle,int err,const char *msg,int size) +{ +char message[100 ]; + +memset (message,0 ,sizeof (message)); +memcpy (message, msg,LWIP_MIN (sizeof (message) -1 , (size_t )size)); + +log_info ("TFTP error: %d (%s)" , err, message); +} + +static const struct tftp_context tftp = { + tftp_open, + tftp_close, + tftp_read, + tftp_write, + tftp_error
Quoted 8 lines
net/lwip/apps/tftp/lwip-tftp.c line 81
Quoted 5 lines
net/lwip/apps/tftp/lwip-tftp.c new file +5
-0+}; + +int ulwip_tftp (ulong addr,char *fname) +{ +void *f = (void *)0x1 ;/* unused fake file handle*/ I haven't dug into lwip details yet, but I am not sure this is safe to use. Simon, since you maintain the lwip part can you elaborate a bit more?
From the lwIP design, using an invalid pointer here is ok: that pointer is only used as a client handle which is never dereferenced internally. The only requirement is that it is not NULL, as that is the validity check for the tftp client to know the handle is valid (or e.g. open failed etc.).
So while we can leave 0x1 here, using a static uint8_t would probably be better, at the expense of using a byte for nothing.
Regards,
Simon
Quoted 55 lines
Quoted 50 lines
net/lwip/apps/tftp/lwip-tftp.c new file +48
-1+err_t err; +ip_addr_t srv; +int ret; +char *server_ip; + +if (!fname || addr ==0 ) +return CMD_RET_FAILURE ; + + size =0 ; + daddr = addr; + server_ip =env_get ("serverip" ); +if (!server_ip) { +log_err ("error: serverip variable has to be set\n" ); +return CMD_RET_FAILURE ; + } + + ret =ipaddr_aton (server_ip, &srv); +if (!ret) { +log_err ("error: ipaddr_aton\n" ); +return CMD_RET_FAILURE ; + } + +log_info ("TFTP from server %s; our IP address is %s\n" , + server_ip,env_get ("ipaddr" )); +log_info ("Filename '%s'.\n" , fname); +log_info ("Load address: 0x%lx\n" , daddr); +log_info ("Loading:" ); + +bootstage_mark_name (BOOTSTAGE_KERNELREAD_START ,"tftp_start" ); + + err =tftp_init_client (&tftp); +if (!(err ==ERR_OK || err ==ERR_USE )) +log_err ("tftp_init_client err: %d\n" , err); + + err =tftp_get (f, &srv,TFTP_PORT , fname,TFTP_MODE_OCTET ); +/* might return different errors, like routing problems */ +if (err !=ERR_OK ) { +log_err ("tftp_get err=%d\n" , err); +return CMD_RET_FAILURE ; + } + +if (env_set_hex ("fileaddr" , addr)) { +log_err ("fileaddr not updated\n" ); +return CMD_RET_FAILURE ; + } + +return CMD_RET_SUCCESS ; +} --Quoted 2 lines
2.30.2
Thanks
/Ilias
Re: [PATCHv8 05/15] net/lwip: implement tftp cmd
Quoted 96 lines · Simon Goldschmidt
Quoted 14 lines · Ilias Apalodimas
Quoted 14 lines
net/lwip/apps/tftp/lwip-tftp.c new file +14
-0+ +/* +* (C) Copyright 2023 Linaro Ltd. <[email protected]> +*/ + +#include <common.h> +#include <command.h> +#include <console.h> +#include <bootstage.h> + +#include "tftp_client.h" +#include "tftp_server.h" +#include <tftp_example.h> +Quoted 8 lines
net/lwip/apps/tftp/lwip-tftp.c
Quoted 8 lines
net/lwip/apps/tftp/lwip-tftp.c new file +8
-0+#include <string.h> + +#include <net/ulwip.h> + +static ulong daddr; +static ulong size; + +static void *tftp_open(const char *fname, const char *mode, u8_t
is_write)Quoted 30 lines
Quoted 30 lines
net/lwip/apps/tftp/lwip-tftp.c new file +30
-0+{ +return NULL ; +} + +static void tftp_close (void *handle) +{ +log_info ("\ndone\n" ); +log_info ("Bytes transferred = %ld (0x%lx hex)\n" , size, size); + +bootstage_mark_name (BOOTSTAGE_KERNELREAD_STOP ,"tftp_done" ); +if (env_set_hex ("filesize" , size)) { +log_err ("filesize not updated\n" ); +ulwip_exit (-1 ); +return ; + } +ulwip_exit (0 ); +} + +static int tftp_read (void *handle,void *buf,int bytes) +{ +return 0 ; +} + +static int tftp_write (void *handle,struct pbuf *p) +{ +struct pbuf *q; + +for (q = p; q !=NULL ; q = q->next) { +memcpy ((void *)daddr, q->payload, q->len); + daddr += q->len;Quoted 8 lines
net/lwip/apps/tftp/lwip-tftp.c
Quoted 8 lines
net/lwip/apps/tftp/lwip-tftp.c new file +8
-0+ size += q->len; +log_info ("#" ); + } + +return 0 ; +} + +static void tftp_error(void *handle, int err, const char *msg, intsize)
Quoted 14 lines
Quoted 14 lines
net/lwip/apps/tftp/lwip-tftp.c new file +14
-0+{ +char message[100 ]; + +memset (message,0 ,sizeof (message)); +memcpy (message, msg,LWIP_MIN (sizeof (message) -1 , (size_t )size)); + +log_info ("TFTP error: %d (%s)" , err, message); +} + +static const struct tftp_context tftp = { + tftp_open, + tftp_close, + tftp_read, + tftp_write,Quoted 8 lines
net/lwip/apps/tftp/lwip-tftp.c line 81
Quoted 6 lines
net/lwip/apps/tftp/lwip-tftp.c new file +6
-0+ tftp_error +}; + +int ulwip_tftp (ulong addr,char *fname) +{ +void *f = (void *)0x1 ;/* unused fake file handle*/ I haven't dug into lwip details yet, but I am not sure this is safe to
use.
Quoted 1 line
Simon, since you maintain the lwip part can you elaborate a bit more?
From the lwIP design, using an invalid pointer here is ok: that pointer
is only used as a client handle which is never dereferenced internally. The only requirement is that it is not NULL, as that is the validity check for the tftp client to know the handle is valid (or e.g. open failed etc.).
Quoted 6 lines
So while we can leave
0x1here, using a staticuint8_twould probably be better, at the expense of using a byte for nothing.Regards,
Simon
U-Boot does not like statics due to the fact that it can relocate itself to another address.
BR,
Maxim.
Quoted 57 lines
Quoted 56 lines
Quoted 51 lines
net/lwip/apps/tftp/lwip-tftp.c new file +48
-1+err_t err; +ip_addr_t srv; +int ret; +char *server_ip; + +if (!fname || addr ==0 ) +return CMD_RET_FAILURE ; + + size =0 ; + daddr = addr; + server_ip =env_get ("serverip" ); +if (!server_ip) { +log_err ("error: serverip variable has to be set\n" ); +return CMD_RET_FAILURE ; + } + + ret =ipaddr_aton (server_ip, &srv); +if (!ret) { +log_err ("error: ipaddr_aton\n" ); +return CMD_RET_FAILURE ; + } + +log_info ("TFTP from server %s; our IP address is %s\n" , + server_ip,env_get ("ipaddr" )); +log_info ("Filename '%s'.\n" , fname); +log_info ("Load address: 0x%lx\n" , daddr); +log_info ("Loading:" ); + +bootstage_mark_name (BOOTSTAGE_KERNELREAD_START ,"tftp_start" ); + + err =tftp_init_client (&tftp); +if (!(err ==ERR_OK || err ==ERR_USE )) +log_err ("tftp_init_client err: %d\n" , err); + + err =tftp_get (f, &srv,TFTP_PORT , fname,TFTP_MODE_OCTET ); +/* might return different errors, like routing problems */ +if (err !=ERR_OK ) { +log_err ("tftp_get err=%d\n" , err); +return CMD_RET_FAILURE ; + } + +if (env_set_hex ("fileaddr" , addr)) { +log_err ("fileaddr not updated\n" ); +return CMD_RET_FAILURE ; + } + +return CMD_RET_SUCCESS ; +} --Quoted 2 lines
2.30.2
Thanks
/Ilias
PATCH v8 6/15 net/lwip: implement wget cmd
In reply to Maxim UvarovU-Boot recently got support for an alternative network stack using LWIP. Replace wget command with the LWIP variant while keeping the output and error messages identical.
--- include/net/lwip.h | 15 +++++ net/lwip/Makefile | 1 + net/lwip/apps/http/Makefile | 6 ++ net/lwip/apps/http/lwip-wget.c | 106 +++++++++++++++++++++++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 net/lwip/apps/http/Makefile create mode 100644 net/lwip/apps/http/lwip-wget.c
include/net/lwip.h +15 -0
@@ -28,6 +28,7 @@ int ulwip_dns(char *name, char *varname);* Returns: 0 if success * Other value < 0, if error */ +int ulwip_dhcp (void );/** * ulwip_tftp() - load file with tftp
@@ -41,3 +42,17 @@ int ulwip_dns(char *name, char *varname);* Returns: 0 if success, !0 if error */ int ulwip_tftp (ulong addr,const char *filename); + +/** +* ulwip_wget() - creates the HTTP request to download file +* +* This function creates the HTTP request to download file from url to the address +* specified in parameters. After this function you need to invoke the polling +* loop to process network communication. +* +* +* @addr: start address to download result +* @url: url in format http://host/url +* Returns: 0 for success, !0 if error +*/ +int ulwip_wget (ulong addr,char *url);
net/lwip/Makefile +1 -0
@@ -66,3 +66,4 @@ obj-$(CONFIG_NET) += port/sys-arch.o obj-y += apps/dhcp/lwip-dhcp.o obj-y += apps/dns/lwip-dns.o obj-y += apps/tftp/ +obj-y += apps/http/
net/lwip/apps/http/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +ccflags-y += -I$(srctree)/net/lwip/port/include +ccflags-y += -I$(srctree)/net/lwip/lwip-external/src/include -I$(srctree)/net/lwip +ccflags-y += -I$(srctree)/net/lwip/lwip-external/src/include/lwip/apps + +obj-$(CONFIG_CMD_WGET) += ../../lwip-external/src/apps/http/http_client.o +obj-$(CONFIG_CMD_WGET) += lwip-wget.o
net/lwip/apps/http/lwip-wget.c new file +106 -0
106 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [PATCHv8 06/15] net/lwip: implement wget cmd
include/net/lwip.h int ulwip_dns(char *name, char *varname); · line 31
Quoted 13 lines
4 files changed, 128 insertions(+) create mode 100644 net/lwip/apps/http/Makefile create mode 100644 net/lwip/apps/http/lwip-wget.cinclude/net/lwip.h +1
-0@@ -28,6 +28,7 @@ int ulwip_dns(char *name, char *varname);* Returns: 0 if success * Other value < 0, if error */ +int ulwip_dhcp (void );
This seems unrelated to wget changes
[...]
Quoted 44 lines
include/net/lwip.h +44
-0+// SPDX-License-Identifier: GPL-2.0 + +/* +* (C) Copyright 2023 Linaro Ltd. <[email protected]> +*/ + +#include <common.h> +#include <command.h> +#include <console.h> +#include <vsprintf.h> + +#include "http_client.h" +#include <net/ulwip.h> + +static ulong daddr; +static httpc_connection_t settings; + +#define SERVER_NAME_SIZE 200 +#define HTTP_PORT_DEFAULT 80 + +static err_t httpc_recv (void *arg,struct altcp_pcb *pcb,struct pbuf *pbuf, +err_t unused_err) +{ +struct pbuf *buf; + +if (!pbuf) +return ERR_BUF ; + +for (buf = pbuf; buf !=NULL ; buf = buf->next) { +memcpy ((void *)daddr, buf->payload, buf->len); +log_debug ("downloaded chunk size %d, to addr 0x%lx\n" , + buf->len, daddr); + daddr += buf->len; + } + +altcp_recved (pcb, pbuf->tot_len); +pbuf_free (pbuf); +return ERR_OK ; +} + +static void httpc_result (void *arg,httpc_result_t httpc_result,u32_t rx_content_len, +u32_t srv_res,err_t err) +{ +if (httpc_result ==HTTPC_RESULT_OK ) {
include/net/lwip.h int ulwip_dns(char *name, char *varname);
Quoted 10 lines
include/net/lwip.h +10
-0+log_info ("\n%d bytes successfully downloaded.\n" , rx_content_len); +env_set_hex ("filesize" , rx_content_len); +ulwip_exit (0 ); + }else { +log_err ("\nhttp eroror: %d\n" , httpc_result); +ulwip_exit (-1 ); + } +} + +/* http://hostname:port/url */
The format doesn't expect a port (for now we can change that once we add https)
Quoted 4 lines
include/net/lwip.h +4
-0+static int parse_url (char *url,char *host,u16 *port) +{ +char *p, *pp; +
include/net/lwip.h
Quoted 10 lines
include/net/lwip.h +10
-0+ p =strstr (url,"http://" ); +if (!p) +return -1 ; + + p +=strlen ("http://" ); + +/* parse hostname */ + pp =strchr (p,'/' ); +if (!pp) { +return -2 ;
-1, -2 -3 etc should be mapped to proper ERRNOs
include/net/lwip.h
Quoted 3 lines
include/net/lwip.h +3
-0+ } + +if (pp - p >=SERVER_NAME_SIZE )
Can you change this to p + SERVER_NAME_SIZE >= pp ?
Quoted 36 lines
include/net/lwip.h +35
-1+return -3 ; + +memcpy (host, p, pp - p); + host[pp - p +1 ] ='\0' ; + *port =HTTP_PORT_DEFAULT ; + +return 0 ; +} + +int ulwip_wget (ulong addr,char *url) +{ +err_t err; +u16 port; +char server_name[SERVER_NAME_SIZE ]; +httpc_state_t *connection; + + daddr = addr; + + err =parse_url (url, server_name, &port); +if (err) +return -ENOENT ; + +log_info ("downloading %s to addr 0x%lx\n" , url, addr); +memset (&settings,0 ,sizeof (settings)); + settings.result_fn = httpc_result; + err =httpc_get_file_dns (server_name, port, url, &settings, + httpc_recv,NULL , &connection); +if (err !=ERR_OK ) +return -EPERM ; + +if (env_set_hex ("fileaddr" , addr)) +return -EACCES ; + +return 0 ; +} --
Quoted 2 lines
2.30.2
Thanks
/Ilias
PATCH v8 7/15 net/lwip: implement ping cmd
In reply to Maxim UvarovU-Boot recently got support for an alternative network stack using LWIP. Replace ping command with the LWIP variant while keeping the output and error messages identical. ping uses lwIP contrib/apps/ping/ping.c code. Custom timeout is used to get an error message on not modified example. lwIP timeouts are not yet implemented in U-Boot (#define LWIP_TIMERS 1) so that for now ping can not rechange itself for continuous pings and stops after the first request (the same behavior as the original ping.)
--- include/net/lwip.h | 15 +++++++++++++ net/lwip/Makefile | 1 + net/lwip/apps/ping/Makefile | 12 ++++++++++ net/lwip/apps/ping/lwip_ping.c | 40 ++++++++++++++++++++++++++++++++++ net/lwip/apps/ping/lwip_ping.h | 15 +++++++++++++ net/lwip/apps/ping/ping.h | 19 ++++++++++++++++ 6 files changed, 102 insertions(+) create mode 100644 net/lwip/apps/ping/Makefile create mode 100644 net/lwip/apps/ping/lwip_ping.c create mode 100644 net/lwip/apps/ping/lwip_ping.h create mode 100644 net/lwip/apps/ping/ping.h
include/net/lwip.h +15 -0
@@ -2,6 +2,8 @@int do_lwip_dns (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]); +int do_lwip_ping (struct cmd_tbl *cmdtp,int flag,int argc, +char *const argv[]);/** * ulwip_dns() - creates the DNS request to resolve a domain host name
@@ -56,3 +58,16 @@ int ulwip_tftp(ulong addr, const char *filename);* Returns: 0 for success, !0 if error */ int ulwip_wget (ulong addr,char *url); + +/** +* ulwip_ping - create the ping request +* +* This function creates the ping for address provided in parameters. +* After this function you need to invoke the polling +* loop to process network communication. +* +* +* @ping_addr: IP address to ping +* Returns: 0 for success, !0 if error +*/ +int ulwip_ping (char *ping_addr);
net/lwip/Makefile +1 -0
@@ -67,3 +67,4 @@ obj-y += apps/dhcp/lwip-dhcp.o obj-y += apps/dns/lwip-dns.o obj-y += apps/tftp/ obj-y += apps/http/ +obj-y += apps/ping/
net/lwip/apps/ping/Makefile new file +12 -0
@@ -0,0 +1,12 @@ +ccflags-y += -I$(srctree)/net/lwip/port/include +ccflags-y += -I$(srctree)/net/lwip/lwip-external/src/include -I$(srctree)/net/lwip +ccflags-y += -I$(obj) + +# ping.c includes "ping.h", copy it to local directory, to override ping.h +.PHONY: $(obj)/ping.c +$(obj)/ping.o: $(obj)/ping.c +$(obj)/ping.c: + cp $(srctree)/net/lwip/lwip-external/contrib/apps/ping/ping.c $(obj)/ping.c + +obj-y += ping.o +obj-y += lwip_ping.o
net/lwip/apps/ping/lwip_ping.c new file +40 -0
@@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* +* (C) Copyright 2023 Linaro Ltd. <[email protected]> +*/ + +#include "lwip/opt.h" +#include "lwip/ip_addr.h" +#include "lwip/timeouts.h" +#include <linux/errno.h> +#include "ping.h" +#include "lwip_ping.h" + +#define PING_WAIT_MS 1000 + +static ip_addr_t ip_target; + +static void ping_tmo (void *arg) +{ +char *ping_addr = (char *)arg; + +log_err ("ping failed; host %s is not alive\n" , ping_addr); +ulwip_exit (1 ); +} + +int ulwip_ping (char *ping_addr) +{ +int err; + + err =ipaddr_aton (ping_addr, &ip_target); +if (!err) +return -ENOENT ; + +sys_timeout (PING_WAIT_MS , ping_tmo, ping_addr); + +ping_init (&ip_target); +ping_send_now (); + +return 0 ; +}
net/lwip/apps/ping/lwip_ping.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +/* +* (C) Copyright 2023 Linaro Ltd. <[email protected]> +*/ + +#ifndef LWIP_PING_H +#define LWIP_PING_H + +#include <lwip/ip_addr.h> + +void ping_raw_init (void ); +void ping_send_now (void ); + +#endif /* LWIP_PING_H */
net/lwip/apps/ping/ping.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#include <net/ulwip.h> +#include "lwip/ip_addr.h" + +#define LWIP_DEBUG 1/* ping_time is under ifdef*/ +#define PING_RESULT (cond) { \ + if (cond == 1) { \ + printf("host %s a alive\n", ipaddr_ntoa(addr)); \ + printf(" %"U32_F" ms\n", (sys_now() - ping_time)); \ + ulwip_exit(0); \ + } else { \ + printf("ping failed; host %s in not alive\n",\ + ipaddr_ntoa(addr)); \ + ulwip_exit(-1); \ + } \ + } while (0); + +void ping_init (const ip_addr_t *ping_addr);
Signature · 1 line
2.30.2
Re: [PATCHv8 07/15] net/lwip: implement ping cmd
Quoted 97 lines · Maxim Uvarov
U-Boot recently got support for an alternative network stack using LWIP. Replace ping command with the LWIP variant while keeping the output and error messages identical. ping uses lwIP
contrib/apps/ping/ping.ccode. Custom timeout is used to get an error message on not modified example. lwIP timeouts are not yet implemented in U-Boot (#defineLWIP_TIMERS1) so that for now ping can not rechange itself for continuous pings and stops after the first request (the same behavior as the original ping.)Signed-off-by Maxim Uvarov <[email protected]>--- include/net/lwip.h | 15 +++++++++++++ net/lwip/Makefile | 1 + net/lwip/apps/ping/Makefile | 12 ++++++++++ net/lwip/apps/ping/lwip_ping.c | 40 ++++++++++++++++++++++++++++++++++ net/lwip/apps/ping/lwip_ping.h | 15 +++++++++++++ net/lwip/apps/ping/ping.h | 19 ++++++++++++++++ 6 files changed, 102 insertions(+) create mode 100644 net/lwip/apps/ping/Makefile create mode 100644 net/lwip/apps/ping/lwip_ping.c create mode 100644 net/lwip/apps/ping/lwip_ping.h create mode 100644 net/lwip/apps/ping/ping.hinclude/net/lwip.h +15
-0@@ -2,6 +2,8 @@int do_lwip_dns (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]); +int do_lwip_ping (struct cmd_tbl *cmdtp,int flag,int argc, +char *const argv[]);/** * ulwip_dns() - creates the DNS request to resolve a domain host name @@ -56,3 +58,16 @@ int ulwip_tftp(ulong addr, const char *filename);* Returns: 0 for success, !0 if error */ int ulwip_wget (ulong addr,char *url); + +/** +* ulwip_ping - create the ping request +* +* This function creates the ping for address provided in parameters. +* After this function you need to invoke the polling +* loop to process network communication. +* +* +* @ping_addr: IP address to ping +* Returns: 0 for success, !0 if error +*/ +int ulwip_ping (char *ping_addr);net/lwip/Makefile +1
-0@@ -67,3 +67,4 @@ obj-y += apps/dhcp/lwip-dhcp.o obj-y += apps/dns/lwip-dns.o obj-y += apps/tftp/ obj-y += apps/http/ +obj-y += apps/ping/net/lwip/apps/ping/Makefile new file +12
-0@@ -0,0 +1,12 @@ +ccflags-y += -I$(srctree)/net/lwip/port/include +ccflags-y += -I$(srctree)/net/lwip/lwip-external/src/include -I$(srctree)/net/lwip +ccflags-y += -I$(obj) + +# ping.c includes "ping.h", copy it to local directory, to override ping.h +.PHONY: $(obj)/ping.c +$(obj)/ping.o: $(obj)/ping.c +$(obj)/ping.c: + cp $(srctree)/net/lwip/lwip-external/contrib/apps/ping/ping.c $(obj)/ping.c + +obj-y += ping.o +obj-y += lwip_ping.onet/lwip/apps/ping/lwip_ping.c new file +12
-0@@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* +* (C) Copyright 2023 Linaro Ltd. <[email protected]> +*/ + +#include "lwip/opt.h" +#include "lwip/ip_addr.h" +#include "lwip/timeouts.h" +#include <linux/errno.h> +#include "ping.h" +#include "lwip_ping.h"
net/lwip/apps/ping/lwip_ping.c line 22
Quoted 10 lines
net/lwip/apps/ping/lwip_ping.c new file +10
-0+ +#define PING_WAIT_MS 1000 + +static ip_addr_t ip_target; + +static void ping_tmo (void *arg) +{ +char *ping_addr = (char *)arg; + +log_err ("ping failed; host %s is not alive\n" , ping_addr);
just cast (char *)arg directly on log_err
Quoted 3 lines
net/lwip/apps/ping/lwip_ping.c new file +3
-0+ulwip_exit (1 ); +} +
[...]
Quoted 49 lines
net/lwip/apps/ping/lwip_ping.c new file +2
-0+return 0 ; +}net/lwip/apps/ping/lwip_ping.h new file +15
-0@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +/* +* (C) Copyright 2023 Linaro Ltd. <[email protected]> +*/ + +#ifndef LWIP_PING_H +#define LWIP_PING_H + +#include <lwip/ip_addr.h> + +void ping_raw_init (void ); +void ping_send_now (void ); + +#endif /* LWIP_PING_H */ net/lwip/apps/ping/ping.h new file +19
-1@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#include <net/ulwip.h> +#include "lwip/ip_addr.h" + +#define LWIP_DEBUG 1/* ping_time is under ifdef*/ +#define PING_RESULT (cond) { \ + if (cond == 1) { \ + printf("host %s a alive\n", ipaddr_ntoa(addr)); \ + printf(" %"U32_F" ms\n", (sys_now() - ping_time)); \ + ulwip_exit(0); \ + } else { \ + printf("ping failed; host %s in not alive\n",\ + ipaddr_ntoa(addr)); \ + ulwip_exit(-1); \ + } \ + } while (0); + +void ping_init (const ip_addr_t *ping_addr); --
Quoted 2 lines
2.30.2
Thanks
/Ilias
PATCH v8 8/15 net/lwip: add lwIP configuration
In reply to Maxim Uvarovlwip configuration can be tuned with header file.
--- net/lwip/lwipopts.h | 178 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 net/lwip/lwipopts.h
net/lwip/lwipopts.h new file +178 -0
@@ -0,0 +1,178 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +/* +* (C) Copyright 2023 Linaro Ltd. <[email protected]> +*/ + +#ifndef LWIP_LWIPOPTS_H +#define LWIP_LWIPOPTS_H + +#include "lwipopts.h" + +#if defined(CONFIG_LWIP_LIB_DEBUG ) +#define LWIP_DEBUG 1 +#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL +#define LWIP_DBG_TYPES_ON LWIP_DBG_ON +#define ETHARP_DEBUG LWIP_DBG_ON +#define NETIF_DEBUG LWIP_DBG_ON +#define PBUF_DEBUG LWIP_DBG_OFF +#define API_LIB_DEBUG LWIP_DBG_ON +#define API_MSG_DEBUG LWIP_DBG_OFF +#define SOCKETS_DEBUG LWIP_DBG_OFF +#define ICMP_DEBUG LWIP_DBG_OFF +#define IGMP_DEBUG LWIP_DBG_OFF +#define INET_DEBUG LWIP_DBG_OFF +#define IP_DEBUG LWIP_DBG_ON +#define IP_REASS_DEBUG LWIP_DBG_OFF +#define RAW_DEBUG LWIP_DBG_OFF +#define MEM_DEBUG LWIP_DBG_OFF +#define MEMP_DEBUG LWIP_DBG_OFF +#define SYS_DEBUG LWIP_DBG_OFF +#define TIMERS_DEBUG LWIP_DBG_ON +#define TCP_DEBUG LWIP_DBG_OFF +#define TCP_INPUT_DEBUG LWIP_DBG_OFF +#define TCP_FR_DEBUG LWIP_DBG_OFF +#define TCP_RTO_DEBUG LWIP_DBG_OFF +#define TCP_CWND_DEBUG LWIP_DBG_OFF +#define TCP_WND_DEBUG LWIP_DBG_OFF +#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF +#define TCP_RST_DEBUG LWIP_DBG_OFF +#define TCP_QLEN_DEBUG LWIP_DBG_OFF +#define UDP_DEBUG LWIP_DBG_OFF +#define TCPIP_DEBUG LWIP_DBG_OFF +#define SLIP_DEBUG LWIP_DBG_OFF +#define DHCP_DEBUG LWIP_DBG_ON +#define AUTOIP_DEBUG LWIP_DBG_ON +#define DNS_DEBUG LWIP_DBG_ON +#define IP6_DEBUG LWIP_DBG_OFF +#define DHCP6_DEBUG LWIP_DBG_OFF +#else +#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL +#define LWIP_DBG_TYPES_ON LWIP_DBG_OFF +#define ETHARP_DEBUG LWIP_DBG_OFF +#define NETIF_DEBUG LWIP_DBG_OFF +#define PBUF_DEBUG LWIP_DBG_OFF +#define API_LIB_DEBUG LWIP_DBG_OFF +#define API_MSG_DEBUG LWIP_DBG_OFF +#define SOCKETS_DEBUG LWIP_DBG_OFF +#define ICMP_DEBUG LWIP_DBG_OFF +#define IGMP_DEBUG LWIP_DBG_OFF +#define INET_DEBUG LWIP_DBG_OFF +#define IP_DEBUG LWIP_DBG_OFF +#define IP_REASS_DEBUG LWIP_DBG_OFF +#define RAW_DEBUG LWIP_DBG_OFF +#define MEM_DEBUG LWIP_DBG_OFF +#define MEMP_DEBUG LWIP_DBG_OFF +#define SYS_DEBUG LWIP_DBG_OFF +#define TIMERS_DEBUG LWIP_DBG_OFF +#define TCP_DEBUG LWIP_DBG_OFF +#define TCP_INPUT_DEBUG LWIP_DBG_OFF +#define TCP_FR_DEBUG LWIP_DBG_OFF +#define TCP_RTO_DEBUG LWIP_DBG_OFF +#define TCP_CWND_DEBUG LWIP_DBG_OFF +#define TCP_WND_DEBUG LWIP_DBG_OFF +#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF +#define TCP_RST_DEBUG LWIP_DBG_OFF +#define TCP_QLEN_DEBUG LWIP_DBG_OFF +#define UDP_DEBUG LWIP_DBG_OFF +#define TCPIP_DEBUG LWIP_DBG_OFF +#define SLIP_DEBUG LWIP_DBG_OFF +#define DHCP_DEBUG LWIP_DBG_OFF +#define AUTOIP_DEBUG LWIP_DBG_OFF +#define DNS_DEBUG LWIP_DBG_OFF +#define IP6_DEBUG LWIP_DBG_OFF +#define DHCP6_DEBUG LWIP_DBG_OFF +#endif +#define LWIP_TESTMODE 0 + +#if defined(CONFIG_LWIP_LIB_NOASSERT ) +#define LWIP_NOASSERT 1 +#define LWIP_ASSERT (message, assertion) +#endif + +#include "lwip/debug.h" + +#define SYS_LIGHTWEIGHT_PROT 0 +#define NO_SYS 1 + +#define LWIP_IPV6 0 + +#define MEM_ALIGNMENT 1 +#define MEM_SIZE 1600 + +#define MEMP_NUM_PBUF 4 +#define MEMP_NUM_RAW_PCB 2 +#define MEMP_NUM_UDP_PCB 4 +#define MEMP_NUM_TCP_PCB 2 +#define MEMP_NUM_TCP_PCB_LISTEN 2 +#define MEMP_NUM_TCP_SEG 16 +#define MEMP_NUM_REASSDATA 1 +#define MEMP_NUM_ARP_QUEUE 2 +#define MEMP_NUM_SYS_TIMEOUT 4 +#define MEMP_NUM_NETBUF 2 +#define MEMP_NUM_NETCONN 32 +#define MEMP_NUM_TCPIP_MSG_API 8 +#define MEMP_NUM_TCPIP_MSG_INPKT 8 +#define PBUF_POOL_SIZE 8 + +#define LWIP_ARP 1 +#define ARP_TABLE_SIZE 10 +#define ARP_QUEUEING 1 + +#define IP_FORWARD 0 +#define IP_OPTIONS_ALLOWED 1 +#define IP_REASSEMBLY 1 +#define IP_FRAG 1 +#define IP_REASS_MAXAGE 3 +#define IP_REASS_MAX_PBUFS 4 +#define IP_FRAG_USES_STATIC_BUF 0 + +#define IP_DEFAULT_TTL 255 + +#define LWIP_ICMP 1 + +#define LWIP_RAW 1 + +#define LWIP_DHCP 1 +#define LWIP_DHCP_BOOTP_FILE 1 +#define LWIP_DHCP_DOES_ACD_CHECK 0 + +#define LWIP_AUTOIP 0 + +#define LWIP_SNMP 0 + +#define LWIP_IGMP 0 + +#define LWIP_DNS 1 + +#define LWIP_UDP 1 + +#define LWIP_TCP 1 + +#define LWIP_LISTEN_BACKLOG 0 + +#define PBUF_LINK_HLEN 14 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS + 40 + PBUF_LINK_HLEN) + +#define LWIP_HAVE_LOOPIF 0 + +#define LWIP_NETCONN 0 +#define LWIP_DISABLE_MEMP_SANITY_CHECKS 1 + +#define LWIP_SOCKET 0 +#define SO_REUSE 0 + +#define LWIP_STATS 0 + +#define PPP_SUPPORT 0 + +#define LWIP_TCPIP_CORE_LOCKING 0 + +#define LWIP_NETIF_LOOPBACK 1 + +/* use malloc instead of pool */ +#define MEMP_MEM_MALLOC 1 +#define MEMP_MEM_INIT 1 +#define MEM_LIBC_MALLOC 1 + +#endif /* LWIP_LWIPOPTS_H */
Signature · 1 line
2.30.2
PATCH v8 9/15 net/lwip: implement lwIP port to U-Boot
In reply to Maxim UvarovImplement port of lwIP stack to the U-Boot. lwIP is well known full IP stack which provides wide functionality, various examples, API closer to linux userland. Rich debug printing and possibility to run lwIP apps under linux make it easier to develop and debug apps.
U-Boot implementation keeps the original file structure widely used for lwIP ports. (i.e. port/if.c port/sys-arch.c). That should allow us to easy port apps to or from U-Boot. Multiply ethernet devices are supported and "ethact" env variable chooses the active device.
Having a rich IP stack inside U-Boot will allow us to have such applications as http or https clients.
--- net/eth-uclass.c | 8 + net/lwip/port/if.c | 332 ++++++++++++++++++++++++++ net/lwip/port/include/arch/cc.h | 38 +++ net/lwip/port/include/arch/sys_arch.h | 10 + net/lwip/port/include/limits.h | 0 net/lwip/port/sys-arch.c | 13 + 6 files changed, 401 insertions(+) create mode 100644 net/lwip/port/if.c create mode 100644 net/lwip/port/include/arch/cc.h create mode 100644 net/lwip/port/include/arch/sys_arch.h create mode 100644 net/lwip/port/include/limits.h create mode 100644 net/lwip/port/sys-arch.c
net/eth-uclass.c +8 -0
@@ -32,6 +32,7 @@ DECLARE_GLOBAL_DATA_PTR;struct eth_device_priv {enum eth_state_t state;bool running; +ulwip ulwip; };/**
@@ -347,6 +348,13 @@ int eth_init(void)return ret; } +struct ulwip *eth_lwip_priv (struct udevice *current) +{ +struct eth_device_priv *priv =dev_get_uclass_priv (current); + +return &priv->ulwip; +} +void eth_halt (void ) {struct udevice *current;
net/lwip/port/if.c new file +332 -0
332 lines not on this page · raw message
net/lwip/port/include/arch/cc.h new file +38 -0
@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* +* (C) Copyright 2023 Linaro Ltd. <[email protected]> +*/ + +#ifndef LWIP_ARCH_CC_H +#define LWIP_ARCH_CC_H + +#include <linux/types.h> +#include <linux/kernel.h> +#include <vsprintf.h> +#include <rand.h> + +#define LWIP_ERRNO_INCLUDE <errno.h> + +#define LWIP_ERRNO_STDINCLUDE 1 +#define LWIP_NO_UNISTD_H 1 +#define LWIP_TIMEVAL_PRIVATE 1 + +#define LWIP_RAND () ((u32_t)rand()) + +/* different handling for unit test, normally not needed */ +#ifdef LWIP_NOASSERT_ON_ERROR +#define LWIP_ERROR (message, expression, handler) do { if (!(expression)) { \ + handler; }} while (0) +#endif + +#define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS + +#define LWIP_PLATFORM_ASSERT (x) do {printf("Assertion \"%s\" failed at line %d in %s\n", \ + x, __LINE__, __FILE__); } while (0) + +#define atoi (str) (int)dectoul(str, NULL) + +#define LWIP_ERR_T int + +#endif /* LWIP_ARCH_CC_H */
net/lwip/port/include/arch/sys_arch.h new file +10 -0
@@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* +* (C) Copyright 2023 Linaro Ltd. <[email protected]> +*/ + +#ifndef LWIP_ARCH_SYS_ARCH_H +#define LWIP_ARCH_SYS_ARCH_H + +#endif /* LWIP_ARCH_SYS_ARCH_H */
net/lwip/port/include/limits.h new file +0 -0
net/lwip/port/sys-arch.c new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* +* (C) Copyright 2023 Linaro Ltd. <[email protected]> +*/ + +#include <common.h> +#include "lwip/opt.h" + +u32_t sys_now (void ) +{ +return get_timer (0 ); +}
Signature · 1 line
2.30.2
PATCH v8 10/15 net/lwip: update .gitignore with lwIP
In reply to Maxim Uvarovignore lwIP library code and reused files from the lwIP.
--- net/lwip/.gitignore | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 net/lwip/.gitignore
net/lwip/.gitignore new file +8 -0
@@ -0,0 +1,8 @@ +lwip-external +apps/ping/ping.c +apps/http/http_client.c +apps/http/http_client.h +apps/tftp/tftp.c +apps/tftp/tftp_client.h +apps/tftp/tftp_common.h +apps/tftp/tftp_example.h
Signature · 1 line
2.30.2
PATCH v8 11/15 net/lwip: connection between cmd and lwip apps
In reply to Maxim Uvarov--- cmd/Makefile | 1 + cmd/net-lwip.c | 286 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 287 insertions(+) create mode 100644 cmd/net-lwip.c
cmd/Makefile +1 -0
@@ -128,6 +128,7 @@ endif obj-$(CONFIG_CMD_MUX) += mux.o obj-$(CONFIG_CMD_NAND) += nand.o obj-$(CONFIG_CMD_NET) += net.o +obj-$(CONFIG_CMD_NET) += net-lwip.o obj-$(CONFIG_CMD_NVEDIT_EFI) += nvedit_efi.o obj-$(CONFIG_CMD_ONENAND) += onenand.o obj-$(CONFIG_CMD_OSD) += osd.o
cmd/net-lwip.c new file +286 -0
286 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v8 12/15 net/lwip: replace original net commands with lwip
In reply to Maxim UvarovReplace original commands: ping, tftp, dhcp and wget.
--- boot/bootmeth_efi.c | 18 +++++++--- boot/bootmeth_pxe.c | 21 ++++++----- cmd/net.c | 86 +++++---------------------------------------- cmd/pxe.c | 19 +++++----- include/net.h | 8 +++-- include/net/ulwip.h | 64 +++++++++++++++++++++++++++++++++ 6 files changed, 113 insertions(+), 103 deletions(-) create mode 100644 include/net/ulwip.h
boot/bootmeth_efi.c +13 -5
@@ -20,6 +20,8 @@#include <mapmem.h> #include <mmc.h> #include <net.h> +#include <net/lwip.h> +#include <net/ulwip.h> #include <pxe_utils.h> #include <linux/sizes.h>
@@ -319,9 +321,7 @@ static int distro_efi_try_bootflow_files(struct udevice *dev,static int distro_efi_read_bootflow_net (struct bootflow *bflow) { -char file_addr[17 ], fname[256 ]; -char *tftp_argv[] = {"tftp" , file_addr, fname,NULL }; -struct cmd_tbl cmdtp = {};/* dummy */ +char fname[256 ];const char *addr_str, *fdt_addr_str;int ret, arch, size;ulong addr, fdt_addr;
@@ -368,7 +368,6 @@ static int distro_efi_read_bootflow_net(struct bootflow *bflow)if (!fdt_addr_str)return log_msg_ret ("fdt" , -EINVAL ); fdt_addr =hextoul (fdt_addr_str,NULL ); -sprintf (file_addr,"%lx" , fdt_addr);/* We only allow the first prefix with PXE */ ret =distro_efi_get_fdt_name (fname,sizeof (fname),0 );
@@ -379,7 +378,16 @@ static int distro_efi_read_bootflow_net(struct bootflow *bflow)if (!bflow->fdt_fname)return log_msg_ret ("fil" , -ENOMEM ); -if (!do_tftpb (&cmdtp,0 ,3 , tftp_argv)) { + ret =ulwip_init (); +if (ret) +return log_msg_ret ("ulwip_init" , ret); + + ret =ulwip_tftp (fdt_addr, fname); +if (ret) +return log_msg_ret ("ulwip_tftp" , ret); + + ret =ulwip_loop (); +if (!ret) { bflow->fdt_size =env_get_hex ("filesize" ,0 ); bflow->fdt_addr = fdt_addr; }else {
boot/bootmeth_pxe.c +13 -8
@@ -21,6 +21,8 @@#include <mapmem.h> #include <mmc.h> #include <net.h> +#include <net/ulwip.h> +#include <net/lwip.h> #include <pxe_utils.h> static int extlinux_pxe_getfile(struct pxe_context *ctx, const char *file_path,
@@ -116,18 +118,21 @@ static int extlinux_pxe_read_file(struct udevice *dev, struct bootflow *bflow, const char *file_path, ulong addr, ulong *sizep) { - char *tftp_argv[] = {"tftp", NULL, NULL, NULL}; -struct pxe_context *ctx =dev_get_priv (dev); -char file_addr[17 ]; ulong size;int ret; -sprintf (file_addr,"%lx" , addr); - tftp_argv[1 ] = file_addr; - tftp_argv[2 ] = (void *)file_path; + ret =ulwip_init (); +if (ret) +return log_msg_ret ("ulwip_init" , ret); + + ret =ulwip_tftp (addr, file_path); +if (ret) +return log_msg_ret ("ulwip_tftp" , ret); + + ret =ulwip_loop (); +if (ret) +return log_msg_ret ("ulwip_loop" , ret); -if (do_tftpb (ctx->cmdtp,0 ,3 , tftp_argv)) -return -ENOENT ; ret =pxe_get_file_size (&size);if (ret)return log_msg_ret ("tftp" , ret);
cmd/net.c +9 -77
134 lines not on this page · raw message
cmd/pxe.c +9 -10
@@ -8,6 +8,7 @@#include <command.h> #include <fs.h> #include <net.h> +#include <net/lwip.h> #include <net6.h> #include <malloc.h>
@@ -29,21 +30,19 @@ const char *pxe_default_paths[] = {static int do_get_tftp (struct pxe_context *ctx,const char *file_path,char *file_addr,ulong *sizep) { -char *tftp_argv[] = {"tftp" ,NULL ,NULL ,NULL }; +ulong addr; +char *end;int ret; -int num_args; - tftp_argv[1 ] = file_addr; - tftp_argv[2 ] = (void *)file_path; + addr =hextoul (file_addr, &end); +if (ctx->use_ipv6) { - tftp_argv[3 ] =USE_IP6_CMD_PARAM ; - num_args =4 ; - }else { - num_args =3 ; +/* @todo: check and fix me, here */ } -if (do_tftpb (ctx->cmdtp,0 , num_args, tftp_argv)) -return -ENOENT ; + ret =ulwip_tftp (addr, file_path); +if (ret) +return log_msg_ret ("tftp" , ret); ret =pxe_get_file_size (sizep);if (ret)
include/net.h +5 -3
@@ -54,8 +54,10 @@ struct in_addr {__be32 s_addr; }; +int do_lwip_dhcp (void ); +/** -* do_tftpb - Run the tftpboot command +* do_lwip_tftp - Run the tftpboot command * * @cmdtp: Command information for tftpboot * @flag: Command flags (CMD_FLAG_...)
@@ -63,7 +65,7 @@ struct in_addr {* @argv: List of arguments * Return: result (see enum command_ret_t) */ -int do_tftpb (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]); +int do_lwip_tftp (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]);/** * dhcp_run() - Run DHCP on the current ethernet device
@@ -514,7 +516,7 @@ extern int net_restart_wrap; /* Tried all network devices */enum proto_t {BOOTP ,RARP ,ARP ,TFTPGET ,DHCP ,DHCP6 ,PING ,PING6 ,DNS ,NFS ,CDP ,NETCONS ,SNTP ,TFTPSRV ,TFTPPUT ,LINKLOCAL ,FASTBOOT_UDP ,FASTBOOT_TCP , -WOL ,UDP ,NCSI ,WGET ,RS +WOL ,UDP ,NCSI ,WGET ,RS ,LWIP };extern char net_boot_file_name[1024 ];/* Boot File name */
include/net/ulwip.h new file +64 -0
64 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v8 13/15 net/lwip: split net.h to net.h, arp.h and eth.h
In reply to Maxim Uvarovcurrent net.h has ethernet and protocol definitions. Protocol definitions overlap with lwIP protocol definitions and net.h can not be included from lwIP code. Splitting on logical blocks makes that work.
--- include/net.h | 189 +-------------------------------------------- include/net/arp.h | 7 ++ include/net/eth.h | 190 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 201 insertions(+), 185 deletions(-) create mode 100644 include/net/arp.h create mode 100644 include/net/eth.h
include/net.h +4 -185
@@ -20,6 +20,7 @@#include <time.h> #include <linux/if_ether.h> #include <rand.h> +#include <net/arp.h> struct bd_info ;struct cmd_tbl ;
@@ -30,25 +31,6 @@ struct udevice;#define DEBUG_NET_PKT 0/* Packets on info on the network at large */ #define DEBUG_INT_STATE 0/* Internal network state changes */ -/* -* The number of receive packet buffers, and the required packet buffer -* alignment in memory. -* -*/ -#define PKTBUFSRX CONFIG_SYS_RX_ETH_BUFFER -#define PKTALIGN ARCH_DMA_MINALIGN - -/* Number of packets processed together */ -#define ETH_PACKETS_BATCH_RECV 32 - -/* ARP hardware address length */ -#define ARP_HLEN 6 -/* -* The size of a MAC address in string form, each digit requires two chars -* and five separator characters to form '00:00:00:00:00:00'. -*/ -#define ARP_HLEN_ASCII (ARP_HLEN * 2) + (ARP_HLEN - 1) -/* IPv4 addresses are always 32 bits in size */ struct in_addr {__be32 s_addr;
@@ -112,150 +94,7 @@ typedef void rxhand_icmp_f(unsigned type, unsigned code, unsigned dport,*/ typedef void thand_f (void ); -enum eth_state_t { -ETH_STATE_INIT , -ETH_STATE_PASSIVE , -ETH_STATE_ACTIVE -}; - -/** -* struct eth_pdata - Platform data for Ethernet MAC controllers -* -* @iobase: The base address of the hardware registers -* @enetaddr: The Ethernet MAC address that is loaded from EEPROM or env -* @phy_interface: PHY interface to use - see PHY_INTERFACE_MODE_... -* @max_speed: Maximum speed of Ethernet connection supported by MAC -* @priv_pdata: device specific plat -*/ -struct eth_pdata { -phys_addr_t iobase; -unsigned char enetaddr[ARP_HLEN ]; -int phy_interface; -int max_speed; -void *priv_pdata; -}; - -enum eth_recv_flags { -/* -* Check hardware device for new packets (otherwise only return those -* which are already in the memory buffer ready to process) -*/ -ETH_RECV_CHECK_DEVICE =1 <<0 , -}; - -/** -* struct eth_ops - functions of Ethernet MAC controllers -* -* start: Prepare the hardware to send and receive packets -* send: Send the bytes passed in "packet" as a packet on the wire -* recv: Check if the hardware received a packet. If so, set the pointer to the -* packet buffer in the packetp parameter. If not, return an error or 0 to -* indicate that the hardware receive FIFO is empty. If 0 is returned, the -* network stack will not process the empty packet, but free_pkt() will be -* called if supplied -* free_pkt: Give the driver an opportunity to manage its packet buffer memory -* when the network stack is finished processing it. This will only be -* called when no error was returned from recv - optional -* stop: Stop the hardware from looking for packets - may be called even if -* state == PASSIVE -* mcast: Join or leave a multicast group (for TFTP) - optional -* write_hwaddr: Write a MAC address to the hardware (used to pass it to Linux -* on some platforms like ARM). This function expects the -* eth_pdata::enetaddr field to be populated. The method can -* return -ENOSYS to indicate that this is not implemented for -this hardware - optional. -* read_rom_hwaddr: Some devices have a backup of the MAC address stored in a -* ROM on the board. This is how the driver should expose it -* to the network stack. This function should fill in the -* eth_pdata::enetaddr field - optional -* set_promisc: Enable or Disable promiscuous mode -* get_sset_count: Number of statistics counters -* get_string: Names of the statistic counters -* get_stats: The values of the statistic counters -*/ -struct eth_ops { -int (*start)(struct udevice *dev); -int (*send)(struct udevice *dev,void *packet,int length); -int (*recv)(struct udevice *dev,int flags,uchar **packetp); -int (*free_pkt)(struct udevice *dev,uchar *packet,int length); -void (*stop)(struct udevice *dev); -int (*mcast)(struct udevice *dev,const u8 *enetaddr,int join); -int (*write_hwaddr)(struct udevice *dev); -int (*read_rom_hwaddr)(struct udevice *dev); -int (*set_promisc)(struct udevice *dev,bool enable); -int (*get_sset_count)(struct udevice *dev); -void (*get_strings)(struct udevice *dev,u8 *data); -void (*get_stats)(struct udevice *dev,u64 *data); -}; - -#define eth_get_ops (dev) ((struct eth_ops *)(dev)->driver->ops) - -struct udevice *eth_get_dev (void );/* get the current device */ -/* -* The devname can be either an exact name given by the driver or device tree -* or it can be an alias of the form "eth%d" -*/ -struct udevice *eth_get_dev_by_name (const char *devname); -unsigned char *eth_get_ethaddr (void );/* get the current device MAC */ - -/* Used only when NetConsole is enabled */ -int eth_is_active (struct udevice *dev);/* Test device for active state */ -int eth_init_state_only (void );/* Set active state */ -void eth_halt_state_only (void );/* Set passive state */ - -int eth_initialize (void );/* Initialize network subsystem */ -void eth_try_another (int first_restart);/* Change the device */ -void eth_set_current (void );/* set nterface to ethcur var */ - -int eth_get_dev_index (void );/* get the device index */ - -/** -* eth_env_set_enetaddr_by_index() - set the MAC address environment variable -* -* This sets up an environment variable with the given MAC address (@enetaddr). -* The environment variable to be set is defined by <@base_name><@index>addr. -* If @index is 0 it is omitted. For common Ethernet this means ethaddr, -* eth1addr, etc. -* -* @base_name: Base name for variable, typically "eth" -* @index: Index of interface being updated (>=0) -* @enetaddr: Pointer to MAC address to put into the variable -* Return: 0 if OK, other value on error -*/ -int eth_env_set_enetaddr_by_index (const char *base_name,int index, -uchar *enetaddr); - - -/* -* Initialize USB ethernet device with CONFIG_DM_ETH -* Returns: -* 0 is success, non-zero is error status. -*/ -int usb_ether_init (void ); - -/* -* Get the hardware address for an ethernet interface . -* Args: -* base_name - base name for device (normally "eth") -* index - device index number (0 for first) -* enetaddr - returns 6 byte hardware address -* Returns: -* Return true if the address is valid. -*/ -int eth_env_get_enetaddr_by_index (const char *base_name,int index, -uchar *enetaddr); - -int eth_init (void );/* Initialize the device */ -int eth_send (void *packet,int length);/* Send a packet */ - -#if defined(CONFIG_API ) || defined(CONFIG_EFI_LOADER ) -int eth_receive (void *packet,int length);/* Receive a packet*/ -extern void (*push_packet)(void *packet,int length); -#endif -int eth_rx (void );/* Check for received packets */ -void eth_halt (void );/* stop SCC */ -const char *eth_get_name (void );/* get name of current device */ -int eth_mcast_join (struct in_addr mcast_addr,int join); +#include <net/eth.h> /**********************************************************************/ /*
@@ -495,16 +334,6 @@ extern char net_root_path[CONFIG_BOOTP_MAX_ROOT_PATH_LEN]; /* Our root path *//* Indicates whether the pxe path prefix / config file was specified in dhcp option */ extern char *pxelinux_configfile;/** END OF BOOTP EXTENTIONS **/ -extern u8 net_ethaddr[ARP_HLEN ];/* Our ethernet address */ -extern u8 net_server_ethaddr[ARP_HLEN ];/* Boot server enet address */ -extern struct in_addr net_ip;/* Our IP addr (0 = unknown) */ -extern struct in_addr net_server_ip;/* Server IP addr (0 = unknown) */ -extern uchar *net_tx_packet;/* THE transmit packet */ -extern uchar *net_rx_packets[PKTBUFSRX ];/* Receive packets */ -extern uchar *net_rx_packet;/* Current receive packet */ -extern int net_rx_packet_len;/* Current rx packet length */ -extern const u8 net_bcast_ethaddr[ARP_HLEN ];/* Ethernet broadcast address */ -extern const u8 net_null_ethaddr[ARP_HLEN ];#define VLAN_NONE 4095/* untagged */ #define VLAN_IDMASK 0x0fff/* mask of valid vlan id */
@@ -557,6 +386,8 @@ extern struct in_addr net_ntp_server; /* the ip address to NTP */extern int net_ntp_time_offset;/* offset time from UTC */ #endif +int eth_mcast_join (struct in_addr mcast_addr,int join); +/* Initialize the network adapter */ int net_init (void );int net_loop (enum proto_t );
@@ -827,18 +658,6 @@ static inline void net_random_ethaddr(uchar *addr) addr[0 ] |=0x02 ;/* set local assignment bit (IEEE802) */ } -/** -* string_to_enetaddr() - Parse a MAC address -* -* Convert a string MAC address -* -* Implemented in lib/net_utils.c (built unconditionally) -* -* @addr: MAC address in aa:bb:cc:dd:ee:ff format, where each part is a 2-digit -* hex value -* @enetaddr: Place to put MAC address (6 bytes) -*/ -void string_to_enetaddr (const char *addr,uint8_t *enetaddr);/* Convert an IP address to a string */ void ip_to_string (struct in_addr x,char *s);
include/net/arp.h new file +7 -0
@@ -0,0 +1,7 @@ +/* ARP hardware address length */ +#define ARP_HLEN 6 +/* +* The size of a MAC address in string form, each digit requires two chars +* and five separator characters to form '00:00:00:00:00:00'. +*/ +#define ARP_HLEN_ASCII (ARP_HLEN * 2) + (ARP_HLEN - 1)
include/net/eth.h new file +190 -0
190 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v8 14/15 net/lwip: drop old net/wget
In reply to Maxim UvarovAfter which to lwip variants of working apps we need to drop old code with all dependencies. This commit drop old wget command files.
--- include/net/wget.h | 22 --- net/Makefile | 1 - net/net.c | 6 - net/wget.c | 440 --------------------------------------------- 4 files changed, 469 deletions(-) delete mode 100644 include/net/wget.h delete mode 100644 net/wget.c
include/net/wget.h deleted +0 -22
@@ -1,22 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* -* Duncan Hare Copyright 2017 -*/ - -/** -* wget_start() - begin wget -*/ -void wget_start (void ); - -enum wget_state { -WGET_CLOSED , -WGET_CONNECTING , -WGET_CONNECTED , -WGET_TRANSFERRING , -WGET_TRANSFERRED -}; - -#define DEBUG_WGET 0/* Set to 1 for debug messages */ -#define SERVER_PORT 80 -#define WGET_RETRY_COUNT 30 -#define WGET_TIMEOUT 2000UL
net/Makefile +0 -1
@@ -32,7 +32,6 @@ obj-$(CONFIG_TCP_FUNCTION_FASTBOOT) += fastboot_tcp.o obj-$(CONFIG_CMD_WOL) += wol.o obj-$(CONFIG_PROT_UDP) += udp.o obj-$(CONFIG_PROT_TCP) += tcp.o -obj-$(CONFIG_CMD_WGET) += wget.o obj-$(CONFIG_LWIP) += lwip/ # Disable this warning as it is triggered by:
net/net.c +0 -6
@@ -109,7 +109,6 @@#include <linux/compiler.h> #include <test/test.h> #include <net/tcp.h> -#include <net/wget.h> #include "arp.h" #include "bootp.h" #include "cdp.h"
@@ -564,11 +563,6 @@ restart:nfs_start ();break ;#endif -#if defined(CONFIG_CMD_WGET ) -case WGET : -wget_start (); -break ; -#endif #if defined(CONFIG_CMD_CDP )case CDP :cdp_start ();
net/wget.c deleted +0 -440
440 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v8 15/15 net/lwip/wget add port selection
In reply to Maxim UvarovAllow to specify HTTP port instead of just using default for wget command.
--- include/net/lwip.h | 2 +- net/lwip/apps/http/lwip-wget.c | 40 +++++++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 11 deletions(-)
include/net/lwip.h +1 -1
@@ -54,7 +54,7 @@ int ulwip_tftp(ulong addr, const char *filename);* * * @addr: start address to download result -* @url: url in format http://host/url +* @url: url in format http://host[:port]/url * Returns: 0 for success, !0 if error */ int ulwip_wget (ulong addr,char *url);
net/lwip/apps/http/lwip-wget.c +30 -10
@@ -63,18 +63,38 @@ static int parse_url(char *url, char *host, u16 *port) p +=strlen ("http://" );/* parse hostname */ - pp =strchr (p,'/' ); -if (!pp) { -return -2 ; + pp =strchr (p,':' ); +if (pp) { +#define PORT_STR_SIZE 5 +char portstr[PORT_STR_SIZE ]; + +if (pp - p >=SERVER_NAME_SIZE ) +return -2 ; +memcpy (host, p, pp - p); + host[pp - p +1 ] ='\0' ; + + p = pp +1 ; + pp =strchr (p,'/' ); +if (!pp) +return -3 ; + +if (pp - p >=PORT_STR_SIZE ) +return -4 ; +memcpy (portstr, p, pp - p); + portstr[pp - p] ='\0' ; + *port = (u16 )dectoul (portstr,NULL ); + }else { + pp =strchr (p,'/' ); +if (!pp) +return -5 ; + +if (pp - p >=SERVER_NAME_SIZE ) +return -6 ; +memcpy (host, p, pp - p); + host[pp - p +1 ] ='\0' ; + *port =HTTP_PORT_DEFAULT ; } -if (pp - p >=SERVER_NAME_SIZE ) -return -3 ; - -memcpy (host, p, pp - p); - host[pp - p +1 ] ='\0' ; - *port =HTTP_PORT_DEFAULT ; -return 0 ; }
Signature · 1 line
2.30.2
Re: [PATCHv8 15/15] net/lwip/wget add port selection
Hi Maxi,
I'd drop this from the series. It's useful in the long run, but let's just get the minimum functionality in first
Thanks
/Ilias
Quoted 77 lines · Maxim Uvarov
Allow to specify HTTP port instead of just using default for wget command.
Signed-off-by Maxim Uvarov <[email protected]>--- include/net/lwip.h | 2 +- net/lwip/apps/http/lwip-wget.c | 40 +++++++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 11 deletions(-)include/net/lwip.h +1
-1@@ -54,7 +54,7 @@ int ulwip_tftp(ulong addr, const char *filename);* * * @addr: start address to download result -* @url: url in format http://host/url +* @url: url in format http://host[:port]/url * Returns: 0 for success, !0 if error */ int ulwip_wget (ulong addr,char *url);net/lwip/apps/http/lwip-wget.c +30
-11@@ -63,18 +63,38 @@ static int parse_url(char *url, char *host, u16 *port) p +=strlen ("http://" );/* parse hostname */ - pp =strchr (p,'/' ); -if (!pp) { -return -2 ; + pp =strchr (p,':' ); +if (pp) { +#define PORT_STR_SIZE 5 +char portstr[PORT_STR_SIZE ]; + +if (pp - p >=SERVER_NAME_SIZE ) +return -2 ; +memcpy (host, p, pp - p); + host[pp - p +1 ] ='\0' ; + + p = pp +1 ; + pp =strchr (p,'/' ); +if (!pp) +return -3 ; + +if (pp - p >=PORT_STR_SIZE ) +return -4 ; +memcpy (portstr, p, pp - p); + portstr[pp - p] ='\0' ; + *port = (u16 )dectoul (portstr,NULL ); + }else { + pp =strchr (p,'/' ); +if (!pp) +return -5 ; + +if (pp - p >=SERVER_NAME_SIZE ) +return -6 ; +memcpy (host, p, pp - p); + host[pp - p +1 ] ='\0' ; + *port =HTTP_PORT_DEFAULT ; } -if (pp - p >=SERVER_NAME_SIZE ) -return -3 ; - -memcpy (host, p, pp - p); - host[pp - p +1 ] ='\0' ; - *port =HTTP_PORT_DEFAULT ; -return 0 ; } --2.30.2
Quoted 5 lines · Maxim Uvarov
Before apply these patches it is needed to create lwIP merge into U-Boot:
git subtree add --prefixnet/lwip/lwip-externalhttps://git.savannah.nongnu.org/git/lwip.git master --squash or
create git submodule, depends how it's more easy to maintain external
library.
So, I think we're going to go with subtree. Please work out how to integrate the above in to the build process automatically (and such that we can maintain it via upgrades moving forward).
Signature · 1 line
Tom
Quoted 10 lines · Tom Rini
Quoted 1 line · Maxim Uvarov
Before apply these patches it is needed to create lwIP merge into
U-Boot:
Quoted 1 line
git subtree add --prefix
net/lwip/lwip-externalhttps://git.savannah.nongnu.org/git/lwip.git master --squash
Quoted 3 lines
or
create git submodule, depends how it's more easy to maintain external library.
Quoted 7 lines
So, I think we're going to go with subtree. Please work out how to integrate the above in to the build process automatically (and such that we can maintain it via upgrades moving forward).
--
Tom
I did not find a good way to friend git format-patch, git am and subtree. And now with using subtree I can provide my thoughts, in general I do not see any big advantages
with maintaining subtree code.
Problem is that:
1. subtree does some root reset. So rebase looks like:
label onto
# Branch acbc0469a49de7055141cc730aa9c728e61b6de2-2
reset [new root]
pick acbc0469a4 Squashed 'net/lwip/lwip-external/' content from commit 84fde1ebbf
label acbc0469a49de7055141cc730aa9c728e61b6de2-2
reset onto
merge -C ec4a128c8d acbc0469a49de7055141cc730aa9c728e61b6de2-2 # Merge commit 'acbc0469a49de7055141cc730aa9c728e61b6de2' as 'net/lwip/lwip-external'
pick 739681a6f5 net/lwip: add doc/develop/net_lwip.rst
pick f0ecab85e0 net/lwip: integrate lwIP library
2. if --rebase-merges option was not provided to rebase, then rebase will omit subtree directory and try to apply rebase patches to root directory. I.e. in current case squashed commit for lwip, will be applied to uboot root directory instead of ./net/lwip/lwip-external.
3. due to broken rebases without --rebase-merges more likely things like git bisect also will not work.
4. change in subtree code ./net/lwip/lwip-external/../something.c will create a git commit which looks like a standard U-Boot commit. I.e. path starts with ./net/lwip/lwip-external/
5. lwip maintains code with a mailing list. So we don't need to push subtree git somewhere to create a pull request.
6. I rechecked the latest edk2 and they use submodules now. (openssl, libfdt, berkeley-softfloat-3 and others).
7. dynamic download also looks horrible for me. I.e. create subtree in Makefile on compilation process. I think maintaining that will give you a bunch of problems. I think we should not touch git structure after cloning.
So what I can here suggest:
1. lwip source code is 9.4M. If we compare all code it will be 564M in total. So just having 1 commit witn copy of lwip library will work here.
or
2. use git submodules. Size of the project will be lower. Submodule will not allow you to use local changes. I.e. change needs to be merged into the upstream project and then you can update git HEAD for the submodule.
or
3. inside u-boot.git create branch lib-lwip and clone lwip repo there. Then use git submoule to connect this branch as a folder to the main U-Boot code.
BR,
Maxim.
Hi Maxim,
Quoted 57 lines · Maxim Uvarov
Quoted 10 lines · Tom Rini
Quoted 1 line · Maxim Uvarov
Before apply these patches it is needed to create lwIP merge into
U-Boot:
Quoted 1 line
git subtree add --prefix
net/lwip/lwip-externalhttps://git.savannah.nongnu.org/git/lwip.git master --squash
Quoted 3 lines
or
create git submodule, depends how it's more easy to maintain external library.Quoted 7 lines
So, I think we're going to go with subtree. Please work out how to integrate the above in to the build process automatically (and such that we can maintain it via upgrades moving forward).
--
TomI did not find a good way to friend git format-patch, git am and subtree. And now with using subtree I can provide my thoughts, in general I do not see any big advantages
with maintaining subtree code.Problem is that:
1. subtree does some root reset. So rebase looks like:
label onto# Branch acbc0469a49de7055141cc730aa9c728e61b6de2-2
reset [new root]
pick
acbc0469a4Squashed 'net/lwip/lwip-external/' content from commit84fde1ebbf
label acbc0469a49de7055141cc730aa9c728e61b6de2-2reset onto
merge -C
ec4a128c8dacbc0469a49de7055141cc730aa9c728e61b6de2-2 # Merge commit 'acbc0469a49de7055141cc730aa9c728e61b6de2' as 'net/lwip/lwip-external'
pick739681a6f5net/lwip: adddoc/develop/net_lwip.rstpick
f0ecab85e0net/lwip: integrate lwIP library2. if --rebase-merges option was not provided to rebase, then rebase will omit subtree directory and try to apply rebase patches to root directory. I.e. in current case squashed commit for lwip, will be applied to uboot root directory instead of
./net/lwip/lwip-external.
Quoted 6 lines
3. due to broken rebases without --rebase-merges more likely things like git bisect also will not work.
4. change in subtree code
./net/lwip/lwip-external/../something.cwill create a git commit which looks like a standard U-Boot commit. I.e. path starts with./net/lwip/lwip-external/
I don't really understand most of the above, but I take it that subtree has some problems...I did find an article about subtree [1]
Quoted 7 lines
5. lwip maintains code with a mailing list. So we don't need to push subtree git somewhere to create a pull request.
6. I rechecked the latest edk2 and they use submodules now. (openssl, libfdt, berkeley-softfloat-3 and others).
Quoted 7 lines
7. dynamic download also looks horrible for me. I.e. create subtree in
Makefileon compilation process. I think maintaining that will give you a bunch of problems. I think we should not touch git structure after cloning.So what I can here suggest:
1. lwip source code is 9.4M. If we compare all code it will be 564M in total. So just having 1 commit witn copy of lwip library will work here.
So we add a 9.4MB patch for the code we need? I suppose that is OK, although it is much larger than net/ today (0.5MB).
What is the churn on lwip? E.g. would it be easy to add a commit every few months to bring in upstream changes?
Quoted 6 lines
or
2. use git submodules. Size of the project will be lower. Submodule will not allow you to use local changes. I.e. change needs to be merged into the upstream project and then you can update git HEAD for the submodule.
I really don't want to work with a submodule project. I've just had too many problems.
Quoted 5 lines
or
3. inside u-boot.git create branch lib-lwip and clone lwip repo there. Then use git submoule to connect this branch as a folder to the main U-Boot code.
It really needs to be properly part of U-Boot.
Quoted 3 lines
BR,
Maxim.
Regards,
Simon
Quoted 107 lines · Simon Glass
Hi Maxim,
Quoted 7 lines · Maxim Uvarov
Quoted 4 lines · Tom Rini
Quoted 1 line · Maxim Uvarov
Before apply these patches it is needed to create lwIP merge into
U-Boot:
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
git subtree add --prefix
net/lwip/lwip-externalhttps://git.savannah.nongnu.org/git/lwip.git master --squash
Quoted 3 lines
or
create git submodule, depends how it's more easy to maintain external library.So, I think we're going to go with subtree. Please work out how to integrate the above in to the build process automatically (and such
that
Quoted 30 lines
Quoted 5 lines
we can maintain it via upgrades moving forward).
--
TomI did not find a good way to friend git format-patch, git am and subtree. And now with using subtree I can provide my thoughts, in general I do not see any big advantages
with maintaining subtree code.Problem is that:
1. subtree does some root reset. So rebase looks like:
label onto# Branch acbc0469a49de7055141cc730aa9c728e61b6de2-2
reset [new root]
pick
acbc0469a4Squashed 'net/lwip/lwip-external/' content from commit84fde1ebbf
label acbc0469a49de7055141cc730aa9c728e61b6de2-2reset onto
Quoted 8 lines
merge -C
ec4a128c8dacbc0469a49de7055141cc730aa9c728e61b6de2-2 # Merge commit 'acbc0469a49de7055141cc730aa9c728e61b6de2' as 'net/lwip/lwip-external'
pick739681a6f5net/lwip: adddoc/develop/net_lwip.rstpick
f0ecab85e0net/lwip: integrate lwIP library2. if --rebase-merges option was not provided to rebase, then rebase
will
Quoted 10 lines
omit subtree directory and try to apply rebase patches to root directory. I.e. in current case squashed commit for lwip, will be applied to uboot root directory instead of
./net/lwip/lwip-external.3. due to broken rebases without --rebase-merges more likely things like git bisect also will not work.
4. change in subtree code
./net/lwip/lwip-external/../something.cwill create a git commit which looks like a standard U-Boot commit. I.e. path starts with./net/lwip/lwip-external/I don't really understand most of the above, but I take it that subtree has some problems...I did find an article about subtree [1]
Quoted 10 lines
5. lwip maintains code with a mailing list. So we don't need to push subtree git somewhere to create a pull request.
6. I rechecked the latest edk2 and they use submodules now. (openssl, libfdt, berkeley-softfloat-3 and others).
7. dynamic download also looks horrible for me. I.e. create subtree in
Makefileon compilation process. I think maintaining that will give you a bunch of problems. I think we should not touch git structure aftercloning.
Quoted 4 lines
So what I can here suggest:
1. lwip source code is 9.4M. If we compare all code it will be 564M in total. So just having 1 commit witn copy of lwip library will work here.So we add a 9.4MB patch for the code we need? I suppose that is OK, although it is much larger than
net/today (0.5MB).What is the churn on lwip? E.g. would it be easy to add a commit every few months to bring in upstream changes?
Quoted 5 lines
or
2. use git submodules. Size of the project will be lower. Submodule will not allow you to use local changes. I.e. change needs to be merged into
the
Quoted 1 line
upstream project and then you can update git HEAD for the submodule.
I really don't want to work with a submodule project. I've just had too many problems.
Quoted 1 line
Quoted 10 lines
Quoted 3 lines
or
3. inside u-boot.git create branch lib-lwip and clone lwip repo there.
Then
Quoted 1 line
use git submoule to connect this branch as a folder to the main U-Boot
code.
It really needs to be properly part of U-Boot.
Ok. Then more likely we don't need all the git history of lwip inside uboot.git. Then the option with a single commit is more preferable. Then we can use part 2 of this article, how to go with standard git commands:
1.
<cmd>
git remote add -f lwip https://git.savannah.nongnu.org/git/lwip.git
git read-tree --prefix=net/lwip/lwip-external -u lwip/master git commit -m "lwip merge sha: xxxx"
</cmd>
this will create a git format-patch friendly commit. Then we send it to the mailing list and apply.
I hope the mailing list will allow us to send a 7.8 MB patch.
Then if for development you need to pull he history of lwip, you can do it with:
git pull -s subtree lwip master --allow-unrelated-histories (but I think nobody will need this.)
New update of the lwip net/lwip/lwip-external dir will be done with:
git pull -s subtree lwip master --allow-unrelated-histories --squash Squash commit also has to be git format-patch friendly.
If you are ok with that proposal I will send v9 with the first patch created with steps above.
Thanks,
Maxim.
Quoted 9 lines
Quoted 3 lines
BR,
Maxim.Regards,
Simon
Hi Maxim,
Quoted 132 lines · Maxim Uvarov
Quoted 103 lines · Simon Glass
Hi Maxim,
Quoted 57 lines · Maxim Uvarov
Quoted 10 lines · Tom Rini
Quoted 1 line · Maxim Uvarov
Before apply these patches it is needed to create lwIP merge into
U-Boot:
Quoted 1 line
git subtree add --prefix
net/lwip/lwip-externalhttps://git.savannah.nongnu.org/git/lwip.git master --squash
Quoted 3 lines
or
create git submodule, depends how it's more easy to maintain external library.Quoted 7 lines
So, I think we're going to go with subtree. Please work out how to integrate the above in to the build process automatically (and such that we can maintain it via upgrades moving forward).
--
TomI did not find a good way to friend git format-patch, git am and subtree. And now with using subtree I can provide my thoughts, in general I do not see any big advantages
with maintaining subtree code.Problem is that:
1. subtree does some root reset. So rebase looks like:
label onto# Branch acbc0469a49de7055141cc730aa9c728e61b6de2-2
reset [new root]
pick
acbc0469a4Squashed 'net/lwip/lwip-external/' content from commit84fde1ebbf
label acbc0469a49de7055141cc730aa9c728e61b6de2-2reset onto
merge -C
ec4a128c8dacbc0469a49de7055141cc730aa9c728e61b6de2-2 # Merge commit 'acbc0469a49de7055141cc730aa9c728e61b6de2' as 'net/lwip/lwip-external'
pick739681a6f5net/lwip: adddoc/develop/net_lwip.rstpick
f0ecab85e0net/lwip: integrate lwIP library2. if --rebase-merges option was not provided to rebase, then rebase will omit subtree directory and try to apply rebase patches to root directory. I.e. in current case squashed commit for lwip, will be applied to uboot root directory instead of
./net/lwip/lwip-external.Quoted 6 lines
3. due to broken rebases without --rebase-merges more likely things like git bisect also will not work.
4. change in subtree code
./net/lwip/lwip-external/../something.cwill create a git commit which looks like a standard U-Boot commit. I.e. path starts with./net/lwip/lwip-external/I don't really understand most of the above, but I take it that subtree has some problems...I did find an article about subtree [1]
Quoted 7 lines
5. lwip maintains code with a mailing list. So we don't need to push subtree git somewhere to create a pull request.
6. I rechecked the latest edk2 and they use submodules now. (openssl, libfdt, berkeley-softfloat-3 and others).
Quoted 7 lines
7. dynamic download also looks horrible for me. I.e. create subtree in
Makefileon compilation process. I think maintaining that will give you a bunch of problems. I think we should not touch git structure after cloning.So what I can here suggest:
1. lwip source code is 9.4M. If we compare all code it will be 564M in total. So just having 1 commit witn copy of lwip library will work here.So we add a 9.4MB patch for the code we need? I suppose that is OK, although it is much larger than
net/today (0.5MB).What is the churn on lwip? E.g. would it be easy to add a commit every few months to bring in upstream changes?
Quoted 6 lines
or
2. use git submodules. Size of the project will be lower. Submodule will not allow you to use local changes. I.e. change needs to be merged into the upstream project and then you can update git HEAD for the submodule.
I really don't want to work with a submodule project. I've just had too many problems.
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
or
3. inside u-boot.git create branch lib-lwip and clone lwip repo there. Then use git submoule to connect this branch as a folder to the main U-Boot code.
It really needs to be properly part of U-Boot.
Ok. Then more likely we don't need all the git history of lwip inside uboot.git. Then the option with a single commit is more preferable. Then we can use part 2 of this article, how to go with standard git commands:
1.
<cmd>
git remote add -f lwip https://git.savannah.nongnu.org/git/lwip.git
git read-tree --prefix=net/lwip/lwip-external -u lwip/master
git commit -m "lwip merge sha: xxxx"
</cmd>
this will create a git format-patch friendly commit. Then we send it to the mailing list and apply. I hope the mailing list will allow us to send a 7.8 MB patch.Then if for development you need to pull he history of lwip, you can do it with:
git pull -s subtree lwip master --allow-unrelated-histories
(but I think nobody will need this.)
Quoted 5 lines
New update of the lwip
net/lwip/lwip-externaldir will be done with:
git pull -s subtree lwip master --allow-unrelated-histories --squash Squash commit also has to be git format-patch friendly.If you are ok with that proposal I will send v9 with the first patch created with steps above.
We've gone through this before. The whole purpose of this is not having to maintain patches.
Simon, instead of "I had problems in the past", can you elaborate a bit more?
Tom said he is fine with subtrees instead of submodules and I know for a fact EDK2 doesn't have too many issues with submodules. Their documentation is pretty clear on building and requires
git clone https://github.com/tianocore/edk2.git
cd edk2
git submodule update --init
Perhaps the situation has improved since you had issues?
Thanks
/Ilias
Quoted 18 lines
Thanks,
Maxim.Quoted 9 lines
Quoted 4 lines
BR,
Maxim.Regards,
Simon
Quoted 149 lines · Ilias Apalodimas
Hi Maxim,
Quoted 132 lines · Maxim Uvarov
Quoted 103 lines · Simon Glass
Hi Maxim,
Quoted 57 lines · Maxim Uvarov
Quoted 10 lines · Tom Rini
Quoted 1 line · Maxim Uvarov
Before apply these patches it is needed to create lwIP merge into
U-Boot:
Quoted 1 line
git subtree add --prefix
net/lwip/lwip-externalhttps://git.savannah.nongnu.org/git/lwip.git master --squash
Quoted 3 lines
or
create git submodule, depends how it's more easy to maintain external library.Quoted 7 lines
So, I think we're going to go with subtree. Please work out how to integrate the above in to the build process automatically (and such that we can maintain it via upgrades moving forward).
--
TomI did not find a good way to friend git format-patch, git am and subtree. And now with using subtree I can provide my thoughts, in general I do not see any big advantages
with maintaining subtree code.Problem is that:
1. subtree does some root reset. So rebase looks like:
label onto# Branch acbc0469a49de7055141cc730aa9c728e61b6de2-2
reset [new root]
pick
acbc0469a4Squashed 'net/lwip/lwip-external/' content from commit84fde1ebbf
label acbc0469a49de7055141cc730aa9c728e61b6de2-2reset onto
merge -C
ec4a128c8dacbc0469a49de7055141cc730aa9c728e61b6de2-2 # Merge commit 'acbc0469a49de7055141cc730aa9c728e61b6de2' as 'net/lwip/lwip-external'
pick739681a6f5net/lwip: adddoc/develop/net_lwip.rstpick
f0ecab85e0net/lwip: integrate lwIP library2. if --rebase-merges option was not provided to rebase, then rebase will omit subtree directory and try to apply rebase patches to root directory. I.e. in current case squashed commit for lwip, will be applied to uboot root directory instead of
./net/lwip/lwip-external.Quoted 6 lines
3. due to broken rebases without --rebase-merges more likely things like git bisect also will not work.
4. change in subtree code
./net/lwip/lwip-external/../something.cwill create a git commit which looks like a standard U-Boot commit. I.e. path starts with./net/lwip/lwip-external/I don't really understand most of the above, but I take it that subtree has some problems...I did find an article about subtree [1]
Quoted 7 lines
5. lwip maintains code with a mailing list. So we don't need to push subtree git somewhere to create a pull request.
6. I rechecked the latest edk2 and they use submodules now. (openssl, libfdt, berkeley-softfloat-3 and others).
Quoted 7 lines
7. dynamic download also looks horrible for me. I.e. create subtree in
Makefileon compilation process. I think maintaining that will give you a bunch of problems. I think we should not touch git structure after cloning.So what I can here suggest:
1. lwip source code is 9.4M. If we compare all code it will be 564M in total. So just having 1 commit witn copy of lwip library will work here.So we add a 9.4MB patch for the code we need? I suppose that is OK, although it is much larger than
net/today (0.5MB).What is the churn on lwip? E.g. would it be easy to add a commit every few months to bring in upstream changes?
Quoted 6 lines
or
2. use git submodules. Size of the project will be lower. Submodule will not allow you to use local changes. I.e. change needs to be merged into the upstream project and then you can update git HEAD for the submodule.
I really don't want to work with a submodule project. I've just had too many problems.
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
or
3. inside u-boot.git create branch lib-lwip and clone lwip repo there. Then use git submoule to connect this branch as a folder to the main U-Boot code.
It really needs to be properly part of U-Boot.
Ok. Then more likely we don't need all the git history of lwip inside uboot.git. Then the option with a single commit is more preferable. Then we can use part 2 of this article, how to go with standard git commands:
1.
<cmd>
git remote add -f lwip https://git.savannah.nongnu.org/git/lwip.git
git read-tree --prefix=net/lwip/lwip-external -u lwip/master
git commit -m "lwip merge sha: xxxx"
</cmd>
this will create a git format-patch friendly commit. Then we send it to the mailing list and apply. I hope the mailing list will allow us to send a 7.8 MB patch.Then if for development you need to pull he history of lwip, you can do it with:
git pull -s subtree lwip master --allow-unrelated-histories
(but I think nobody will need this.)Quoted 5 lines
New update of the lwip
net/lwip/lwip-externaldir will be done with:
git pull -s subtree lwip master --allow-unrelated-histories --squash Squash commit also has to be git format-patch friendly.If you are ok with that proposal I will send v9 with the first patch created with steps above.
We've gone through this before. The whole purpose of this is not having to maintain patches.
Simon, instead of "I had problems in the past", can you elaborate a bit more?Tom said he is fine with subtrees instead of submodules and I know for a fact EDK2 doesn't have too many issues with submodules. Their documentation is pretty clear on building and requires
Quoted 5 lines
git clone https://github.com/tianocore/edk2.git
cd edk2
git submodule update --initPerhaps the situation has improved since you had issues?
While I don't really care how you solve this technically, I'd *strongly* be interested for U-Boot to use *unmodified* lwIP sources where an explicit reference to an lwIP commit is used. I'd rather integrate bugfixes for U-Boot into lwIP than having the sources drift apart.
Regards,
Simon
Quoted 21 lines
Thanks
/IliasQuoted 18 lines
Thanks,
Maxim.Quoted 9 lines
Quoted 4 lines
BR,
Maxim.Regards,
Simon
Quoted 22 lines
Quoted 22 lines
Quoted 9 lines
Then if for development you need to pull he history of lwip, you can do it with:
git pull -s subtree lwip master --allow-unrelated-histories
(but I think nobody will need this.)New update of the lwip
net/lwip/lwip-externaldir will be done with:
git pull -s subtree lwip master --allow-unrelated-histories --squash Squash commit also has to be git format-patch friendly.If you are ok with that proposal I will send v9 with the first patch created with steps above.
We've gone through this before. The whole purpose of this is not having to maintain patches.
Simon, instead of "I had problems in the past", can you elaborate a bit more?Tom said he is fine with subtrees instead of submodules and I know for a fact EDK2 doesn't have too many issues with submodules. Their documentation is pretty clear on building and requires
git clone https://github.com/tianocore/edk2.git
cd edk2
git submodule update --init
Quoted 6 lines
Quoted 1 line
Perhaps the situation has improved since you had issues?
While I don't really care how you solve this technically, I'd *strongly* be interested for U-Boot to use *unmodified* lwIP sources where an explicit reference to an lwIP commit is used. I'd rather integrate bugfixes for U-Boot into lwIP than having the sources drift apart.
Strongly agree here, we want to use upstream and all the combined development and reviews etc rather than forking off and ending up with yet another slightly different IP stack. The whole advantage of adopting LWIP is the advantage of combined security, features and bugs from a wide range of projects :-)
Quoted 29 lines · Peter Robinson
Quoted 22 lines
Quoted 22 lines
Quoted 9 lines
Then if for development you need to pull he history of lwip, you can do it with:
git pull -s subtree lwip master --allow-unrelated-histories
(but I think nobody will need this.)New update of the lwip
net/lwip/lwip-externaldir will be done with:
git pull -s subtree lwip master --allow-unrelated-histories --squash Squash commit also has to be git format-patch friendly.If you are ok with that proposal I will send v9 with the first patch created with steps above.
We've gone through this before. The whole purpose of this is not having to maintain patches.
Simon, instead of "I had problems in the past", can you elaborate a bit more?Tom said he is fine with subtrees instead of submodules and I know for a fact EDK2 doesn't have too many issues with submodules. Their documentation is pretty clear on building and requires
git clone https://github.com/tianocore/edk2.git
cd edk2
git submodule update --initQuoted 6 lines
Quoted 1 line
Perhaps the situation has improved since you had issues?
While I don't really care how you solve this technically, I'd *strongly* be interested for U-Boot to use *unmodified* lwIP sources where an explicit reference to an lwIP commit is used. I'd rather integrate bugfixes for U-Boot into lwIP than having the sources drift apart.
Quoted 5 lines
Strongly agree here, we want to use upstream and all the combined development and reviews etc rather than forking off and ending up with yet another slightly different IP stack. The whole advantage of adopting LWIP is the advantage of combined security, features and bugs from a wide range of projects :-)
Yes, this is what I want as well, and why I'm perhaps more agreeable with the approaches where it's a lot harder for us to start forking things unintentionally. I gather submodule rather than subtree would be better for that case?
Signature · 1 line
Tom
Quoted 42 lines · Tom Rini
Quoted 1 line · Peter Robinson
Quoted 1 line
Quoted 1 line
Quoted 1 line
Then if for development you need to pull he history of lwip, you
can do it with:
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
git pull -s subtree lwip master --allow-unrelated-histories (but I think nobody will need this.)
New update of the lwip
net/lwip/lwip-externaldir will be done with:
git pull -s subtree lwip master --allow-unrelated-histories--squash
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Squash commit also has to be git format-patch friendly.
If you are ok with that proposal I will send v9 with the first
patch created with steps above.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
We've gone through this before. The whole purpose of this is not having to maintain patches.
Simon, instead of "I had problems in the past", can you elaborate abit more?
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Tom said he is fine with subtrees instead of submodules and I know
for
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
a fact EDK2 doesn't have too many issues with submodules. Their documentation is pretty clear on building and requires
git clone https://github.com/tianocore/edk2.git
cd edk2
git submodule update --initPerhaps the situation has improved since you had issues?
While I don't really care how you solve this technically, I'd
*strongly*
Quoted 9 lines
Quoted 3 lines
be interested for U-Boot to use *unmodified* lwIP sources where an explicit reference to an lwIP commit is used. I'd rather integrate bugfixes for U-Boot into lwIP than having the sources drift apart.
Strongly agree here, we want to use upstream and all the combined development and reviews etc rather than forking off and ending up with yet another slightly different IP stack. The whole advantage of adopting LWIP is the advantage of combined security, features and bugs from a wide range of projects :-)
Quoted 8 lines
Yes, this is what I want as well, and why I'm perhaps more agreeable with the approaches where it's a lot harder for us to start forking things unintentionally. I gather submodule rather than subtree would be better for that case?
--
Tom
Yes, submodule will be a much better solution for us. And I also don't think that today
there are any issues with submodules. It works well of OE, RPM and DEB builds,
distributions should not have problems with it.
BR,
Maxim.
Hi,
Quoted 24 lines · Maxim Uvarov
Quoted 20 lines · Tom Rini
Quoted 18 lines · Peter Robinson
Quoted 18 lines
Quoted 18 lines
Quoted 9 lines
Then if for development you need to pull he history of lwip, you can do it with:
git pull -s subtree lwip master --allow-unrelated-histories
(but I think nobody will need this.)New update of the lwip
net/lwip/lwip-externaldir will be done with:
git pull -s subtree lwip master --allow-unrelated-histories --squash Squash commit also has to be git format-patch friendly.If you are ok with that proposal I will send v9 with the first patch created with steps above.
We've gone through this before. The whole purpose of this is not having to maintain patches.
Simon, instead of "I had problems in the past", can you elaborate a bit more?Tom said he is fine with subtrees instead of submodules and I know for a fact EDK2 doesn't have too many issues with submodules. Their documentation is pretty clear on building and requires
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
git clone https://github.com/tianocore/edk2.git
cd edk2
git submodule update --initPerhaps the situation has improved since you had issues?
Nope.
Quoted 17 lines
Quoted 17 lines
Quoted 11 lines
Quoted 5 lines
While I don't really care how you solve this technically, I'd *strongly* be interested for U-Boot to use *unmodified* lwIP sources where an explicit reference to an lwIP commit is used. I'd rather integrate bugfixes for U-Boot into lwIP than having the sources drift apart.
Strongly agree here, we want to use upstream and all the combined development and reviews etc rather than forking off and ending up with yet another slightly different IP stack. The whole advantage of adopting LWIP is the advantage of combined security, features and bugs from a wide range of projects :-)
Yes, this is what I want as well, and why I'm perhaps more agreeable with the approaches where it's a lot harder for us to start forking things unintentionally. I gather submodule rather than subtree would be better for that case?
Quoted 7 lines
Quoted 2 lines
--
TomYes, submodule will be a much better solution for us. And I also don't think that today there are any issues with submodules. It works well of OE, RPM and DEB builds, distributions should not have problems with it.
My particular experience is with coreboot. Some problems I have:
1. Updating the modules doesn't work and I need to reset, try the --init thing, fetch things manually, etc. etc.
2. In ChromiumOS coreboot we can't use submodules internally since each package has its own build script. E.g. we need to build coreboot separately from its blobs, fsp, external libraries, etc. At least there we can do this, but if U-Boot adopts a submodule for a core feature, this is going to create no end of problems.
3. It makes it impossible to patch lwip for any fix we need for a release
4. We still have to 'fast forward' to a new commit every now and then, which really is no easier than doing a merge commit for the changes since the last sync, is it?
Really, we need a maintainer for the lwip piece, if we are to adopt it. Using submodules is not a substitute for that.
Regards,
Simon
Quoted 74 lines · Simon Glass
Hi,
Quoted 24 lines · Maxim Uvarov
Quoted 20 lines · Tom Rini
Quoted 18 lines · Peter Robinson
Quoted 18 lines
Quoted 18 lines
Quoted 9 lines
Then if for development you need to pull he history of lwip, you can do it with:
git pull -s subtree lwip master --allow-unrelated-histories
(but I think nobody will need this.)New update of the lwip
net/lwip/lwip-externaldir will be done with:
git pull -s subtree lwip master --allow-unrelated-histories --squash Squash commit also has to be git format-patch friendly.If you are ok with that proposal I will send v9 with the first patch created with steps above.
We've gone through this before. The whole purpose of this is not having to maintain patches.
Simon, instead of "I had problems in the past", can you elaborate a bit more?Tom said he is fine with subtrees instead of submodules and I know for a fact EDK2 doesn't have too many issues with submodules. Their documentation is pretty clear on building and requires
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
git clone https://github.com/tianocore/edk2.git
cd edk2
git submodule update --initPerhaps the situation has improved since you had issues?
Nope.
Quoted 17 lines
Quoted 17 lines
Quoted 11 lines
Quoted 5 lines
While I don't really care how you solve this technically, I'd *strongly* be interested for U-Boot to use *unmodified* lwIP sources where an explicit reference to an lwIP commit is used. I'd rather integrate bugfixes for U-Boot into lwIP than having the sources drift apart.
Strongly agree here, we want to use upstream and all the combined development and reviews etc rather than forking off and ending up with yet another slightly different IP stack. The whole advantage of adopting LWIP is the advantage of combined security, features and bugs from a wide range of projects :-)
Yes, this is what I want as well, and why I'm perhaps more agreeable with the approaches where it's a lot harder for us to start forking things unintentionally. I gather submodule rather than subtree would be better for that case?
Quoted 7 lines
Quoted 2 lines
--
TomYes, submodule will be a much better solution for us. And I also don't think that today there are any issues with submodules. It works well of OE, RPM and DEB builds, distributions should not have problems with it.
My particular experience is with coreboot. Some problems I have:
1. Updating the modules doesn't work and I need to reset, try the --init thing, fetch things manually, etc. etc.
2. In ChromiumOS coreboot we can't use submodules internally since each package has its own build script. E.g. we need to build coreboot separately from its blobs, fsp, external libraries, etc. At least there we can do this, but if U-Boot adopts a submodule for a core feature, this is going to create no end of problems.
3. It makes it impossible to patch lwip for any fix we need for a release
4. We still have to 'fast forward' to a new commit every now and then, which really is no easier than doing a merge commit for the changes since the last sync, is it?
Quoted 2 lines
Really, we need a maintainer for the lwip piece, if we are to adopt it. Using submodules is not a substitute for that.
As an lwIP maintainer, I cannot step up as a maintainer of lwIP in U-Boot, however, I can assure you I will do my best to work with you on integrating fixes into upstream lwIP if required.
Without wanting to promote using submodules: all other examples of lwIP being copied into another repository have practically never resulted in bugfixes being sent back to us (ok, that's not 100% true, but we do get them only once in a while) and being like that, those projects are facing problems upgrading our stack in turn. I wouldn't want to be a maintainer of such code, either.
Regards,
Simon
Quoted 84 lines · Simon Goldschmidt
Quoted 74 lines · Simon Glass
Hi,
Quoted 24 lines · Maxim Uvarov
Quoted 20 lines · Tom Rini
Quoted 18 lines · Peter Robinson
Quoted 18 lines
Quoted 18 lines
Quoted 9 lines
Then if for development you need to pull he history of lwip, you can do it with:
git pull -s subtree lwip master --allow-unrelated-histories
(but I think nobody will need this.)New update of the lwip
net/lwip/lwip-externaldir will be done with:
git pull -s subtree lwip master --allow-unrelated-histories --squash Squash commit also has to be git format-patch friendly.If you are ok with that proposal I will send v9 with the first patch created with steps above.
We've gone through this before. The whole purpose of this is not having to maintain patches.
Simon, instead of "I had problems in the past", can you elaborate a bit more?Tom said he is fine with subtrees instead of submodules and I know for a fact EDK2 doesn't have too many issues with submodules. Their documentation is pretty clear on building and requires
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
git clone https://github.com/tianocore/edk2.git
cd edk2
git submodule update --initPerhaps the situation has improved since you had issues?
Nope.
Quoted 17 lines
Quoted 17 lines
Quoted 11 lines
Quoted 5 lines
While I don't really care how you solve this technically, I'd *strongly* be interested for U-Boot to use *unmodified* lwIP sources where an explicit reference to an lwIP commit is used. I'd rather integrate bugfixes for U-Boot into lwIP than having the sources drift apart.
Strongly agree here, we want to use upstream and all the combined development and reviews etc rather than forking off and ending up with yet another slightly different IP stack. The whole advantage of adopting LWIP is the advantage of combined security, features and bugs from a wide range of projects :-)
Yes, this is what I want as well, and why I'm perhaps more agreeable with the approaches where it's a lot harder for us to start forking things unintentionally. I gather submodule rather than subtree would be better for that case?
Quoted 7 lines
Quoted 2 lines
--
TomYes, submodule will be a much better solution for us. And I also don't think that today there are any issues with submodules. It works well of OE, RPM and DEB builds, distributions should not have problems with it.
My particular experience is with coreboot. Some problems I have:
1. Updating the modules doesn't work and I need to reset, try the --init thing, fetch things manually, etc. etc.
2. In ChromiumOS coreboot we can't use submodules internally since each package has its own build script. E.g. we need to build coreboot separately from its blobs, fsp, external libraries, etc. At least there we can do this, but if U-Boot adopts a submodule for a core feature, this is going to create no end of problems.
3. It makes it impossible to patch lwip for any fix we need for a release
4. We still have to 'fast forward' to a new commit every now and then, which really is no easier than doing a merge commit for the changes since the last sync, is it?Quoted 2 lines
Really, we need a maintainer for the lwip piece, if we are to adopt it. Using submodules is not a substitute for that.
As an lwIP maintainer, I cannot step up as a maintainer of lwIP in U-Boot, however, I can assure you I will do my best to work with you on integrating fixes into upstream lwIP if required.
Quoted 6 lines
Without wanting to promote using submodules: all other examples of lwIP being copied into another repository have practically never resulted in bugfixes being sent back to us (ok, that's not 100% true, but we do get them only once in a while) and being like that, those projects are facing problems upgrading our stack in turn. I wouldn't want to be a maintainer of such code, either.
So, ideally once we've integrated lwip, I'd be having us track the stable tags, rather than top of tree. Is this what you'd recommend, first of all? And second, assuming we can take STABLE_2_2_0 once it's released how often do you envision updates? I ask since maybe things do move slow enough that if I make some of my local every-time test scripts stop and confirm it's OK to have some changes to net/ (or where ever...) I can make sure we don't diverge and then like the calendar entries I do have to remind me to check with a resync to X I could do that for lwip.
Signature · 1 line
Tom