| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
| |
len is the size of the ICMP echo request and the ICMP echo response will
have the exact same size, but the code erroneously, copied ETHER_HDR_SIZE
bytes worth of extra data beyond the buffer and sent that out.
Fix this by using the correct length.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20240404184001.1532897-6-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We shouldn't keep using the TTL value of the ICMP echo request,
as we are sending a fresh packet, therefore restore it to the maximum
value.
While at it, also fix the frag_off field: A fragment offset of 0 on its
own doesn't mean that there's no fragmentation, but that this is the
first fragment. Writing 0x4000 there sets the "Don't fragment" bit,
which we are already setting for all other IP communication and should
be setting here as well.
Suggested-by: Jan Lübbe <j.luebbe@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20240404184001.1532897-5-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The barebox network stack calls ping_reply() to handle ICMP echo
requests. The function copies destination addresses to source addresses,
fixes up some fields, recalculates checksums and then sends back the
ICMP echo response.
There are two checksums involved: The IP checksum over the IP header and
the ICMP header spanning the ICMP payload, which extends to the end of
packet.
The number of bytes that the ICMP checksum should be computed for was
being calculated as total_size_reported_by_nic - iphdr_size - ethhdr_size.
This is wrong as it assumes that the IP payload extends until the end of
packet. There are multiple reasons this may not be the case:
- The packet is smaller than the minimum and is thus padded.
- The sender adds trailing bytes after the IP payload for no reason.
- The network driver reports a wrong size, because it doesn't
correctly handle extra bytes added by hardware checksum offloading.
The last one affects the barebox cpsw and smsc95xx drivers, which will
be fixed up in follow-up commits.
The proper solution is to use the same length for the payload and
for its checksum. Do this by using the new ip_verify_size(), which will
take care to fix up the size discrepancy.
This issue was found by trying to ping a Raspberry Pi 3b running barebox
sitting behind a router employing conntrack, which apparently discarded
the ping responses due to the wrong ICMP checksum. These issues did not
occur without such a router in-beween, because the ping command itself
doesn't bother to verify the checksum.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20240404184001.1532897-4-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We currently assume that the size reported by the network driver
reflects the number of bytes actually transmitted over the wire, but
this is apparently not always the case, at least for the barebox cpsw
and smc95xx drivers. These don't handle hardware checksum offloading
correctly and thus pass extraneous checksum bytes inserted by the
hardware to the network stack as if these were part of the transmitted
frame.
These drivers will be fixed in follow-up commits, but on the off-chance
more drivers are affected, let's use the size reported in the IP header
when doing IP packet processing.
As the old size is needed to dump the packet in net_bad_packet(), this
is moved inside the new function.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20240404184001.1532897-3-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
| |
While ultimately the same (net_free_packet == dma_free == free), this
will not necessarily be always the case, so let's use the dedicated
net_free_packet function to free the packets.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20240404184001.1532897-2-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
| |
Now that no in-tree user of NetRxPackets remain, no one will miss this
remnant of simpler times.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20240313110704.1095554-8-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
| |
We have a number of drivers that call net_alloc_packet in a loop and
will gain some more in the quest to drop NetRxPackets.
Let's provide a helper that can be used for this and a function to free
the packets as well.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20240313110704.1095554-2-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
Now that we can print MAC addresses using the %pM format specifier we
can get rid of ethaddr_to_string(). Do this treewide.
Link: https://lore.barebox.org/20240202151147.226876-2-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Especially during development, devices often lack a MAC address. While a
MAC address can be easily added to the environment:
nv dev.eth0.ethaddr="aa:bb:cc:dd:ee:ff"
It's easily lost when flashing complete new images, e.g. from CI.
Make the development experience neater by deriving a stable MAC address
if possible.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20231122094747.340825-3-uwe@kleine-koenig.org
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It's possible to request very large messages using
the current code base. F.ex. UDP datagrams with the tftp client.
The tftp servers will happily reply with fragmented IP frames.
All these frame parts need to be dropped as BB currently doesn't
do fragment reassembly.
The current check was for fragment offsets only (0x1fff).
But the first frame has fragment offset 0 and would slip through
this check. That could result in a seemingly OK frame
for the tftp client, but with broken data.
Add check for the MF (More Fragments) flag. Should cover the
first packet too.
Signed-off-by: Christian Melki <christian.melki@t2data.com>
Link: https://lore.barebox.org/20230704175535.1183448-1-christian.melki@t2data.com
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The normal use case for ifup -a is to get *some* interface working and
not really wait for all interfaces to come up and then timeout waiting
for those without link up to never get a DHCP lease.
When using automounts with a previously empty $global.net.server, we
know this to be the case, because the first DHCP interface will set the
variable and all remaining ones won't affect this. Therefore, let's add
a ifup -a1 option, which would stop after $global.net.server was set via
DHCP. This is a special case of a possible future ifup -ar, which would
check after each ifup if $global.net.server was either newly set or
became resolvable, but that would be a bigger change, so we skip that
for now.
Times after eth_open_all has brought up CPU Ethernet and 4 DSA ports:
barebox$ time ifup -a
time: 10002ms
barebox$ time ifup -a1
time: 1072ms
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20230130072057.34349-3-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
We populate ret, but don't do anything with it. Pass it along instead.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220905095557.596891-32-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
| |
It is kind of tcpdump or tshark for barebox. Instead of starting
application it will let barebox dump everything to the console by still
allowing to use other application.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Link: https://lore.barebox.org/20220413082205.429509-15-o.rempel@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
| |
Add callback for optional rx_preprocessor. This is needed to add DSA
switch support and demultiplex traffic received from different switch ports.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Link: https://lore.barebox.org/20220413082205.429509-2-o.rempel@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
Additional to IPv4 addresses add support for global.net.server being a
hostname.
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
This allows the DHCP code to configure specific network
devices so that DHCP no longer depends on any "current"
network device.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There is not much point in having a network device specific
gateway. If barebox really is part of such a complicated network
in which it needs multiple gateways, then we probably need a
real routing table. Until this happens, a single gateway should
be enough.
This introduces global.net.gateway which holds the gateway ip. The
previously used device specific <ethx>.gateway variables still exist,
but are only aliases for the single gateway.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Some DHCP servers provide the wrong serverip in which case
it is desired to specify it manually and won't let the dhcp
command overwrite it.
This has previously been done by setting the serverip again
to the desired value after dhcp has been executed. With this
patch we do not overwrite it in the first place if it is valid
already. This is necessary when the serverip is not set via
/env/network/eth* but via nv.net.server.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
| |
The server to use is independent of the network device, there is
not much point to make the server specific to a network device.
This introduces global.net.server as the serverip which is
used as standard NFS/tftp server. The previously used eth
device specific parameters still exist, but are only aliases
for the global single variable.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
| |
It's more convenient to have getter/setter functions for
variables rather than using the detour around global vars
which use string matching and all kinds of overhead in the
background.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
| |
Register domainname and nameserver as globalvars rather than attaching
them to a dedicated net device. the global device already exists and
already contains much of the barebox configuration, so no need to add
an extra device for network config.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
Rather than using the hardcoded value 0xffffffff in several places
add a define for the broadcast IP.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
Use pr_* functions in the networking code rather than printf() and
debug(). Also Add a "net: " prefix to messages to give them some more
context.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
dev_add_param_string allows to pass a priv * so that the device_d *
argument is not needed and can be removed later.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
Convert users of ip_to_string() and print_IPaddr() to %pI4 and
remove the now unused functions.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
| |
The caller already has the correct network device, so pass it
to net_answer_arp() rather than using eth_get_current() there.
This is a step towards making a global current network device
unnecessary.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
| |
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
Some network related functions are also needed when networking
is disabled. Move these to a separate file which is always compiled.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
| |
register_preset_mac_address only works when CONFIG_PARAMETER
is enabled because otherwise dev_set_param is a no-op. Add a
function to set the MAC address explicitly without the need
of CONFIG_PARAMETER and use it where appropriate.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|\
| |
| |
| |
| | |
Conflicts:
drivers/net/dm9k.c
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
In barebox network packets always go out at the current ethernet
device and are expected to be received from the current interface.
This has some side effects. When for example an NFS is mounted when
one interface is active and the interface is changed afterwards the
NFS packets leave the new interface, but the NFS server won't be
reachable there.
Instead of changing the whole network traffic to the current ethernet
interface we now initialize a network connection with the current
network interface, but then the connection will continue to use that
interface even when the current interface is changed.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
| |
| |
| |
| |
| |
| |
| | |
So that barebox has the information which interface a packet
came from.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|/
|
|
|
|
|
|
|
| |
"ifconfig" and "ip" from normal Linux userspace shows ethernet addresses
normally in lowercase. And the %pM format specifier in Linux does that,
too. Conform to this custom formatting.
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
| |
Return a proper error code instead of -1 which would be -EPERM.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
| |
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
| |
Checksum calculation on data including its own checksum (as is the case with
IP headers) should give 0xffff before bit flipping. Current code works well
for the correct checksum case, but fails to identify errors.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
Rather than storing the parameters globally and trying to keep them
in sync with the device parameters, store the parameters in the ethernet
device directly. Also, update to dev_add_param_ip().
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
| |
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|\
| |
| |
| |
| |
| | |
Conflicts:
drivers/net/miidev.c
include/miidev.h
|