]> git.baikalelectronics.ru Git - kernel.git/commit
net: tipc: fix FB_MTU eat two pages
authorMenglong Dong <dong.menglong@zte.com.cn>
Mon, 28 Jun 2021 06:37:44 +0000 (23:37 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Jun 2021 20:31:57 +0000 (13:31 -0700)
commit04b91b55bfd77dfb4d0a623f8e5e33b66a5a7b18
tree6364734be857c1e028de3cd2e6f7a1a37721f18c
parent870172d9c0a9683e1faa577933c7a76751c13123
net: tipc: fix FB_MTU eat two pages

FB_MTU is used in 'tipc_msg_build()' to alloc smaller skb when memory
allocation fails, which can avoid unnecessary sending failures.

The value of FB_MTU now is 3744, and the data size will be:

  (3744 + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) + \
    SKB_DATA_ALIGN(BUF_HEADROOM + BUF_TAILROOM + 3))

which is larger than one page(4096), and two pages will be allocated.

To avoid it, replace '3744' with a calculation:

  (PAGE_SIZE - SKB_DATA_ALIGN(BUF_OVERHEAD) - \
    SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))

What's more, alloc_skb_fclone() will call SKB_DATA_ALIGN for data size,
and it's not necessary to make alignment for buf_size in
tipc_buf_acquire(). So, just remove it.

Fixes: 625308e1e3d6 ("tipc: fall back to smaller MTU if allocation of local send skb fails")
Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn>
Acked-by: Jon Maloy <jmaloy@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/bcast.c
net/tipc/msg.c
net/tipc/msg.h