Merge branch 'ipv4-ipv6-account-for-fraggap-on-paged-allocation-paths'

Wongi Lee says:

====================
ipv4/ipv6: account for fraggap on paged allocation paths

Fix fraggap accounting in the paged-allocation paths of IPv4 and IPv6.

The IPv6 patch is the v4 update of the previously posted patch. The IPv4
patch handles the same code pattern (by Ido).

v3: https://lore.kernel.org/aiq3f7UZGFp0F3MV@DESKTOP-19IMU7U.localdomain
v2: https://lore.kernel.org/aigx83czv+UJZA0d@DESKTOP-19IMU7U.localdomain
v1: https://lore.kernel.org/aibiIYMAwUErTw5U@DESKTOP-19IMU7U.localdomain
====================

Link: https://patch.msgid.link/ajFQn6yh43eDeQm9@DESKTOP-19IMU7U.localdomain
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Jakub Kicinski 2026-06-21 15:24:52 -07:00
commit 38becddc33
2 changed files with 5 additions and 11 deletions

View File

@ -1116,8 +1116,8 @@ static int __ip_append_data(struct sock *sk,
!(rt->dst.dev->features & NETIF_F_SG)))
alloclen = fraglen;
else {
alloclen = fragheaderlen + transhdrlen;
pagedlen = datalen - transhdrlen;
alloclen = fragheaderlen + transhdrlen + fraggap;
pagedlen = datalen - transhdrlen - fraggap;
}
alloclen += alloc_extra;
@ -1164,9 +1164,6 @@ static int __ip_append_data(struct sock *sk,
}
copy = datalen - transhdrlen - fraggap - pagedlen;
/* [!] NOTE: copy will be negative if pagedlen>0
* because then the equation reduces to -fraggap.
*/
if (copy > 0 &&
INDIRECT_CALL_1(getfrag, ip_generic_getfrag,
from, data + transhdrlen, offset,

View File

@ -1667,8 +1667,8 @@ static int __ip6_append_data(struct sock *sk,
!(rt->dst.dev->features & NETIF_F_SG)))
alloclen = fraglen;
else {
alloclen = fragheaderlen + transhdrlen;
pagedlen = datalen - transhdrlen;
alloclen = fragheaderlen + transhdrlen + fraggap;
pagedlen = datalen - transhdrlen - fraggap;
}
alloclen += alloc_extra;
@ -1683,10 +1683,7 @@ static int __ip6_append_data(struct sock *sk,
fraglen = datalen + fragheaderlen;
copy = datalen - transhdrlen - fraggap - pagedlen;
/* [!] NOTE: copy may be negative if pagedlen>0
* because then the equation may reduces to -fraggap.
*/
if (copy < 0 && !(flags & MSG_SPLICE_PAGES)) {
if (copy < 0) {
err = -EINVAL;
goto error;
}