zebra: limit RTADV socket rcvbuf to 20MB#20654
Merged
ton31337 merged 1 commit intoFRRouting:masterfrom Feb 3, 2026
Merged
Conversation
Greptile OverviewGreptile SummaryAdded a 20MB receive buffer limit to the RTADV ICMPv6 socket to prevent out-of-memory conditions caused by excessive Router Advertisement/Router Solicitation packet bursts.
The change follows existing patterns in the codebase (similar buffer limiting exists in Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant App as FRR Application
participant Socket as rtadv_make_socket()
participant Kernel as Linux Kernel
participant Network as ICMPv6 Network
App->>Socket: Create RTADV socket
Socket->>Kernel: ns_socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6)
Kernel-->>Socket: Return socket fd
Note over Socket,Kernel: New: Limit receive buffer
Socket->>Kernel: setsockopt(SO_RCVBUF, 20MB)
alt Success
Kernel-->>Socket: Buffer size set
else Failure
Kernel-->>Socket: Error
Socket->>Kernel: close(sock)
Socket-->>App: Return error
end
Socket->>Kernel: setsockopt_ipv6_pktinfo()
Socket->>Kernel: setsockopt_ipv6_multicast_loop()
Socket->>Kernel: setsockopt_ipv6_unicast_hops()
Socket->>Kernel: Additional socket options...
Socket-->>App: Return configured socket
Note over Network,Kernel: During operation
Network->>Kernel: ICMPv6 RA/RS packets
Kernel->>Kernel: Buffer packets (max 20MB)
App->>Kernel: rtadv_read() event
Kernel-->>App: Receive buffered packets
|
Contributor
Author
ton31337
reviewed
Feb 2, 2026
zebra/rtadv.c
Outdated
| /* Limit receive buffer size to 20MB */ | ||
| { | ||
| int rcvbuf = 20971520; | ||
| ret = setsockopt(sock, SOL_SOCKET, SO_RCVBUF, |
Member
There was a problem hiding this comment.
Let's use setsockopt_so_recvbuf().
mjstapp
reviewed
Feb 2, 2026
zebra/rtadv.c
Outdated
|
|
||
| /* Limit receive buffer size to 20MB */ | ||
| { | ||
| int rcvbuf = 20971520; |
Contributor
There was a problem hiding this comment.
Magic number? could we have a define for this value?
mjstapp
reviewed
Feb 2, 2026
Contributor
mjstapp
left a comment
There was a problem hiding this comment.
Please run checkpatch and ensure it's clear
The RTADV raw ICMPv6 socket previously did not enforce an upper bound for the receive buffer size. In abnormal situations, excessive inbound packets combined with slow or stalled consumption by FRR can cause the kernel socket buffer to grow continuously and eventually trigger OOM. Limit SO_RCVBUF to 20MB to cap the worst-case memory usage while still providing sufficient buffering headroom for RS/RA bursts. Signed-off-by: hengwu0 <[email protected]>
Contributor
Author
mjstapp
approved these changes
Feb 3, 2026
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.
The RTADV raw ICMPv6 socket previously did not enforce an upper bound for the receive buffer size. In abnormal situations, excessive inbound packets combined with slow or stalled consumption by FRR can cause the kernel socket buffer to grow continuously and eventually trigger OOM.
Limit SO_RCVBUF to 20MB to cap the worst-case memory usage while still providing sufficient buffering headroom for RS/RA bursts.
Signed-off-by: hengwu0 [email protected]