warning: format '%d' expects argument of type 'int', but argument 3 has
type 'size_t' {aka 'long unsigned int'} [-Wformat=]
Change the printf modifier to %zd for size_t variable will resolve the
warning.
Signed-off-by: Vijayakannan Ayyathurai <vijayakannan.ayyathurai@intel.com>
Default binding should take place before we actually make use of the
local address when registering packet socket "connection".
Also, instead of hard coding the protocol for default binding to
ETH_P_ALL, use the protocol that the socket was created with.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In order to be able to receive packets on unbound packet sockets (which
should collect packet from all interfaces in such case), it's needed to
register receive callback at the socket layer as soon as the socket is
created.
In additional to that, the default binding for packet sockets need to be
revisited. Packet socket should not be bound to the default interface,
as this way the socket would only be receiving packets from that
particular interface. Instead, leave the interface unspecified in such
case.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Allow to update the local address on a registered connection when
rebinding.
This is needed for packet sockets, as by default packet socket
will be bound to "any" interface (interface index 0), and interface
index is part of the local address registered for packet socket.
In order to be able to explicitly bind to a specific interface later, it
needs to be possible to update the local address registered for the
connection, as we need to update the interface index, which is used
by net_conn_packet_input() for packet filtering.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
keep_alive_timer_restart() only works in ESTABLISHED state. In
tcp_in() SYN_SENT and SYN_RECEIVED state, it won't work by calling
this function. So remove the call in that 2 states while adding it
in the bottom after changing the conn->state to ESTABLISHED.
Signed-off-by: Shrek Wang <inet_eman@outlook.com>
Slightly increase the default maximum size for zperf uploads to support
1kB of data payload together with the 40 bytes UDP client header.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Add support for uploading custom data, instead of a static packet of
'z'. This can be used for more accurate profiling of uplink throughput
for a given application. For example, reading data from flash, or
application level encryption.
Signed-off-by: Jordan Yates <jordan@embeint.com>
The timestamp in the UDP header is expected to be a Unix timestamp, not
an application uptime. Add the option to specify the Unix time at
function entry so that the reported timestamps are accurate.
Signed-off-by: Jordan Yates <jordan@embeint.com>
The minimum packet size is the combination of the datagram and client
headers, not just the datagram header.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Prevent the modulo operation causing a division by zero error by falling
back to the minimal ACK timeout value if the random factor is 1.0. Also
fall back to the same value if the random factor is erroneously smaller
than 1.0. Additionally make the upper bound of the random range
reachable.
Signed-off-by: Adrian Friedli <adrian.friedli@husqvarnagroup.com>
The _ is a reserved character in front of the symbols so remove
it from network management event macros. The remaining string
without the _ will identify the network API anyway so having
underscore there is not needed.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This adjust the IPv6 source address selection so that it is possible
to select deprecated IPv6 address if no better preferred address is found.
From RFC 6724 chapter 5:
Rule 3: Avoid deprecated addresses.
If one of the two source addresses is "preferred" and one of them is
"deprecated" (in the RFC 4862 sense), then prefer the one that is
"preferred".
Rule 8: Use longest matching prefix.
If CommonPrefixLen(SA, D) > CommonPrefixLen(SB, D), then prefer SA.
Similarly, if CommonPrefixLen(SB, D) > CommonPrefixLen(SA, D), then
prefer SB.
So the fix allows deprecated address to be selected if it is a better
match than the preferred one. The reasoning here is that an address with
a longer matching prefix is generally considered topologically closer to
the destination. Using such a source address can lead to more efficient
routing, as it's more likely that the source and destination are within
the same network segment or a closely related one.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Increased the heap mempool size for the socketpairs. This way there will
be enough memory available to allocate 2 * struct spair.
Signed-off-by: Ibe Van de Veire <ibe.vandeveire@basalte.be>
Make sure RS process is stopped if network interface goes down
as there is no point doing it any more.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
It might happen that if the network interface is going up/down
fast enough, the RS timer could get inserted to the active RS
timer list twice. This would then cause a forever loop in
rs_timeout() when traversing the active list.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Use -w option to delay the startup of the upload job.
Then when ready, do "zperf jobs start" to launch all upload
sessions at the same time.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If user has enabled CONFIG_ZPERF_SESSION_PER_THREAD, then if
user gives -a (async) option to upload command, then multiple
uploads can be run simultaneously. Each upload will be run
in a dedicated work queue. The work queue thread priority can
be set by -t option.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Shift the error handling for `ethernet_ll_prepare_on_ipv4` out into
`ethernet_send`, since that is the function that needs to handle the
various result types of the ARP process.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Make it clearer that the `net_buf_ref` is for `k_queue_unique_append`,
and reverse the reference if the queue add fails.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Update `net_arp_prepare` to return a return code instead of a pointer,
so that the various results of the function can be differentiated.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Print a warning if sending a packet on the L2 interface fails. Currently
this is completely silent unless `NET_DBG` is enabled and the `context`
parameter is provided.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Our decoder can handle decoding of non-deterministic CBOR just fine.
There is no need to block valid CBOR if the server does not produce
length-first deterministic CBOR.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
The new DSA framework purpose and changes are as below.
- Aligned to Linux DSA framework which has been already mature framework
for many years, For now in zephyr, the DSA components were splited
as: switch, port, master(not need driver file for now), slave, and tag.
Seperated drivers were used for maintaining and developing new
features.
- The unified dts bindings (aligned to linux) were supported. The port
driver would parse DTS to decide the port type (master port, slave
port, or cpu port) to set up the switch. All the ports registered as
standard ethernet devices. (dsa port and dsa switch tree was not
supported.)
- How to add DSA device driver based on the framework? All the device
driver needing to do is providing dsa_spi implementation and private
data, and calling below initialization.
DSA_INIT_INSTANCE(n, _dapi, data)
- For switch tag case, recv/xmit helpers in dsa_api could be used for
taging/untagging. No modified ethernet drivers.
For no-tag type case, ethernet driver of master port should support
packet injection/extraction for slave ports leaving NULL recv/xmit.
The dsa_nxp_imx_netc.c driver will be the first example of the new DSA
framework.
The future work for DSA will be supporting bridge for ports. We may align
Linux to give users two options to use DSA device:
- Standalone mode: the switch ports work as regular ethernet ports.
- Bridge mode: switch mode with virtual bridge device which could be
assigned IP address.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Current DSA TX/RX way was hard-coded in ethernet devices driver
with ETH_DSA_SUPPORT and NET_DSA.
This patch is to make such way obsolete, as we actually will support
a better DSA framework to handle this in NET/DSA core driver.
To make legacy devices not affected, below options are used instead.
- ETH_DSA_SUPPORT_DEPRECATED
- NET_DSA_DEPRECATED
Once the legacy devices are converted to new DSA framework, this code
could be removed.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Moved OpenThread-related Kconfigs from L2 layer to
modules/openthread. All of those configs were not strictly related
to the L2 layer, so they fits better to OpenThread module.
This operation allows using OpenThread Kconfigs even if L2 layer is
disabled.
Enabling NET_L2_OPENTHREAD also configures those configs by
selecting the OPENTHREAD kconfig, so there is no change regarding
backwards compatibility. The only change is that the Kconfigs
related to Thread were moved to the modules space, so their
location in the menuconfig also changed.
Once it is done, a choice for setting different L2 implementations
seems to be redundant.
Signed-off-by: Arkadiusz Balys <arkadiusz.balys@nordicsemi.no>
Make the zperf server support optional, if only upload throughput
testing is required. This reduces the resources required to operate.
Signed-off-by: Jordan Yates <jordan@embeint.com>
`NET_ZPERF` enables the core zperf utility library, not a shell module.
Add more specifics about what the utility can communicate with.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Part of the socket matching criteria for AF_PACKET family took place
inside conn_raw_socket() function, and some of it was redundant with
what already was checked in net_conn_packet_input(). Moreover, if the
packet cloning for packet socket failed for whatever reason, the packet
was reported as NET_DROP, which was confusing.
Finally, conn_raw_socket() updated network stats, which didn't really
work as net stats are only collected for UDP/TCP protocols and not for
L2 level protocols.
Therefore, cleanup the processing by:
* Moving all socket matching criteria into net_conn_packet_input()
for clarity,
* Drop unneeded net stats functions,
* Clarify NET_DROP strategy for packet socket input.
net_conn_packet_input() should only be responsible for delivering
packets to respective packet sockets, it should not decide whether
to drop the packet or not - it's L2/L3 processing code
responsibility. Therefore, assume this function forwards packet for
further processing by default, and only allow small optimization to
return NET_OK if the packet socket was really the only endpoint in
the system.
* And finally, since now conn_raw_socket() responsibility was to clone
the packet for the respective socket, and was almost identical to a
corresponding function for raw IP sockets, unify the two functions.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The current implementation of net_conn_input() can accept different
packet types, with completely different processing code, resulting in a
function which is pretty bloated, sliced with conditionally enabled code
and hard to understand and therefore maintain.
This commit splits that function into smaller ones, specialized for
different packet types (and entry levels). The following functions have
been extracted from the original one:
- net_conn_packet_input() for early packet processing (covering
AF_PACKET family sockets)
- net_conn_raw_ip_input() for raw IP packets processing (covering
AF_INET(6)/SOCK_RAW sockets)
- net_conn_can_input() for CAN packets processing (covering AF_CAN
family sockets)
The net_conn_input() function stripped from above cases now only takes
care of packets that have been processed by respective L4 and are
intended for regular TCP/UDP sockets.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
After L2 processing, the LL protocol type is already known and should be
set accordingly on the packet. Therefore it can be passed to the
net_packet_socket_input() function to allow proper socket filtering
based on protocol.
Additionally, as LL protocol type is 16 bit value, fix the proto
parameter type in net_packet_socket_input().
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Fix the zperf UDP datagram header definition, as iperf introduced a
backwards incompatible format change in version 2.0.10 (August 2017).
```
struct UDP_datagram {
// used to reference the 4 byte ID number we place in UDP datagrams
// Support 64 bit seqno on machines that support them
uint32_t id;
uint32_t tv_sec;
uint32_t tv_usec;
uint32_t id2;
};
```
Update the header to the new format, with a Kconfig option to fall back
to the previous header definition.
The response decoding was testd with a nRF7002 client and
`iperf-2.2.1-win64.exe` server, with the output statistics struct now
containing the same information as reported on the PC server.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Make sure that when sendto is being used without the socket being bound
before, a correct interface is used for transmission. As
zpacket_sendto_ctx() calls net_context_recv() to register receive
callback before sending, a default binding was used by the context
layer, which would bind the socket to the default interface. This could
lead to unexpected results, i.e. packet being sent on a default
interface, even though a different one was specified.
Make also sure that there is no ambiguity in the interface selection -
the application should be explicitly clear what interface it wants to
use when it comes to packet sockets. It's better to return an error if
no valid interface was specified.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
According to AF_PACKET man pages protocol number 0 is allowed, however
in such case the socket is only capable of transmitting packets then:
"If protocol is set to zero, no packets are received."
Therefore, allow to create sockets with such protocol, and at the
connection.c level filter out such sockets from data reception.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
RSA3K based certs are not supported on all platforms, so, keep both
variants, rsa2k (the older certs but with longer expiry 9999 days) and
rsa3k (latest ones) and we can have more variants in this folders.
Also, add a cmake variable to override the path with default as rsa3k.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Certificates usage depends on STA/AP mode, but we don't have that
information at a build time, so, make all certs as optional and if a
file isn't found then generate an empty header so that corresponding C
code will be built.
Any missing mandatory certificates will be validated before connection
and connection is failed.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Deletion of credential should use the pointer from the reference slot
not the temporary buffer, this causes a crash (unknown error).
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>