Commit graph

41120 commits

Author SHA1 Message Date
Tomasz Bursztyka
a0daca0c6a net: Fix IPv6 NS packet size check
Source link-layer address option might not be present, if the IP source
address is unspecified.

Change-Id: I1c9e89cce39588c6c8735e59cf894f6d278d52bb
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:17 +02:00
Tomasz Bursztyka
72df406cb8 net: Add IPv6 ND statistics when relevant
CONFIG_NET_IPV6_ND enables ND packet processing, and we are thus
interested about the packet recv/sent/drop statistics.

Change-Id: Id281c924193bd2b1d71088bf40d47b1601daad5c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:17 +02:00
Jukka Rissanen
1619279553 net: RX fiber needs bigger stack
Current stack consumption as reported by analyzer

  RX fiber stack real size 1200 unused 84 usage 1072/1156 (92 %)

so increase the stack to 1200 bytes.

Change-Id: Ibf2b27a6fb25cfb6be6d95e77c2e882526128a0a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:17 +02:00
Jukka Rissanen
86a3edffd0 net: Return NET_CONTINUE in L2 ethernet driver in send()
If the packet is not sent yet, then return NET_CONTINUE so that
the caller can avoid processing the packet yet. The packet might
not be sent yet if for example IPv6 ND is being done.

Change-Id: I242ffcafb3e68f63d9dca06367e075a143a7bbe6
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:17 +02:00
Jukka Rissanen
fe7cc6d2d2 net: Ethernet driver needs to set ll address
Instead of swapping the ll address set the source and
destination addresses if they are not set.

Change-Id: Icdded06df2edb27f71894e29e9bc22a8f0313fae
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:17 +02:00
Jukka Rissanen
ad4fe09c48 net: IPv6 neighbor was not properly added to cache
The IPv6 and ll address of the neighbor was not properly updated
and set in the neighbor cache. Symptoms were that packets were
discarded even thou the cache contained proper ll address.

Change-Id: I2acfb1b03d2eb69eddcf7ad5e25e8a7ce2ce3bb5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:17 +02:00
Jukka Rissanen
43acda57b8 net: No need to swap ll address in IPv6 module
The L2 layer sender should actually set the link layer addresses
properly.

Change-Id: I9dd2f9ca269384dff0bef12e570317173f6a5f02
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:17 +02:00
Jukka Rissanen
dd3b93d3f3 net: Update UDP sent packet statistics
Change-Id: Ia012f1b1d2cd9e975e3e1744a2f6fce09ccc0987
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:17 +02:00
Jukka Rissanen
5754b64611 net: nbuf variables needs clearing when allocating nbuf
Initial value for nbuf variables need to be set as they
might contain garbage from previous allocation.

Change-Id: I1d16e72387dbda86355ac01aabc1ba617bba0d50
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
d873ba5fbc net: Check packet sending status correctly in arp.c
The packet sending function returns either NET_OK or NET_DROP
instead of <0 value. Make sure we check the value correctly.

Change-Id: Iab5b5c07ca548e9c2ccb31542a7633ecc0de2bc9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
1eb1c0f4f3 net: Call net_context send callback when packet is sent
The send callback in net_context is called after packet has been
successfully sent or dropped. The callback is not called if the
packet is pending and waiting for example IPv6 ND to finish.

Change-Id: I28e77c6333974705a0e31862bb913eedace0b3f9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
e2908b1a6b net: Call send callback in net_context properly
The send callback should be called after the packet has been
sent so setup things allowing that.

Change-Id: Icb82f9896667dcb1e400376c0fca6df380509090
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
e04fbc04e1 net: Add token to nbuf
The token is used by net_context.c when sending packet. User
can set the token and get it back when data has been sent.
This can be used to know what specific packet was sent if
there are multiple packets going at the same time.

Change-Id: Iaaf730faaa55a712ae22d903e612e44deb683b8f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
63d14c33e3 net: Check IPv6 NS, NA and RA messages for corruption
Additional checks to make sure the received IPv6 neighbor
solicitation, neighbor advertisement and router advertisement
messages are not corrupted.

Change-Id: Ic34a92eaac14dc9e2e6ed305fc7b2b6dcab9c29c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
11e111d494 net: Rename ip_protocol to net_ip_protocol
In order to be consistent with naming, this commit renames
ip_protocol enum that is found in net_ip.h to net_ip_protocol.

