Skip to content

Commit 5204ccb

Browse files
edumazetkuba-moo
authored andcommitted
inet: add indirect call wrapper for getfrag() calls
UDP send path suffers from one indirect call to ip_generic_getfrag() We can use INDIRECT_CALL_1() to avoid it. Signed-off-by: Eric Dumazet <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Reviewed-by: Brian Vazquez <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f029c40 commit 5204ccb

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

net/ipv4/ip_output.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,10 @@ static int __ip_append_data(struct sock *sk,
11691169
/* [!] NOTE: copy will be negative if pagedlen>0
11701170
* because then the equation reduces to -fraggap.
11711171
*/
1172-
if (copy > 0 && getfrag(from, data + transhdrlen, offset, copy, fraggap, skb) < 0) {
1172+
if (copy > 0 &&
1173+
INDIRECT_CALL_1(getfrag, ip_generic_getfrag,
1174+
from, data + transhdrlen, offset,
1175+
copy, fraggap, skb) < 0) {
11731176
err = -EFAULT;
11741177
kfree_skb(skb);
11751178
goto error;
@@ -1213,8 +1216,9 @@ static int __ip_append_data(struct sock *sk,
12131216
unsigned int off;
12141217

12151218
off = skb->len;
1216-
if (getfrag(from, skb_put(skb, copy),
1217-
offset, copy, off, skb) < 0) {
1219+
if (INDIRECT_CALL_1(getfrag, ip_generic_getfrag,
1220+
from, skb_put(skb, copy),
1221+
offset, copy, off, skb) < 0) {
12181222
__skb_trim(skb, off);
12191223
err = -EFAULT;
12201224
goto error;
@@ -1252,7 +1256,8 @@ static int __ip_append_data(struct sock *sk,
12521256
get_page(pfrag->page);
12531257
}
12541258
copy = min_t(int, copy, pfrag->size - pfrag->offset);
1255-
if (getfrag(from,
1259+
if (INDIRECT_CALL_1(getfrag, ip_generic_getfrag,
1260+
from,
12561261
page_address(pfrag->page) + pfrag->offset,
12571262
offset, copy, skb->len, skb) < 0)
12581263
goto error_efault;

net/ipv6/ip6_output.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,8 +1697,9 @@ static int __ip6_append_data(struct sock *sk,
16971697
pskb_trim_unique(skb_prev, maxfraglen);
16981698
}
16991699
if (copy > 0 &&
1700-
getfrag(from, data + transhdrlen, offset,
1701-
copy, fraggap, skb) < 0) {
1700+
INDIRECT_CALL_1(getfrag, ip_generic_getfrag,
1701+
from, data + transhdrlen, offset,
1702+
copy, fraggap, skb) < 0) {
17021703
err = -EFAULT;
17031704
kfree_skb(skb);
17041705
goto error;
@@ -1742,8 +1743,9 @@ static int __ip6_append_data(struct sock *sk,
17421743
unsigned int off;
17431744

17441745
off = skb->len;
1745-
if (getfrag(from, skb_put(skb, copy),
1746-
offset, copy, off, skb) < 0) {
1746+
if (INDIRECT_CALL_1(getfrag, ip_generic_getfrag,
1747+
from, skb_put(skb, copy),
1748+
offset, copy, off, skb) < 0) {
17471749
__skb_trim(skb, off);
17481750
err = -EFAULT;
17491751
goto error;
@@ -1781,7 +1783,8 @@ static int __ip6_append_data(struct sock *sk,
17811783
get_page(pfrag->page);
17821784
}
17831785
copy = min_t(int, copy, pfrag->size - pfrag->offset);
1784-
if (getfrag(from,
1786+
if (INDIRECT_CALL_1(getfrag, ip_generic_getfrag,
1787+
from,
17851788
page_address(pfrag->page) + pfrag->offset,
17861789
offset, copy, skb->len, skb) < 0)
17871790
goto error_efault;

0 commit comments

Comments
 (0)