Repository navigation
net/arp,icmpv6: Avoid blocking and allocations on non-blocking TX. - #22749
Open
mohitgurav20 wants to merge 1 commit into
Open
mohitgurav20 wants to merge 1 commit into
mohitgurav20 wants to merge 1 commit into
Conversation
arp_send() and icmpv6_neighbor() previously allocated mempool/callback and semaphore resources before checking the ARP/Neighbor tables, and blocked synchronously even for O_NONBLOCK or MSG_DONTWAIT sends. * Add arp_send_nonblock() and icmpv6_neighbor_nonblock() with a fast-path table lookup under netdev_lock(dev) before allocating any state or callback. * When nonblock is true and the entry is missing, return OK when CONFIG_NET_ARP_SEND_QUEUE is enabled (letting arp_out() queue the packet), or trigger a one-shot asynchronous request and return -EAGAIN. * Keep arp_send() and icmpv6_neighbor() as blocking wrappers for existing non-socket callers. * Update tcp_send_buffered.c, tcp_send_unbuffered.c, udp_sendto_buffered.c, and udp_sendto_unbuffered.c to pass nonblock. Assisted-by: Antigravity:gemini-4-hydrogen-medium Signed-off-by: mohitgurav20 <mohitgurav20@gmail.com>
mohitgurav20
requested review from
jerpelea and
xiaoxiang781216
as code owners
December 2, 2026 15:43
Contributor
Author
|
@xiaoxiang781216 @jerpelea reviewer pls feel free to to request the changes and guide me thorugh this issue . |
GUIDINGLI
approved these changes
Dec 2, 2026
Contributor
Author
|
The failed jobs hit ghcr.io Docker Login / Docker Pull EOF/401 errors before the build step ,could a maintainer please re-run the failed CI jobs? |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
arp_send()andicmpv6_neighbor()allocate state/callback and semaphore objects before checking the ARP/Neighbor table, and block in a retry loop even when the socket isO_NONBLOCKorMSG_DONTWAITis set.arp_send_nonblock()(net/arp/arp_send.c) andicmpv6_neighbor_nonblock()(net/icmpv6/icmpv6_neighbor.c) which takenetdev_lock(dev)and checkarp_find()/neighbor_lookup()up front, returningOKimmediately with zero allocations on a cache hit.nonblockistrueand the entry is missing:CONFIG_NET_ARP_SEND_QUEUE=y,arp_send_nonblock()returnsOKsoarp_out()queues the packet and sends the ARP request.mempool_allocate(..., 0)+arp_update(dev, ipaddr, NULL, 0)-EINPROGRESSguard for IPv4; heap-allocated async state freed on completion orNETDEV_DOWNfor IPv6) and returns-EAGAIN.arp_send()andicmpv6_neighbor()as blocking wrappers so existing non-socket callers (tcp_conn.c,tcp_sendfile.c,arp_acd.c,icmpv6_autoconfig.c,icmpv6_sendmsg.c) are unaffected.tcp_send_buffered.c,tcp_send_unbuffered.c,udp_sendto_buffered.c, andudp_sendto_unbuffered.cto evaluatenonblockbefore L2 resolution and call the non-blocking variants.Impact
O_NONBLOCK/MSG_DONTWAIT) TCP and UDP sends no longer block waiting on ARP/NDP retries.-1(errno = EAGAIN) immediately instead of blocking 100ms+ and failing withEHOSTUNREACH(or queue and return the byte count whenCONFIG_NET_ARP_SEND_QUEUE=y).arp_send()andicmpv6_neighbor()signatures are preserved).Testing
riscv-none-elf-gcc13.2.0riscv64,rv-virt:netnsh64(qemu-system-riscv64)./tools/checkpatch.sh -fon all 8 modified files passed with no errors.CONFIG_TESTING_OSTESTwas disabled locally due to anapps/version mismatch onwork_queue_run. Sincerv-virt:netnsh64hasCONFIG_NET_IPv6disabled by default, IPv4 was runtime-tested in QEMU for bothCONFIG_NET_ARP_SEND_QUEUE=nandCONFIG_NET_ARP_SEND_QUEUE=y, whileicmpv6_neighbor_nonblock()is verified by inspection. Could maintainers confirm whether these QEMU logs are acceptable?Testing logs before change (unmodified
master,CONFIG_NET_ARP_SEND_QUEUE=n):Testing logs after change (
CONFIG_NET_ARP_SEND_QUEUE=n):Testing logs after change (
CONFIG_NET_ARP_SEND_QUEUE=y,CONFIG_DRIVERS_VIRTIO_NET_BUFNUM=8):PR verification Self-Check