Change-Id: Ie6caf059279b819794a13494468de789450e2bd8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
84edd8f2f1 net: apps: Fix echo-server to use the new user API
Echo-server no longer reverses the data as doing it
when we have a fragment chain is quite challenging.

Change-Id: I298669f3ddba67000672320e7b3b14f72e9f12d4
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
7ec784f102 net: Set reserve, context and iface properly in nbuf
Invalid values were used when filling reserve, context and
network interface in nbuf private data area.

Change-Id: Id063fa3a415cd281d50148c10e7b838d56878894
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
2420452c28 net: Add more debugging to nbuf
Change-Id: Id23bc69d1566d50cbee4f9ae6def51f5f79b7dfe
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
d4aa154e70 net: Use proper ll header length when sending IPv6 NS
We must use the link layer header length derived from the
actual interface when sending IPv6 neighbor solicitation msg.

Change-Id: I1836743ffed50254c89341fbdade039741e62f33
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
a91fbc7e3f net: Resolve LL address for IPv6 packet in ethernet L2 driver
If we do not know link layer address when sending ethernet frame,
then initiate IPv6 neighbor discovery process.

Change-Id: Id9c55646895a12ea3693cdca330e730bc80d83dc
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
14dc085830 net: Do IPv6 ND if LL address is not known when sending
Resolve the ll address so that IPv6 packet can be sent.
This means that the IPv6 neighbor discovery needs to be done.
The original packet will be sent after neighbor advertisement
is received.

Change-Id: If54cdbd1468ca802f59e206996ea3addab16d5b8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
2ea5bc52b2 net: Neighbor cache entry was not properly init
Pending variable needs to be init so that we do not use
some old value when cache entry is reused.

Change-Id: Id6af61981d4fc7628992b4a018d84a4e5c8a16f6
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:16 +02:00
Jukka Rissanen
7d97b7d10e net: Fix debug prints in net conn manager
The IP address was not printed properly when registering a handler.

Change-Id: Iadb02997a43f1440932d224e0113b6f45c4f0aed
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
9d5b0d651c slip: Do not send ethernet header if MTU is large enough
No need to partition the data if MTU is large enough and
data can be sent in one frame.

Change-Id: I8ba0f5030ed1e2c1341c7e2dd409ba636b1a9a4c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
755c96fddf net: Set the protocol family and interface for net_buf
When allocating net_buf via a net_context, set the network
interface and protocol family to net_nbuf.

Change-Id: I0df876e0c8ba66bac42f3aa7fd17c5bf9a935985
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
498f9e04de net: tests: Unit tests for user space socket API
Change-Id: Ifd149e4f4313abde4cead135f7533f26dec6bdf7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
c0e4781346 net: Create IPv4, IPv6 and UDP packets when needed
The sending functions net_context_send() and net_context_sendto()
will need to send data.

Change-Id: I5372cb9dede2a996276c30241f28689c4f902dff
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
b481908c71 net: Utility function to append UDP packet into net_buf
Change-Id: I7008b7cddb08525c2f549715a46cae608bb865d4
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
41670f78c2 net: Add helper to create IPv4 packet
Change-Id: I51a19878f3e21cfcff5b92fec413d172cc025dd6
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
961a32ad95 net: Add helper to create IPv6 packet
Change-Id: I5bf6e29f450d13add1ca78ee090e2107e7fee45f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
13733f7894 net: Add user space API to net_context
This API provides similar kind of functionality as BSD socket
API. This API does not provide BSD socket API.

Change-Id: I537d0ad2a5213f1d1e11fa7891dd4f4d0f3cc4bb
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
7702e0384c net: Increasing the default IPv6 unicast addr count
The earlier default 1 was too low, a more usable 2 is now
the default. User can set the limit to 1 if needed.

Change-Id: Ib30a1ceb95c42f69197298f672daaeab6b41890b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
9331b2bc7b net: Add net_conn pointer to callback
When a UDP packet has been received and if a watcher match
is found, then a callback is called. It is useful to have
a pointer to net_conn when calling the callback.

Change-Id: Ifa97b37c22b1fc9cac7eadfba23aa68dfd473fda
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
1932d4c3ec net: Convert network connection to use sockaddr
As the net_conn needs port information, use struct sockaddr
internally as it has the port numbers built in.

