This fix addresses wrong announce message length warning message.
TLV is a variable length (4+8N) based on the 802.1AS-2011 (table 10-8). In
Zephyr TLV is fixed to 12 bytes. TLV type and length are already taken
into account in the announcement message length.
Signed-off-by: Mario Paja <mario.paja@zal.aero>
The Zephyr's core ethernet code had to be adjusted to support setting T1S
PLCA parameters from user Zephyr programs.
Such approach allows more flexibility, as T1S network configuration;
especially PLCA node numbers, can be assigned not only via device tree
at compile time. For example user can read them from EEPROM and then
configure the network accordingly.
For now - the union in struct ethernet_t1s_param only consists of plca
structure. This can change in the future, when other T1S OA parameters -
like Receive/Transmit Cut-Through Enable (bits RXCTE/TXCTE in OA_CONFIG0
register) are made adjustable from user program.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
A recent iface lock removal in ed17320c3d
exposed issues with concurrent access on TX to drivers that are not
re-entrant.
Reverting that commit does not really solve the problem, as it would
still exist if multiple Traffic Class queues are in use.
Therefore, introduce a separate mutex for TX data path, protecting the
L2/driver from concurrent transfers from several threads.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Move the syscall_handler.h header, used internally only to a dedicated
internal folder that should not be used outside of Zephyr.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The stack size was previously hardcoded in the source code, making it
difficult to change when enabling options that require a larger stack.
Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
According to IEEE Std 802.1AS-2011 11.3.3, gPTP messages are not
VLAN-tagged.
Remove the use of VLAN headers for gPTP messages on the TX path.
The RX path is handled by the drivers. The network drivers in Zephyr
might need to be updated as well in order to accept receiving
non-VLAN-tagged gPTP messages when the CONFIG_NET_VLAN option is
selected.
Continue sending gPTP packets with VLAN tags when CONFIG_NET_GPTP_VLAN
is enabled. Specify that this option is for testing purposes.
Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
The previous implementation was setting priority 3 (Critical
applications) for Sync, Pdelay and Pdelay_Resp messages; and priority 6
(Internetwork control) for the other PTP messages. This might have been
done under the incorrect understanding that "Critical applications" was
the highest priority.
This resulted in the Pdelay_Resp_Follow_Up getting sent before the
Pdelay_Resp message when enough TC_TX queues were being used
(NET_TC_TX_COUNT >= 2), which is an inversion compared to the intended
order.
Invert the priority of the outgoing PTP packets so that the PTP event
messages are sent with higher priority, as was originally intended.
Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
rand32.h does not make much sense, since the random subsystem
provides more APIs than just getting a random 32 bits value.
Rename it to random.h and get consistently with other
subsystems.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
We must send the packet without queueing it. The pkt has already
been queued for sending, once by net_if and second time in the ARP
queue. We must not queue it twice in net_if so that the statistics
of the pkt are not counted twice and the packet filter callbacks
are only called once.
Fixes#62483
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Linuxptp report UTC offset is 9472 seconds, is a byte order issue,
The right value is 37. Also fixed offset_scaled_log_var byte order.
Signed-off-by: Chen Caidy <chen@caidy.cc>
According to IEEE802.1AS Table 11-6 and 10.6.2.2.9,
802.1AS using peer-to-peer delay mechanism, two-step clock,
Grand master clock should keep this correction_field as zero.
Signed-off-by: Chen Caidy <chen@caidy.cc>
According to IEEE802.1AS 11.4.4.2.1, we need fill
preciseOriginTimestamp as syncEventEgressTimestamp.
In this follow_up message, prec_orig_ts need to filled
from net_pkt_timestamp(sync) for best accuracy. state machine
is software trigger with insufficient precision.
After this change, a grand master endpoint sync accuracy
increase from 3.5ms to 580ns with mimxrt1050_evk board.
Signed-off-by: Chen Caidy <chen@caidy.cc>
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Until now iterable sections APIs have been part of the toolchain
(common) headers. They are not strictly related to a toolchain, they
just rely on linker providing support for sections. Most files relied on
indirect includes to access the API, now, it is included as needed.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
LLDP start timer is executed when iface is up
at startup, then once more when iface up event
is received.
When iface is up before net_lldp_init call, then multiple
entries are added to the lldp_ifaces related to the
same iface.
That leads to continuous loop execution within
lldp_tx_timeout.
This commit checks if lldp tx_timer_start is set and
doesn't append new entry into the slist.
The tx_timer_start is set at startup and reset on
down event.
Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
The arm-clang compiler/linker does not optimize away unused function
symbols and thus will error if symbols that are referenced are not
defined. To fix this add needed ifdef'ry.
Build various network samples that utilize ethernet but don't have
CONFIG_NET_PROMISCUOUS_MODE will get a link error for:
Error: L6218E: Undefined symbol
net_mgmt_NET_REQUEST_ETHERNET_SET_PROMISC_MODE
(referred from ethernet.o).
Fix by adding ifdef protection around promisc code.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
In the case of no ARP entry, the incoming packet is added to the ARP's
pending queue, while ARP is being resolved. Here a reference is taken
by the ARP layer to the packet to avoid it being freed, but the Ethernet
immediately puts down the reference and send the ARP packet to the
driver.
If the ARP request fails for some reason, L2 returns failure to net_if
which then puts down the reference and the packet will be freed as the
reference count is now zero.
But the packet is still in the ARP's pending queue and after timeout
ARP will put down the reference causing double free bus fault (double
free message is only seen if the CONFIG_NET_PKT_LOG_LEVEL_DBG is
enabled, so, a bit hard to debug.
Fix this by clearing the ARP entry and pending queue after taking a
reference and then free ARP packet, IP packets are either freed by ARP
pending queue drain or net_if layer.
Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
According to RFC3927, hosts with only IPv4 LL address should still be
able to send packets to destination w/o IPv4 LL address:
A host with an IPv4 Link-Local address may send to a destination
which does not have an IPv4 Link-Local address. If the host is not
multi-homed, the procedure is simple and unambiguous: Using ARP and
forwarding directly to on-link destinations is the default route
This behaviour however was not possible with Zephyr, which only allowed
to use IPv4 LL source address for IPv4 LL destinations.
Fix this, by introducing a final fallback (only if IPv4 autoconf is
enabled), to select IPv4 LL address as a source address if no other
address is available.
Additionally, modify the ARP routine a bit if IPv4 LL address is in use.
There's no really point to forward the packet to gateway if IPv4 LL
address is used, as such addresses are not routable. Instead, try to
find the peer in local network in such case.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The following fixes were applied:
- Multicast Rx packets stats were not recorded due not parsing the
ethernet header. The function that tried to parse the ethernet header
was parsing the ethernet packet beyond the ethernet header.
- Added a new stats for unknown protocol which gets updated when the
ethernet layer encounters an unknown ethernet packet type.
Fixes#53994
Signed-off-by: Chamira Perera <chamira.perera@audinate.com>
The L2 networking layer checks for return value from enable, but
Ethernet is not checking and always returns 0, so, relay the return
value from the Ethernet driver to networking stack.
This fixes the issue of interface start failing but interface still
being up.
Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
Setting a detected packet family (ipv4 or ipv6) in net_context level
instead in lower layers for AF_PACKET/SOCK_RAW/IPPROTO_RAW type sockets
when sending data.
Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
The IPv4 autoconfiguration feature relies on the fact, that autoconf
ARP packets are always prepared by the ARP module. After recent ARP
refactoring though that could no longer be the case due to packet
queueing mechanism. This could lead to net pkt leaks in the autoconf
module.
Fix this by skipping the pending packet queue for autoconf packets.
Since for autoconf ARP requests there's no really a pending packet
to queue, it can be safely avoided. This results in the ARP request
being always sent for the autoconf case, preventing the packet leak.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Setting the protocol type for raw IP packets to be sent so that they
can be passed to Ethernet.
Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
net_pkt_get_frag() and a few other functions did not specify the
allocated fragment length, incorrectly assuming that fixed-sized
buffers are always used.
In order to make the function work properly also with variable-sized
buffers, extend the function argument list with minimum expected
fragment length parameter. This allows to use net_buf_alloc_len()
allocator in variable buffer length configuration, as well as verify if
the fixed-sized buffer is large enough to satisfy the requirements
otherwise.
Update the existing codebase to provide the expected fragment length,
based on the context.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Align Ethernet/Wi-Fi drivers/L2 with interface state handling update.
For drivers, that did not support carrier detection, no changes are
needed.
Driver that did support carrier detection, are updated to set the
carrier state to OFF by default, instead of setting the
NET_IF_NO_AUTO_START flag. This allows to postopne the actual
NET_EVENT_IF_UP notification until driver detects that carrier is ready.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The bridge subsystem was written with a ETH_BRIDGE_INITIALIZER that
assumed it could initialize a k_mutex with a zero-filled initializer.
That never worked. Unlike semaphores, mutexes have always required a
runtime call to k_mutex_init(). What happened instead is that
k_mutex_un/lock() returned error codes, which were ignored by the code
here. So no locking was happening.
This was discovered while migrating to zync, where an attempt to
unlock an unlocked mutex is a panic condition (and where zero-filled
initializers are legal, but represent an unfair semaphore and not a
mutex, so deadlock correctly).
Signed-off-by: Andy Ross <andyross@google.com>
This fixes a bug with ARP and multiple outgoing packets with an IP
that needs to be resolved, causing the first packet to go out and
all others to be dropped after the timeout by having a FIFO of
pending packets instead of a single packet.
Signed-off-by: Jamie McCrae <spam@helper3000.net>
Wi-Fi protocol uses EAPoL ether type frames for authentication, so, add
support for that ether type so that they are not dropped.
Though we have NET_ETHERNET_FORWARD_UNRECOGNISED_ETHERTYPE to allow
unknown frames to be passed up the stack, but this might cause
performance penalty.
Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
The L2 protocol type information is not carried to the upper layers.
This is problematic for packet sockets, as the address structure in
recvfrom() is supposed to provide this information.
Fix this by adding ll_proto_type field in the net_pkt structure.
Set the protocol type in the Ethernet L2 when packet is processed.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
irq_lock() returns an unsigned integer key.
Generated by spatch using semantic patch
scripts/coccinelle/irq_lock.cocci
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Logging v1 has been removed and log_strdup wrapper function is no
longer needed. Removing the function and its use in the tree.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Add Kconfig option to the Ethernet L2 which allows to forward frames
with unknown EtherType further into the stack. This can be useful for
packet sockets, where further frame processing is application dependent.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In order to bring consistency in-tree, migrate all subsystems code to
the new prefix <zephyr/...>. Note that the conversion has been scripted,
refer to zephyrproject-rtos#45388 for more details.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
NSEC_PER_SEC is an unsigned integer macro. Thus, -NSEC_PER_SEC will be
treated as unsigned integer as well which lead to calculation error on
64bits integer variables. Added the correct type casting into the formula
to fix the calculation error.
Signed-off-by: Kweh Hock Leong <hock.leong.kweh@intel.com>
According to Kconfig guidelines, boolean prompts must not start with
"Enable...". The following command has been used to automate the changes
in this patch:
sed -i "s/bool \"[Ee]nables\? \(\w\)/bool \"\U\1/g" **/Kconfig*
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Fix#42800
Both pss->rate_ratio and port_ds->neighbor_rate_ratio are double type
but sync_receipt_time is uint64_t. If pss->rate_ratio is less than 1
or sync_receipt_time * port_ds->neighbor_rate_ratio is less than 1,
sync_receipt_time becomes 0 due to double to uint64_t cast.
Assign port_ds->neighbor_prop_delay to sync_receipt_time first to fix
this issue.
Signed-off-by: Lu Ding <lucasdinglu@gmail.com>
correction field in sync follow up message must be converted from host
endianness to network endianness.
Signed-off-by: Lu Ding <lucasdinglu@gmail.com>
The comment before this change was misleading, as those functions
(and other ones used from the level of user space application) require
DSA interface (like lan{012}), not the master one (like eth0).
Signed-off-by: Lukasz Majewski <lukma@denx.de>