This optimizes the memory quite a bit since we do not need to clone nor
split the original packet at any time.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Most of the code had to be reworked due to the new API: it's more
logical to do everything sequentially (first headers, then MLD part)
than the contrary with inserting headers at the end.
Using get_data/set_data as well it makes the code clearer.
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.
Introducing a generic struct to acces the common part of MLD queries,
instead of accessing part by part.
Also, returning NET_OK in case parsing went fine. We send an MLD report
anyway, so it's not a good idea to count the message as being dropped in
statistics.
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>
Unlike before, we allocate a new packet for the reply which is a
modified clone of the request.
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>
Use the new net_pkt API to proceed through IPv6 header and all the
extension header as well.
Use udp/tcp input functions relevantly, and call net_conn_input
afterwards.
Note: This commit temporarly disable IPv6 fragmentation support
in the code directly. Which support will be re-enabled afterwards.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This is pretty much the same as in ICMPv4. Actually, when it comes to
the ICMP header, it could probably be put in a common places for both
ICMPv4 and ICMPv6.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Extension headers are specific and use nexthdr attribute from net_pkt.
next_header_proto is the user protocol (if any) that might require
finalization too (calculating the checksum).
However, if there are extension header, we need to skip those and jump
to the position where the user protocol starts.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Also, store the actual next_hdr value and not it's position.
This permits to reduce net_pkt from some bytes.
Such field was unused until now, but it will be soon.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This API is meant to work with pre-allocated net_pkt.
It assumes net_pkt's buffer cursor is at the right position where to
create the IPv6 header. Once done, the cursor will be placed right
after the newly created IPv6 header.
Finalizing assumes the same.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Function names will be normalized then by the couple create/finalize.
This one only sets the checksum.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
checksum_offload is now the only one using that function, let's get rid
of such usage.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Verifying udp/tcp checksum should be done before calling this function.
Also, up to ipv4 and ipv6 to provide a pointer to their respective
header.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This will be the place where UDP header is parsed: its checksum verified
and src/dst ports grabbed.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
It's now up to net_context to build the net_pkt and send it.
This will become the default.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
It's not anymore up to user to provide the pkt. Context will build the
packet according to its metadata and provided buffer and length.
It currently supports only IPv4 and UDP.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Unlike before, we allocate a new packet for the reply which is a
modified clone of the request.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This is meant to remove the need for macro NET_IPV4_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>
Function names will be normalized then by the couple create/finalize.
This one only sets the checksum.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
As before, such header is meant to be in a contiguous area (beginning
of the buffer, only 20 bytes)
Opportunistically chaning the function name to net_ipv4_input() (all
will be create/finalize/input).
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Newly received pkt can get their cursor intialized at net_recv_data()
(most of the time, drivers won't mangle with the content before calling
that function).
Right after l2 (net_if_recv_data()) parsing as well. L2s pull the
starting buffer after ll header. Instead of letting L2s updating the
cursor, it's simpler to reinitialize it directly after such parsing.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This will avoid new API's writing functions to modify the packet's
content. For instance while checking its checksum etc...
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Use the new API where relevant. Only sam_gmac is left aside for now.
This simplifies a lot the code as the caller should only care about
allocating net_pkt and its buffer once, and thus will not need to mess
with "frags" etc...
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This is the easiest piece to change using the new API, and can be used
as showing how this API can be used.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This API is meant to work with pre-allocated net_pkt.
It assumes net_pkt's buffer cursor is at the right position where to
create the UDP header. Once done, the cursor will be placed right after
the newly created UDP header.
Finalizing assumes the same.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This API is meant to work with pre-allocated net_pkt.
It assumes net_pkt's buffer cursor is at the right position where to
create the IPv4 header. Once done, the cursor will be placed right
after the newly created IPv4 header.
Finalizing assumes the same.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
These ones would support linearizing non-contiguous area, however
requiring a bit more complex type as an "accessor".
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>