Change-Id: Idb1c87afa956dfe55dc8d533d867fa7845545b12
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
b055a05ae8 net: Add helpers for getting protocol specific sockaddr
Change-Id: Icdf9dec83856b35228f9e3be24c2beceb37c3178
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
0dbe48eb46 net: Add sockaddr struct
These are need in future commits. The sockaddr struct will hold
the IP address and port number among other things.

Change-Id: I0971c39f0f1cb019aa8610977a245e24548c56ee
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
96eb99d23f net: UDP checksum calculator
Change-Id: Idf8bf34c3567fa68ac1b4871e584efafbb2f13d5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:14 +02:00
Jukka Rissanen
be63339dc5 net: Swap ll addresses when handling ICMPv6 Echo-Request
As we send the same network buffers back to sender, then
we need to also swap link layer addresses otherwise the packets
will be discarded by the sender.

Change-Id: I08b083d567bf5f45fd25d8a30fefa5330e12c35e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:14 +02:00
Jukka Rissanen
1d78106058 net: net_hexdump_frags() is only available when debugging
Creating a dummy macro that is used when debugging is disabled.

Change-Id: I8171463451ef428f1f06fa845d7af6b78c7c5910
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:14 +02:00
Jukka Rissanen
f88da0fa36 net: tests: UDP unit test had incorrect ll address length
Change-Id: Ie3231c6fda2faf49f4767a78250b923bedb2d293
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:14 +02:00
Jukka Rissanen
6085ff518a net: Making IP address const in utility func
Changing the IP address type to const as the functions do not
modify the IP address.

Change-Id: I176d84af5f05843226a954f91b6bb3bba6596863
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:14 +02:00
Jukka Rissanen
f2a40b6805 net: Address family needs to be set for multicast address
Network interface multicast address was missing information
about the protocol family.

Change-Id: I8d7b0514ec351efddb6997965c940f62fc08a37a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:14 +02:00
Jukka Rissanen
432f3b3914 net: tests: udp: Print debug info only when activated
No need to print debug prints if debugging is not activated.

Change-Id: I42a6453b4f3e11106119561b580ebea41e56452d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:14 +02:00
Jukka Rissanen
20167bd472 net: Utility to get net_if according to index value
Using network interface index instead of net_if pointer can
save 3 bytes of memory. So these utilities help to convert
pointer to index and vice versa.

Change-Id: I8743a06e0935d48798b19526154058be385550af
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:14 +02:00
Jukka Rissanen
2658ac7a73 net: IP address lookup functions return interface
When checking the IP address from network interface, return
also the used network interface.

Change-Id: If7b8385193da4cb1b469f697e219cfae3b6477dd
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:14 +02:00
Jukka Rissanen
03a40093cf net: Do not include anything from net/ip directory
We do not need any header files from legacy IP stack.

Change-Id: I0c78fe500bec37593e66e8a237a3f92b79cbaf85
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:14 +02:00
Tomasz Bursztyka
a1fde2bff8 net: Fix dedicated IPv4 function for net_if
IPv4/6 functions follows this scheme: net_if_ipv<4/6>_<name>.
Applying that to net_if_set_gw/net_if_set_netmask which are IPv4
functions.

Change-Id: I2dcbb16ce81cfdffbfbb5cae24ad76ddf2b9919a
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:14 +02:00
Tomasz Bursztyka
92e592c80d net: Simplify IPV<4/6> config management in net_if
Reducing the amount of #if defined(CONFIG_NET_IPV<4/6>) for a clearer
code and to lower compiler's stress.

Change-Id: Iffbfbda4409c6cbf48a3057ea1b9e43309cd84e7
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:14 +02:00
Ravi kumar Veeramally
c1ee601962 net: tests: Add unit tests for 6lowpan functionality
Change-Id: Ie13a05300e05fdc536fcb4ec64e323789704ba8b
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:14 +02:00
Ravi kumar Veeramally
c475796a19 net: Add initial 6lowpan IPHC compression support.
IPv6 packets with UDP header are compressed and decompressed
as per RFC 6282 (IPHC). Context based compression not implemented.

Change-Id: I8020da26b8d40fdc80e75cba56ef28a01a36159e
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:14 +02:00