When we are about to send a NS, we should not use the destination
address as that is typically the multicast address. We should use
the target address instead.
This fixes the case where a neighbor is in incomplete state, and
we send a neighbor solicitation to find out whether the neighbor
is reachable. In this case the destination address is the solicited
node multicast address which is no use when trying to figure out
the source address.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit fixes a problem where our own IP address
is added to the cache instead of the senders.
This bug was due to a swap of the address in the original packet.
The swapping of the address is now removed.
Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
A neighbor solicitation packet for an address that is not ours should
not cause the sender to be added to the neighbor cache. See RFC 4861
section 7.2.3.
Add the neighbor to the cache when we have decided to respond to the
NS packet.
Fixes#21869.
Signed-off-by: Jonas Norling <jonas.norling@greeneggs.se>
Use the same code when parsing source link-layer address option for
both RA and NS packets. It looked like handle_ns_neighbor() could
actually read too much data into lladdr.addr when handling 8-byte
addresses (802.15.4).
Signed-off-by: Jonas Norling <jonas.norling@greeneggs.se>
Setting it to UINT32_MAX, as it is subsequently overwritten with
MIN(oldest, something_else).
Signed-off-by: Piotr Zierhoffer <pzierhoffer@antmicro.com>
This commit changes the Link-Layer Address Option length calculation
from hardcoded values to a numerical rounding up to full 8.
The length is calculated according to rfc4861 section 4.6.1.
Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
The network to host byte order conversion is actually in place
on the network buffer. This prevents the reuse and forwarding of
RA packets. This commit uses temporary variables instead.
Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
Take the targer link layer address option link laxer addres lenght
from net packets source addres instead if the interface.
This is usefull for 6LoCAN border translator (6LoCAN to Ethernet).
Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
This commit is an implementation of 6LoCAN, a 6Lo adaption layer for
Controller Area Networks. 6LoCAN is not yet standardised.
Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
This reduces the size of struct net_if_ipv6 by 24 bytes by moving
the k_delayed_work attribute into net_if core code.
Then each net_if_ipv6 can be added to the timer handler via a slist.
This does not make much gain if the system has only 1 network interface
It starts to be interesting if it has 2+ network interfaces then.
Fixes#8728
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Provide access functions for manipulating network interface flags.
There is no need for the caller of this API to know about the inner
details of the flags.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This patch fixes following issues.
* If IPv6 neighbor table is full, stack can not add any new
neighbors. So stale counter is introduced. Whenever neighbor
enters into STALE state, stale counter will be incremented
by one. When table is full and if stack wants to add new
neighbor, oldest neighbor in STALE state will be removed
and new neighbor will be added.
* When neighbor is in PROBE state and when it exceeds max
number of PROBEs, only neighbor with router is removed.
As per RFC 4861 Appendix C, entry can be discarded. Now
neighbor will be removed from the table.
* Reachability timer has an issue. e.g. if a first entry timer
is 10 seconds, after 3 seconds, a new entry added with
only 3 seconds. But current implementation does not check
whether remaining time of current left over timeout is more
than new entry timeout or not. In this example, when new entry
timeout is 3 seconds, left over timeout from first etnry is
still 7 seconds. If k_delayed_work_remaining_get() returns
some value then new entry time out was not considered.
Which is bad. It fixed now.
* nbr_free is used sometimes to remove the neighbor. Which does
not remove route if that particulat neighbor is route to some
other neighbor. net_ipv6_nbr_rm() should be used in such places.
* Trivial changes which does not affect functionality.
Fixes#14063
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
In case of Ethernet for instance, the MTU is larger than the minimal
IPv6 MTU, so it is not required to fragment a packet that fits in
Ethernet MTU.
Fixes#14659
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Now that legacy - and unrelated - function named net_pkt_get_data has
been removed, we can rename net_pkt_get_data_new relevantly.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Also, return a verdict instead of a pointer to net_pkt. It's simpler as
it will be up to net_send_data()'s caller to unref the net_pkt in case
of NET_DROP: less places where net_pkt can be unref.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Reworking the logic to reduce the amount of variables.
This part was heavier to change as it was not accessing the headers
directly but instead was read parts by parts.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Reworking the logic to reduce the amount of variables.
Also taking the opportunity to normalize drop messages.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
In nbr part, this is a useful information. Since net_icmpv6_input has
already parsed the icmpv6 header, let's get pass it, instead of
retrieving/parsing it again in various handler functions.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
And let's use net_ipv6_create, net_icmpv6_create, net_ipv6_finalize to
factorize the code better.
Removing useless setup_headers private function now.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
And let's use net_ipv6_create, net_icmpv6_create, net_ipv6_finalize to
factorize the code better.
De-clutter the code by reordering where src/dst are evaluated.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
And let's use net_ipv6_create, net_icmpv6_create, net_ipv6_finalize to
factorize the code better.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This is meant to remove the need for macro NET_IPV6_HDR(), since we
don't know in future if accessing the header that way will be valid.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Remove network specific default and max log level setting
and start to use the zephyr logging values for those.
Remove LOG_MODULE_REGISTER() from net_core.h and place the
calls into .c files. This is done in order to avoid weird
compiler errors in some cases and to make the code look similar
as other subsystems.
Fixes#11343Fixes#11659
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Unify the function naming for various network checking functions.
For example:
net_is_ipv6_addr_loopback() -> net_ipv6_is_addr_loopback()
net_is_my_ipv6_maddr() -> net_ipv6_is_my_maddr()
etc.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
As the debugging print calls are async, all the strings that might
be overwritten must use log_strdup() which will create a copy
of the printable string.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Instead of one global log level option and one on/off boolean
config option / module, this commit creates one log level option
for each module. This simplifies the logging as it is now possible
to enable different level of debugging output for each network
module individually.
The commit also converts the code to use the new logger
instead of the old sys_log.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The return of memset is never checked. This patch explicitly ignore
the return to avoid MISRA-C violations.
The only directory excluded directory was ext/* since it contains
only imported code.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
*_ll_src/*_ll_dst/*_ll_swap/*_ll_if were not self explanatory, ll
meaning "link layer" it's ambiguous what the names meant.
Changing to:
*_lladdr_src/*_lladdr_dst/*_lladdr_swap/*_lladdr_if to fix this.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Refactor IPv6 address lifetime timer setting in net_if_addr to support
longer lifetime than 24 days.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
No functionality changes. Just moved IPv6 neighbor and related functions
to ipv6_nbr.c for better readability.
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>