Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'inet-ping-remove-extra-skb_clone-consume_skb'

Eric Dumazet says:

====================
inet: ping: remove extra skb_clone()/consume_skb()

First patch in the series moves ICMP_EXT_ECHOREPLY handling in icmp_rcv()
to prepare the second patch.

The second patch removes one skb_clone()/consume_skb() pair
when processing ICMP_EXT_REPLY packets. Some people
use hundreds of "ping -fq ..." to stress hosts :)
====================

Link: https://patch.msgid.link/20250226183437.1457318-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+24 -36
+17 -16
net/ipv4/icmp.c
··· 1248 1248 goto reason_check; 1249 1249 } 1250 1250 1251 - if (icmph->type == ICMP_EXT_ECHOREPLY) { 1252 - reason = ping_rcv(skb); 1253 - goto reason_check; 1254 - } 1255 - 1256 - /* 1257 - * 18 is the highest 'known' ICMP type. Anything else is a mystery 1258 - * 1259 - * RFC 1122: 3.2.2 Unknown ICMP messages types MUST be silently 1260 - * discarded. 1261 - */ 1262 - if (icmph->type > NR_ICMP_TYPES) { 1263 - reason = SKB_DROP_REASON_UNHANDLED_PROTO; 1264 - goto error; 1265 - } 1266 - 1267 1251 /* 1268 1252 * Parse the ICMP message 1269 1253 */ ··· 1272 1288 reason = SKB_DROP_REASON_INVALID_PROTO; 1273 1289 goto error; 1274 1290 } 1291 + } 1292 + 1293 + if (icmph->type == ICMP_EXT_ECHOREPLY || 1294 + icmph->type == ICMP_ECHOREPLY) { 1295 + reason = ping_rcv(skb); 1296 + return reason ? NET_RX_DROP : NET_RX_SUCCESS; 1297 + } 1298 + 1299 + /* 1300 + * 18 is the highest 'known' ICMP type. Anything else is a mystery 1301 + * 1302 + * RFC 1122: 3.2.2 Unknown ICMP messages types MUST be silently 1303 + * discarded. 1304 + */ 1305 + if (icmph->type > NR_ICMP_TYPES) { 1306 + reason = SKB_DROP_REASON_UNHANDLED_PROTO; 1307 + goto error; 1275 1308 } 1276 1309 1277 1310 reason = icmp_pointers[icmph->type].handler(skb);
+5 -15
net/ipv4/ping.c
··· 966 966 967 967 enum skb_drop_reason ping_rcv(struct sk_buff *skb) 968 968 { 969 - enum skb_drop_reason reason = SKB_DROP_REASON_NO_SOCKET; 970 - struct sock *sk; 971 969 struct net *net = dev_net(skb->dev); 972 970 struct icmphdr *icmph = icmp_hdr(skb); 971 + struct sock *sk; 973 972 974 973 /* We assume the packet has already been checked by icmp_rcv */ 975 974 ··· 979 980 skb_push(skb, skb->data - (u8 *)icmph); 980 981 981 982 sk = ping_lookup(net, skb, ntohs(icmph->un.echo.id)); 982 - if (sk) { 983 - struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); 983 + if (sk) 984 + return __ping_queue_rcv_skb(sk, skb); 984 985 985 - pr_debug("rcv on socket %p\n", sk); 986 - if (skb2) 987 - reason = __ping_queue_rcv_skb(sk, skb2); 988 - else 989 - reason = SKB_DROP_REASON_NOMEM; 990 - } 991 - 992 - if (reason) 993 - pr_debug("no socket, dropping\n"); 994 - 995 - return reason; 986 + kfree_skb_reason(skb, SKB_DROP_REASON_NO_SOCKET); 987 + return SKB_DROP_REASON_NO_SOCKET; 996 988 } 997 989 EXPORT_SYMBOL_GPL(ping_rcv); 998 990
+2 -5
net/ipv6/icmp.c
··· 957 957 break; 958 958 959 959 case ICMPV6_ECHO_REPLY: 960 - reason = ping_rcv(skb); 961 - break; 962 - 963 960 case ICMPV6_EXT_ECHO_REPLY: 964 - reason = ping_rcv(skb); 965 - break; 961 + ping_rcv(skb); 962 + return 0; 966 963 967 964 case ICMPV6_PKT_TOOBIG: 968 965 /* BUGGG_FUTURE: if packet contains rthdr, we cannot update