| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
| |
<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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
| |
Add ethernet code safe for being called from a poller.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
| |
__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_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>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
ifdown is the counterpart to ifup and disables one or all ethernet
interfaces.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
ifup usually takes an ethernet device, so use ethernet device completion
for the command.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
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>
|
|\ |
|
| |
| |
| |
| |
| |
| |
| | |
Additional to IPv4 addresses add support for global.net.server being a
hostname.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| | |
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>
|
|/
|
|
|
| |
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
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>
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
|\ \ |
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
|\ \
| |/
|/| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| | |
Signed-off-by: Oleg Karfich <oleg.karfich@wago.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|/
|
|
|
| |
Signed-off-by: Oleg Karfich <oleg.karfich@wago.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
| |
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
How to repropduce the unaligned store problem
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
Ooops, address error on store!
$ 0 : 00000000 00000000 01010600 697f2a2e
$ 4 : a0850000 00000000 0000001c a040c1b8
$ 8 : 00000000 00000002 00000002 00000000
$12 : 00000000 00000040 00000100 00000001
$16 : a040bba0 a0850000 a0850000 a0850000
$20 : 00000000 00000075 00000076 a040ba20
$24 : 00000002 a080f210
$28 : 00000000 a03ffce0 fffffffd a0833b8c
Hi : 000154f8
Lo : 20000000
epc : a0833b84
ra : a0833b8c
Status: 00000002
Cause : 80000414
Config: 80008482
### ERROR ### Please RESET the board ###
The unaligned store instruction is located in the bootp_request() from net/dhcp.c:
a0833b50 <bootp_request>:
..
a0833b7c: 3c020101 lui v0,0x101
a0833b80: 24420600 addiu v0,v0,1536 /* 0x1010600 -> v0 */
a0833b84: 0c20024a jal a0800928 <get_time_ns>
a0833b88: ae02002a sw v0,42(s0) /* store 0x1010600 to addr s0 + 42 */
This assembler code is generated by mips-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
from this:
bp = (struct bootp *)payload;
bp->bp_op = OP_BOOTREQUEST; /* 0x01 */
bp->bp_htype = HWT_ETHER; /* 0x01 */
bp->bp_hlen = HWL_ETHER; /* 0x06 */
bp->bp_hops = 0;
Compiler replaces four 'store byte' instruction by one 'store 32-bit word'
instruction. Alas sometimes this leads to unaligned store situation.
Making struct bootp __packed prevents this optimization and fixes the problem.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Tested-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When you have a static network environment but more than one network
device on your machine it is necessary to provide the <device> parameter
to the ip parameter at kernel cmd line.
The device name assigned by Linux cannot in general be predicted as it
depends on driver bind order.
This patch introduces a new property linux.devname to eth devices.
The value is added to bootargs per interface and can be changed in
env/network/INTF
Based on patch by Gavin Schenk <g.schenk@eckelmann.de>.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This provides a new way to configure network interfaces based
on nvvars. A network interface can now be configured with variables
in the nv.dev.<ethname>.* namespace. There is a new network device
parameter "mode" which specifies the mode used to obtain IP settings.
The mode can be "dhcp", "static" or "disabled":
nv.dev.eth0.mode=dhcp
(ipaddr, netmask are ignored in this setting)
nv.dev.eth0.mode=static
nv.dev.eth0.ipaddr=192.168.0.17
nv.dev.eth0.netmask=255.255.0.0
nv.dev.eth0.mode=disabled
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
| |
DHCP has a C API, so use it instead of running as command.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
| |
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
Now that we can do routing we no longer need a "current"
network device. Remove it.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
| |
The IP/netmask/gateway settings contain all informations
needed to pick the correct network device. This patch
adds support for that and makes specifying the "current"
network interface using the ethact command unnecessary.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The DHCP code is a mess. It is not clear which options are sent to the
server and which options are returned from the server. Also environment
variables are read from and written to all over the place.
This patch cleans this up. There now is struct dhcp_req_param which is
used for options sent to the server and struct dhcp_result which contains
the values sent from the server. The values from the server are written
to the barebox variables in a single place. Also it's now possible to
call the dhcp code without modifying barebox variables at all, storing
the result only in the dhcp result struct.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
Fix some spaces-before-function-opening-brackets and duplicate empty
lines.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
| |
Drop explicit casts to/from void pointers.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
| |
Instead of allowing to DHCP only on the "current" network
device, allow to specify the desired network device. This
is a first step to get rid of the concept of a "current"
network device.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|