summaryrefslogtreecommitdiffstats
path: root/net
Commit message (Collapse)AuthorAgeFilesLines
* treewide: add SPDX-License-Identifier for files without explicit licenseAhmad Fatoum2022-01-052-0/+4
| | | | | | | | | Record GPL-2.0-only as license for all files lacking an explicit license statement. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220103120539.1730644-12-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: add SPDX-License-Identifier for Kbuild/KconfigAhmad Fatoum2022-01-052-0/+4
| | | | | | | | | | | | | | | To verify only Kconfig/Makefile is touched: git show --numstat --format=oneline HEAD | grep -v 'Kconfig\|Makefile' will print only arch/powerpc/Kbuild. To verify nothing unexpected is added: git show -U0 | grep '^-[^-]\|^+[^+]' | sort -u Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220103120539.1730644-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: dhcp: set default DHCP vendor ID to "barebox"Oleksij Rempel2021-10-051-0/+2
| | | | | | | | | To make debugging of DHCP related issues easier, set DHCP vendor ID to "barebox" by default. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20210914064853.2808775-1-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: dhcp: send current hostname as part of the DHCP requestOleksij Rempel2021-10-051-0/+8
| | | | | | | | | | | | To be able to use more advanced DHCP server configurations, for example host name pattern matching, barebox should send some name. With this patch, barebox will send barebox_hostname, if dhcp.hostname is not configured. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20210914063001.2803749-1-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fastboot net: add setter for global.fastboot.net.autostartMarco Felsch2021-08-231-6/+13
| | | | | | | | | | | | | | Without this change the only possible way to start the fastboot.net.autostart mechanism is by using the nv storage. Split fastboot_on_boot() into two functions: - a globalvar setter fastboot_net_autostart_set() and - a the globalvar init function fastboot_net_init_globalvar(). This allows init scripts to start the autostart mechanism as well. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210813083221.31763-1-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: consult device tree for ethernet address in NVMEM as fall-backAhmad Fatoum2021-06-221-0/+24
| | | | | | | | | | | | | | | | | | | | | While barebox fixes up the mac-address into the device tree, it doesn't care much for extracting a mac address _from_ the device tree, whether it be from local-mac-address property or from a mac-address nvmem cell. Fix the latter by calling of_get_mac_addr_nvmem for each Ethernet adapter. We do this in a very late initcall, because we don't want to enforce a probe a probe order between nvmem providers and network devices. We can't do it at randomization time, because we need to fixup Ethernet mac addresses, even when barebox itself doesn't ifup the netdev. of_get_mac_addr_nvmem could be replaced by of_get_mac_address to also parse local-mac-address and brethern, but justifying this change is left as a future exercise. Cc: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210619034516.6737-13-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: dns: use correct nameserver var name in error messageAntony Pavlov2021-05-251-1/+1
| | | | | | | | | | The commit d5d342d26368c1 ("net: Make domainname and nameserver globalvars") changes net.nameserver variable name to global.net.nameserver. This commit changes the variable name in the error message too. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Link: https://lore.barebox.org/20210525062133.5458-1-antonynpavlov@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/usb-gadget'Sascha Hauer2021-05-172-4/+1
|\
| * fastboot/dfu: use system partitions as fall backAhmad Fatoum2021-05-121-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Use the new system partitions infrastructure to have fastboot and DFU fall back to using the same partitions if the global.usbgadget.dfu_function and global.fastboot_partitions are not set, respectively. No functional change intended for configurations that have SYSTEM_PARTITIONS disabled. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210503114901.13095-13-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * common: make FILE_LIST feature unconditionalAhmad Fatoum2021-05-121-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | CONFIG_FILE_LIST controls whether the file_list_* family of functions are compiled. common/file-list.o does not register any initcalls and there is no code that is dependent on it being available: it's selected as required. This means linker GC can completely get rid of it if required, so drop the symbol. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210503114901.13095-16-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Removed Unreachable code: net/net.c: net_handle_arp()Neeraj Pal2021-05-121-2/+0
|/ | | | | | Signed-off-by: Neeraj Pal <neerajpal09@gmail.com> Link: https://lore.barebox.org/20210508193654.81389-1-neerajpal09@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: eth: of_fixup_node: Use reproducible node name for fixupStefan Riedmueller2021-03-301-6/+10
| | | | | | | | | To be able to fixup older devicetrees, prior to v4.15 where leading zeros of the unit addresses were removed, use the reproducible name to find the corresponding nodes. Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: include <linux/math64.h> wrapper instead of <asm-generic/div64.h>Ahmad Fatoum2021-02-191-1/+1
| | | | | | | | | | | <asm-generic/div64.h> isn't meant for direct usage as <asm/div64.h> may override this on a per-architecture basis. We don't do that currently, but in the future we might. Include the <linux/math64.h> instead. No functional change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: introduce unsetenv() to prepare for changing setenv(var, "") behaviorAhmad Fatoum2020-11-231-1/+1
| | | | | | | | | | | | | | | | | Currently, we treat setenv(var, "") and setenv(var, NULL) the same and delete var, which is surprising and leads to subtle quirks: - setenv(var, "") is specified by POSIX to set var to an empty string, but barebox uses it to delete variables - nv.user= calls nv_set with NULL parameter, but nv user="" doesn't Make the API more POSIX-like by providing unsetenv with the expected semantics. Most user code can then use unsetenv without worrying about whether "" or NULL is the magic deletion value. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Replace license and copyright boilerplate by SPDX identfiersUwe Kleine-König2020-11-028-113/+30
| | | | | | | | | Converts the files that licensecheck can determine to be licensed under GPL-2.0-only or GPL-2.0-or-later and also convert the copyright statements to SPDX. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* magicvar: Replace BAREBOX_MAGICVAR_NAMED with BAREBOX_MAGICVARSascha Hauer2020-10-024-19/+17
| | | | | | | | BAREBOX_MAGICVAR now generates a unique identifier automatically, so we can convert users of BAREBOX_MAGICVAR_NAMED to the simpler BAREBOX_MAGICVAR macro. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fastboot net: implement fastboot over UDPEdmund Henniges2020-08-193-0/+594
| | | | | | | | | | | | | | This implements the UDP variant of the fastboot protocol. The only way to start the service for now is to compile with CONFIG_FASTBOOT_NET_ON_BOOT. The service will bind to the network interface that provides the IPv4 gateway. Sending an OKAY packet before performing a restart is necessary since contrary to USB the host will not notice when a UDP server disappears. Signed-off-by: Edmund Henniges <eh@emlix.com> Signed-off-by: Daniel Glöckner <dg@emlix.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: reply to ping requestsSascha Hauer2020-08-191-2/+44
| | | | | | | Now that we have the network receive function running in a poller we can reasonably well answer to ping requests. Implement this feature. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Call net_poll() in a pollerSascha Hauer2020-08-193-5/+60
| | | | | | | | | | | | | | | This adds calling of net_poll() in a poller. With this we can react to incoming packets like ping requests or fastboot requests. We could change to call net_poll() from a poller exclusively, but this would significantly slow down USB network controllers. As described in the patch these take a long time in the packet receive path. To work around this we keep the networking users call net_poll() at a high rate when they are waiting for incoming packets and only every 10ms we call net_poll() from a poller to get incoming traffic when no networking protocol is actively calling net_poll(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Add a slice to struct eth_deviceSascha Hauer2020-08-191-2/+72
| | | | | | Add ethernet code safe for being called from a poller. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: eth: rename __eth_rx()Sascha Hauer2020-08-191-4/+4
| | | | | | | | | __eth_rx() not only receives packets but also checks the carrier. In the next steps it will also send the queued packets, so rename the function to eth_do_work(). Also return void as the only caller can't do anything with the return value. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: Fix out of bounds readSascha Hauer2020-06-031-1/+3
| | | | | | | | | nfs_read_reply() interprets the fields of an incoming packet directly as a field length without checking the boundaries. Clamp the maximum length to the packet length to avoid reading out of bounds. Reported-by: Jai Verma <jai2.verma@outlook.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: remove references to CREDITSUwe Kleine-König2020-04-276-18/+0
| | | | | | | | The CREDITS file was removed from barebox in 2015 by commit 6570288f2d97 ("Remove the CREDITS file"). Remove references to it from several files. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Add ifdown support and commandSascha Hauer2020-03-311-0/+69
| | | | | | | ifdown is the counterpart to ifup and disables one or all ethernet interfaces. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: ifup command: add ethernet device completionSascha Hauer2020-03-311-0/+2
| | | | | | | ifup usually takes an ethernet device, so use ethernet device completion for the command. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Open ethernet devices explicitlySascha Hauer2020-03-313-27/+36
| | | | | | | | Open ethernet devices explicitly rather than implicitly when sending packets. This allows us to not only enable, but in the next step to also disable ethernet devices. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: nfs: Fix possible buffer overflowSascha Hauer2019-09-021-1/+4
| | | | | | | | nfs_readlink_reply() interprets a 32bit value directly received from the network as length argument to memcpy() without any boundary checking. Clamp the copy size at the end of the incoming packet. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/net'Sascha Hauer2019-01-153-12/+32
|\
| * net: Allow hostnames for global.net.serverSascha Hauer2019-01-042-7/+16
| | | | | | | | | | | | | | Additional to IPv4 addresses add support for global.net.server being a hostname. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * net: dns: Allow to set variable with the resolved hostSascha Hauer2019-01-041-4/+10
| | | | | | | | | | | | | | Add an additional [VARIABLE] parameter to the host command to allow setting a variable with the resolved IP address. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * net: dns: leave host command with error on failureSascha Hauer2019-01-041-4/+9
| | | | | | | | | | | | | | When we can't resolv a host we should return an error rather than just successfully. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: lib: Make use of ETH_ALENAndrey Smirnov2018-12-101-4/+4
|/ | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: dns: return error codesSascha Hauer2018-11-295-23/+35
| | | | | | | | | | | | | | The resolv() function used to return the IP address. When net_udp_new() fails we return an error code though which the callers of resolv() take as an IP address. This is wrong of course and we could return 0 in this case. Instead we return an error code and pass the resolved IP as a pointer which allows us to return proper error codes. This patch also adds error messages and error returns to the various callers of resolv() which used to just continue with a zero IP and let the user figure out what went wrong. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ping command: Print which host is pingedSascha Hauer2018-11-291-0/+2
| | | | | | | | When a hostname instead a IP is given to the ping command then the IP the host is resolved to is a useful information. Add a message printing it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: dns: Use pr_debugSascha Hauer2018-11-291-12/+15
| | | | | | | | Use pr_debug rather than debug and add a pr_fmt string to give the messages more context. While at it add a debug message which prints the ip when successfully resolved. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/net-switch-mv88e6xxx'Sascha Hauer2018-11-091-1/+1
|\
| * drivers: Introduce dev_set_name()Andrey Smirnov2018-10-181-1/+1
| | | | | | | | | | | | | | | | Introduce dev_set_name() in order to hide implementation details of setting device's name so it'd be easier to change it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/net'Sascha Hauer2018-11-091-0/+1
|\ \
| * | net: only use ethaddrs registered with device node on that deviceLucas Stach2018-11-081-0/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | If an ethaddr is registered with a device node the ethid is set to 0 via the struct initialization. Now if a device without a node (for eaxample a USB network adapter) with ethid 0 looks up the ethaddr it will wrongly get that address assigned, as the ethid matches. Avoid this by setting the ethid to something that no device will ever use when the addr is registered via a device node. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2018-11-091-3/+3
|\ \ | |/ |/|
| * net: dhcp: fix option 54Marcin Niestroj2018-10-261-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Option 54 (Server Identifier) is something different than SIADDR (Server IP address). Currently they are used interchangeably. This causes DHCPNAK with DHCP servers that have configured different values for each field. Create new 'dhcp_serverip' field in 'struct dhcp_result', so we treat option 54 separately. This fixes DHCP requests for servers that send two different values for SIADDR and option 54 in DHCPOFFER. Fixes: 528298b702a0 ("net: dhcp: rework") Fixes: e18cc5b7e9ce ("DHCP: fix option 54 passing") Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: make routing work after dhcp commandAntony Pavlov2018-10-161-0/+3
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At the moment only ifup stuff turns netif up. After the commit f0624a701513 ('net: Do not route traffic to interfaces that are not up') the dhcp command keeps netif->ifup == false and network subsystem can't route packets. How to repropduce the problem on qemu-malta_defconfig: qemu-system-mips -nodefaults -M malta -m 256 \ -nographic -serial stdio -monitor null \ -bios barebox-flash-image \ -net user -net nic,model=rtl8139 ... barebox:/ dhcp eth0: 100Mbps full duplex link detected eth0: DHCP client bound to address 10.0.2.15 barebox:/ ping 10.0.2.2 ping failed: No route to host However if ifup command is used for network interface configuration then there is no network problem, e.g. barebox:/ ifup eth0 eth0: 100Mbps full duplex link detected eth0: DHCP client bound to address 10.0.2.15 barebox:/ ping 10.0.2.2 host 10.0.2.2 is alive Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> CC: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2018-09-111-1/+1
|\
| * net: Do not route traffic to interfaces that are not upAndrey Smirnov2018-08-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the case when: - Board has multiple network interfaces - Two ore more of those interfaces are statically configured to be on the same network - Only one of those interfaces is up and it is preceeded (as far as for_each_netdev is concerned) by interface in the same network that isn't net_route() will choose "non-up" device as a route for traffic resulting in no network connectivity. Change the routing logic to also consider if interface is "up", so that only such interfaces would be considered for sending network traffic out. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: dhcp: add global variable for retriesOleg.Karfich@wago.com2018-09-041-1/+3
| | | | | | | | | | Signed-off-by: Oleg Karfich <oleg.karfich@wago.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: dhcp: use private extension 224 also in discover requestsOleg.Karfich@wago.com2018-09-041-0/+7
|/ | | | | Signed-off-by: Oleg Karfich <oleg.karfich@wago.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: eth: Make use of ETH_ALENAndrey Smirnov2018-08-101-7/+7
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: use dev_warn() when no MAC address is setVivien Didelot2018-05-221-1/+1
| | | | | | | | | | | | | | | | | | | When a SoC such as VF610 has no addresses programmed for both its interfaces, the "No MAC address set" warning can be confusing: booting 'net' WARNING: net: warning: No MAC address set. Using random address a2:e8:be:79:72:01 WARNING: net: warning: No MAC address set. Using random address aa:d5:d7:10:c0:42 This patch uses dev_warn() instead and removes the redundant "warning": booting 'net' WARNING: eth0: No MAC address set. Using random address a2:e8:be:79:72:01 WARNING: eth1: No MAC address set. Using random address 4e:be:c4:bc:ce:36 Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Acked-by: Sam Ravnborg <sam@ravnborg.org>
* net: on ifup -a only detect devices when necessarySascha Hauer2018-04-091-1/+20
| | | | | | | | | | | | | | | | For network boot we once used to hardcode eth0, but in latest changes this was changed to work with different network devices and the 'ifup eth0' was replaced with 'ifup -a' which lead to the result that we now detect all devices in order to eventually also bring up USB network adapters. In most of the cases this is not desired. When a board has internal network support this is likely to be used. With this patch we only detect all devices when we do not have a network device already. For the unusual case in which a USB network adapter shall be used even when an internal network interface is present we introduce the global variable "global.net.ifup_force_detect" which can be used to force detection of devices. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* DHCP: fix option 54 passingYegor Yefremov2018-02-221-5/+2
| | | | | | | | | | | | | | | Though variable net_dhcp_server_ip was declared and used as a function parameter it was never assigned. That's why a DHCP request was sent without option 54 set. Some DHCP server for example dnsmasq didn't accept such a packet. As both offered IP address and server IP are stored in the global dhcp_result structure we don't need either net_dhcp_server_ip or OfferedIP variables and can use the addresses from dhcp_result directly. Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>