mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net 0/2] net: ioam6: fix bugs in ioam6_iptunnel
@ 2024-07-02 17:44 Justin Iurman
  2024-07-02 17:44 ` [PATCH net 1/2] net: ioam6: use "new" dst entry with skb_cow_head Justin Iurman
  2024-07-02 17:44 ` [PATCH net 2/2] net: ioam6: mitigate the two reallocations problem Justin Iurman
  0 siblings, 2 replies; 7+ messages in thread
From: Justin Iurman @ 2024-07-02 17:44 UTC (permalink / raw)
  To: netdev
  Cc: davem, dsahern, edumazet, kuba, pabeni, linux-kernel, justin.iurman

When running some measurements on IOAM, we discovered a "bug" that
triggers two reallocations instead of one in some specific cases. Those
specific cases are:
- "inline" mode with pre-allocated data size 236 or 240 bytes
- "encap" mode with pre-allocated data size 196 or 200 bytes

The reason is that we (unluckily) fall on a boundary and, since we use
skb->mac_len by default in skb_cow_head(), the second call to
skb_cow_head() after the insertion may need more than available in the
headroom (because, there, we call LL_RESERVED_SPACE()). Example on a
machine that reallocates by steps of 64 bytes:
- I need to add 256 bytes (+14 skb->mac_len), so 270 bytes
- current headroom is 206 bytes
- call to skb_cow_head, the headroom is now 270 bytes (+64 bytes)
- after the insertion, we want to make sure that the dev has enough
  headroom (LL_RESERVED_SPACE() gives 16 bytes in our case: 14+2)
- current headroom is 14 bytes (yep, remember... see above)
- call to skb_cow_head... oh wait, I need 16 bytes and I only have 14
  available... let's reallocate! The headroom is now 78 bytes (+64)

And so every single time. Patch 2 solves this issue by providing a
mitigation.

Also, while fixing the above, we discovered another bug: after the
insertion, the second call to skb_cow_head() makes sure that the dev has
enough headroom for layer 2 and stuff. In that case, the "old" dst entry
is used, which is not correct. Patch 1 solves this issue.

Justin Iurman (2):
  net: ioam6: use "new" dst entry with skb_cow_head
  net: ioam6: mitigate the two reallocations problem

 net/ipv6/ioam6_iptunnel.c | 85 ++++++++++++++++++++-------------------
 1 file changed, 44 insertions(+), 41 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-07-04 11:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-02 17:44 [PATCH net 0/2] net: ioam6: fix bugs in ioam6_iptunnel Justin Iurman
2024-07-02 17:44 ` [PATCH net 1/2] net: ioam6: use "new" dst entry with skb_cow_head Justin Iurman
2024-07-04  9:08   ` Paolo Abeni
2024-07-02 17:44 ` [PATCH net 2/2] net: ioam6: mitigate the two reallocations problem Justin Iurman
2024-07-02 18:30   ` Justin Iurman
2024-07-04  9:23   ` Paolo Abeni
2024-07-04 11:58     ` Justin Iurman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®