net: ipv6: ioam6_iptunnel: mitigate 2-realloc issue
authorJustin Iurman <justin.iurman@uliege.be>
Tue, 3 Dec 2024 12:49:43 +0000 (13:49 +0100)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 5 Dec 2024 10:15:56 +0000 (11:15 +0100)
commitdce525185bc92864e5a318040285ee070563fe34
treeef4a67c67fceb1992875b71f11953b7f6257ac81
parent0600cf40e9b36fe17f9c9f04d4f9cef249eaa5e7
net: ipv6: ioam6_iptunnel: mitigate 2-realloc issue

This patch mitigates the two-reallocations issue with ioam6_iptunnel by
providing the dst_entry (in the cache) to the first call to
skb_cow_head(). As a result, the very first iteration may still trigger
two reallocations (i.e., empty cache), while next iterations would only
trigger a single reallocation.

Performance tests before/after applying this patch, which clearly shows
the improvement:
- inline mode:
  - before: https://ibb.co/LhQ8V63
  - after: https://ibb.co/x5YT2bS
- encap mode:
  - before: https://ibb.co/3Cjm5m0
  - after: https://ibb.co/TwpsxTC
- encap mode with tunsrc:
  - before: https://ibb.co/Gpy9QPg
  - after: https://ibb.co/PW1bZFT

This patch also fixes an incorrect behavior: after the insertion, the
second call to skb_cow_head() makes sure that the dev has enough
headroom in the skb for layer 2 and stuff. In that case, the "old"
dst_entry was used, which is now fixed. After discussing with Paolo, it
appears that both patches can be merged into a single one -this one-
(for the sake of readability) and target net-next.

Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/ipv6/ioam6_iptunnel.c