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.

net: change sock_queue_rcv_skb_reason() to return a drop_reason

Change sock_queue_rcv_skb_reason() to return the drop_reason directly
instead of using a reference.

This is part of an effort to remove stack canaries and reduce bloat.

$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new
add/remove: 0/0 grow/shrink: 3/7 up/down: 79/-301 (-222)
Function old new delta
vsock_queue_rcv_skb 50 79 +29
ipmr_cache_report 1290 1315 +25
ip6mr_cache_report 1322 1347 +25
packet_rcv_spkt 329 327 -2
sock_queue_rcv_skb_reason 166 128 -38
raw_rcv_skb 122 80 -42
ping_queue_rcv_skb 109 61 -48
ping_rcv 215 162 -53
rawv6_rcv_skb 278 224 -54
raw_rcv 591 527 -64
Total: Before=29722890, After=29722668, chg -0.00%

Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260409145625.2306224-2-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
900f27fb 4431c239

+34 -26
+14 -3
include/net/sock.h
··· 2502 2502 struct sk_buff *skb)); 2503 2503 int __sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb); 2504 2504 2505 - int sock_queue_rcv_skb_reason(struct sock *sk, struct sk_buff *skb, 2506 - enum skb_drop_reason *reason); 2505 + enum skb_drop_reason 2506 + sock_queue_rcv_skb_reason(struct sock *sk, struct sk_buff *skb); 2507 2507 2508 2508 static inline int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) 2509 2509 { 2510 - return sock_queue_rcv_skb_reason(sk, skb, NULL); 2510 + enum skb_drop_reason drop_reason = sock_queue_rcv_skb_reason(sk, skb); 2511 + 2512 + switch (drop_reason) { 2513 + case SKB_DROP_REASON_SOCKET_RCVBUFF: 2514 + return -ENOMEM; 2515 + case SKB_DROP_REASON_PROTO_MEM: 2516 + return -ENOBUFS; 2517 + case 0: 2518 + return 0; 2519 + default: 2520 + return -EPERM; 2521 + } 2511 2522 } 2512 2523 2513 2524 int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb);
+2 -3
net/can/bcm.c
··· 363 363 struct sockaddr_can *addr; 364 364 struct sock *sk = op->sk; 365 365 unsigned int datalen = head->nframes * op->cfsiz; 366 - int err; 367 366 unsigned int *pflags; 368 367 enum skb_drop_reason reason; 369 368 ··· 419 420 addr->can_family = AF_CAN; 420 421 addr->can_ifindex = op->rx_ifindex; 421 422 422 - err = sock_queue_rcv_skb_reason(sk, skb, &reason); 423 - if (err < 0) { 423 + reason = sock_queue_rcv_skb_reason(sk, skb); 424 + if (reason) { 424 425 struct bcm_sock *bo = bcm_sk(sk); 425 426 426 427 sk_skb_reason_drop(sk, skb, reason);
+2 -1
net/can/isotp.c
··· 291 291 addr->can_family = AF_CAN; 292 292 addr->can_ifindex = skb->dev->ifindex; 293 293 294 - if (sock_queue_rcv_skb_reason(sk, skb, &reason) < 0) 294 + reason = sock_queue_rcv_skb_reason(sk, skb); 295 + if (reason) 295 296 sk_skb_reason_drop(sk, skb, reason); 296 297 } 297 298
+2 -1
net/can/j1939/socket.c
··· 333 333 if (skb->sk) 334 334 skcb->msg_flags |= MSG_DONTROUTE; 335 335 336 - if (sock_queue_rcv_skb_reason(&jsk->sk, skb, &reason) < 0) 336 + reason = sock_queue_rcv_skb_reason(&jsk->sk, skb); 337 + if (reason) 337 338 sk_skb_reason_drop(&jsk->sk, skb, reason); 338 339 } 339 340
+2 -1
net/can/raw.c
··· 207 207 if (oskb->sk == sk) 208 208 *pflags |= MSG_CONFIRM; 209 209 210 - if (sock_queue_rcv_skb_reason(sk, skb, &reason) < 0) 210 + reason = sock_queue_rcv_skb_reason(sk, skb); 211 + if (reason) 211 212 sk_skb_reason_drop(sk, skb, reason); 212 213 } 213 214
+6 -14
net/core/sock.c
··· 520 520 } 521 521 EXPORT_SYMBOL(__sock_queue_rcv_skb); 522 522 523 - int sock_queue_rcv_skb_reason(struct sock *sk, struct sk_buff *skb, 524 - enum skb_drop_reason *reason) 523 + enum skb_drop_reason 524 + sock_queue_rcv_skb_reason(struct sock *sk, struct sk_buff *skb) 525 525 { 526 526 enum skb_drop_reason drop_reason; 527 527 int err; 528 528 529 529 err = sk_filter_reason(sk, skb, &drop_reason); 530 530 if (err) 531 - goto out; 531 + return drop_reason; 532 532 533 533 err = __sock_queue_rcv_skb(sk, skb); 534 534 switch (err) { 535 535 case -ENOMEM: 536 - drop_reason = SKB_DROP_REASON_SOCKET_RCVBUFF; 537 - break; 536 + return SKB_DROP_REASON_SOCKET_RCVBUFF; 538 537 case -ENOBUFS: 539 - drop_reason = SKB_DROP_REASON_PROTO_MEM; 540 - break; 541 - default: 542 - drop_reason = SKB_NOT_DROPPED_YET; 543 - break; 538 + return SKB_DROP_REASON_PROTO_MEM; 544 539 } 545 - out: 546 - if (reason) 547 - *reason = drop_reason; 548 - return err; 540 + return SKB_NOT_DROPPED_YET; 549 541 } 550 542 EXPORT_SYMBOL(sock_queue_rcv_skb_reason); 551 543
+2 -1
net/ipv4/ping.c
··· 935 935 936 936 pr_debug("ping_queue_rcv_skb(sk=%p,sk->num=%d,skb=%p)\n", 937 937 inet_sk(sk), inet_sk(sk)->inet_num, skb); 938 - if (sock_queue_rcv_skb_reason(sk, skb, &reason) < 0) { 938 + reason = sock_queue_rcv_skb_reason(sk, skb); 939 + if (reason) { 939 940 sk_skb_reason_drop(sk, skb, reason); 940 941 pr_debug("ping_queue_rcv_skb -> failed\n"); 941 942 return reason;
+2 -1
net/ipv4/raw.c
··· 300 300 /* Charge it to the socket. */ 301 301 302 302 ipv4_pktinfo_prepare(sk, skb, true); 303 - if (sock_queue_rcv_skb_reason(sk, skb, &reason) < 0) { 303 + reason = sock_queue_rcv_skb_reason(sk, skb); 304 + if (reason) { 304 305 sk_skb_reason_drop(sk, skb, reason); 305 306 return NET_RX_DROP; 306 307 }
+2 -1
net/ipv6/raw.c
··· 369 369 370 370 /* Charge it to the socket. */ 371 371 skb_dst_drop(skb); 372 - if (sock_queue_rcv_skb_reason(sk, skb, &reason) < 0) { 372 + reason = sock_queue_rcv_skb_reason(sk, skb); 373 + if (reason) { 373 374 sk_skb_reason_drop(sk, skb, reason); 374 375 return NET_RX_DROP; 375 376 }