Make sure that IPv4 specific functions are callable even if
IPv4 is not enabled. This allows use of IS_ENABLED() macro
in other parts of the system.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Make sure that IPv6 specific functions are callable even if
IPv6 is not enabled. This allows use of IS_ENABLED() macro
in other parts of the system.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
No need to evaluate what's the ll reserve size here as net if has a
function to do so.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
If the destination IPv6 address is interface local scope multicast
address FF01::, then loopback those packets back to us as that is
the purpose of those addresses. They are to work same way as
localhost unicast address. See RFC 3513 ch 2.7 for details.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If IPv6 is disabled, then we can skip IPv6 checks and avoid
Coverity warnings. Same thing for IPv4.
Coverity-CID: 189506
Fixes#11100
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>
Make sure that ICMPv6 checksum is correct before continuing
processing the packet.
Fixes#10971
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If we receive an IPv6 packet with organisation scope multicast
address FF08:: then we must drop it as those addresses are
reserved for organisation network traffic only.
Fixes#10961
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If we receive an IPv6 packet with site scope multicast
address FF05:: then we must drop it as those addresses are
reserved for site network traffic only.
Fixes#10960
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If we receive an IPv6 packet with interface scope multicast
address FF01:: then we must drop it as those addresses are
reserved for local network traffic only.
Fixes#10959
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
For Bluetooth, the link address is set only after the Bluetooth
connection is established. Because of this, place the link address
check to net_if_up() because at that point the link address should
be set properly.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
There's a lot of code which assumes net_if_get_link_addr(iface)->addr
Forgetting to set it leads to deferred, spectacular crashes. It's
impractical to assert it on every usage. So, instead let's assert
it after call to driver->init(), as that is supposed to set it.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
We must drop packet that is received from outside and which has
IPv6 loopback address (::1) either as a destination address or
source address.
Fixes#10933
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
ICMPv4 checksum is not optional and thus cannot be zero. Hence, drop
packet with invalid zero ICMPv4 checksum.
Signed-off-by: Ruslan Mstoi <ruslan.mstoi@intel.com>
If we receive an IPv4 that has broadcast destination address, then
properly handle it.
This means that for
* ICMPv4, if CONFIG_NET_ICMPV4_ACCEPT_BROADCAST is set (this is the
default value) and we receive echo-request then accept the packet.
Drop other ICMPv4 packets.
* TCP, drop the packet
* UDP, accept the packet if the destination address is the broadcast
address 255.255.255.255 or the subnet broadcast address.
Drop the packet if the packets broadcast address is not in our
configured subnet.
In sending side, make sure that we do not route broadcast address
IPv4 packets back to us. Also set Ethernet MAC destination address
properly if destination IPv4 address is broadcast one.
Fixes#10780
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Add utility function that returns true if given IPv4 address is
a broadcast address. This will be used in later commits to check
received packet IPv4 source and destination addresses.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Remove extra ntohl() calls when checking IPv4 address against
a subnet address.
Convert also the IPv4 address to be const as the netmask related
functions do not change its value.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Cache the used transport protocol in net_pkt. This way we can
avoid traversing IP header to get the last protocol in network
packet. This is mostly an issue in IPv6 which can have a long
list of extension headers after IPv6 header and before the
transport protocol header.
Fixes#10853
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Wrong Kconfig template was used for max debug level which caused
the max level to be the default level (ERROR). This prevented
all debug prints from showing.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The maximum log level was using wrong template which caused
the max value to be ignored.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The CONFIG_NET_DEFAULT_LOG_LEVEL template entry was only partially
fixed earlier and some spaces were not there around "=".
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The connection index was printed incorrectly in debug print.
Coverity-CID: 188742
Coverity-CID: 188753
Fixes#10583#10574
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This patch fixes the compile error when CONFIG_NET_PKT_LOG_LEVEL
is LOG_LEVEL_DBG.
> subsys/net/ip/net_shell.c: In function ‘context_info’:
> subsys/net/ip/net_shell.c:2893:106: error: ‘struct net_buf_pool’
> has no member named ‘avail_count’
> subsys/net/ip/net_shell.c:2893:125: error: ‘struct net_buf_pool’
> has no member named ‘name’
In struct net_buf_pool, 'avail_count' and 'name' are depends on
CONFIG_NET_BUF_POOL_USAGE.
Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
Check for NULL IPv6 addr values from net_if_ipv6_get_ll() in rpl.c
If NULL, print out an error statement stating that no proper IPv6
address was found
Coverity-CID: 188169
Fixes#10094.
Signed-off-by: Satya Bhattacharya <satyacube@gmail.com>
Recently, the wifi net offload driver has been asserting
as init_iface() was checking for api->send != NULL, even in
the case of NET_OFFLOAD
This patch suggests a fix to handle the NET_OFFLOAD case.
Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
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>
Currently logging subsystem supports quite small number of function
parameters. So split some long functions into smaller pieces.
Hopefully this is just a temporary patch and we can support more
parameters to logging macros.
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>
Completely remove the last_sync_receipt_timeout time. It is not part of
the standard (see 802.1AS-2011, 10.2.11 for the complete list of
variables for this state machine). Additionally this extra variable was
never really initialized so the calculated duration made no sense.
Just start the timer based on the regular sync receipt timeout time
interval from the port data set.
Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
Under GNU C, sizeof(void) = 1. This commit merely makes it explicit u8.
Pointer arithmetics over void types is:
* A GNU C extension
* Not supported by Clang
* Illegal across all ISO C standards
See also: https://gcc.gnu.org/onlinedocs/gcc/Pointer-Arith.html
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
pkt properties should be set prior to routing.
If packet routing is turned on and the packet is
forwarded to an interface, the pkt properties like
ipv6_ext_len or ip_hdr_len will not be initialized.
If a UDP packet is forwarded to an 6lo interface,
it leads to incorrect calculation of UDP header
during UDP header compression (net_udp_get_hdr).
Fixes#10204
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
If the neighbour does not exists, then the route to it cannot
be deleted so we can return error to caller in that case.
Coverity-CID: 188173
Fixes#10090
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
In net_route_add(), do not try to print route information if
route to neighbor is not found.
Coverity-CID: 188172
Fixes#10091
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Use the destination address to select the proper network interface
when binding. The default network interface cannot be used here
as then the packet might be sent to wrong network interface.
Fixes#9935
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
New shell implementation is on the way. For now old one and all
references are kept to be gradually replaced by new shell.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
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>
- Up to net_context to give the source port.
- net_udp_append is unused anywhere: let's remove it.
- left over macros on _raw versions removed as well.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>