vrrrpd: improve error handling in several paths - #21251
Merged
Merged
Conversation
Greptile SummaryThis PR hardens error handling across the Key changes:
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Receive VRRP Packet] --> B[vrrp_pkt_parse_datagram]
B --> C{family == AF_INET\nor AF_INET6?}
C -- "neither" --> D["VRRP_PKT_VCHECK(false)\nreturn -1\n(was: assert)"]
C -- "AF_INET/AF_INET6" --> E[Version & Size Checks]
E --> F[vrrp_pkt_checksum]
F --> G{Valid version\nin packet?}
G -- "invalid" --> H["return chksum_pre+1\n(checksum mismatch guaranteed)\n(was: assert)"]
G -- "valid" --> I[Compute real checksum]
I --> J[Checksum Match?]
J -- "no" --> K[return -1]
J -- "yes" --> L[vrrp_recv_advertisement]
L --> M{VRRPv3?}
M -- "yes" --> N["master_adver_interval &= 0x0FFF\n(enforce 12-bit field)"]
N --> O[vrrp_recalculate_timers]
M -- "no" --> O
subgraph Socket Setup
P[vrrp_socket] --> Q{IPv4 address\nfound on iface?}
Q -- "no" --> R["zlog_err + goto done\n(was: assert)"]
Q -- "yes" --> S[setsockopt multicast join]
end
subgraph Gratuitous ARP
T[vrrp_garp_send_all] --> U{family == AF_INET?}
U -- "no" --> V["zlog_warn + return\n(was: assert)"]
U -- "yes" --> W[vrrp_garp_send]
end
subgraph Neighbor Discovery
X[vrrp_ndisc_una_send_all] --> Y[vrrp_ndisc_una_send per addr]
Y --> Z{family == AF_INET6?}
Z -- "no" --> AA["zlog_warn + return -1\n(was: assert)"]
Z -- "yes" --> AB[Send ND packet]
end
Prompt To Fix All With AIThis is a comment left during a code review.
Path: vrrpd/vrrp_ndisc.c
Line: 193-201
Comment:
**Missing early-return family guard in `_send_all`**
The companion function `vrrp_garp_send_all` in `vrrp_arp.c` received an explicit family check with a single `zlog_warn` and an early return. `vrrp_ndisc_una_send_all` had its `assert` removed but received no equivalent guard. If this function is called with `r->family != AF_INET6` and `r->addrs` contains N addresses, `vrrp_ndisc_una_send` will fire N separate warning log lines instead of one. Adding an early-return check here keeps the two `_send_all` functions consistent:
```suggestion
int vrrp_ndisc_una_send_all(struct vrrp_router *r)
{
struct listnode *ln;
struct ipaddr *ip;
if (r->family != AF_INET6) {
zlog_warn(VRRP_LOGPFX VRRP_LOGPFX_VRID VRRP_LOGPFX_FAM
"Unable to send unsolicited Neighbor Advertisements on %s: not INET6",
r->vr->vrid, family2str(r->family),
r->mvl_ifp->name);
return -1;
}
for (ALL_LIST_ELEMENTS_RO(r->addrs, ln, ip))
vrrp_ndisc_una_send(r, ip);
return 0;
}
```
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: "vrrpd: replace some ..." |
added 3 commits
March 18, 2026 16:01
Ensure advertised vrrpv3 timers are limited to 12 bits. Signed-off-by: Mark Stapp <mjs@cisco.com>
Don't mix explicit ethernet and per-interface hw values; we only support ethernet for g-ARP messages. Signed-off-by: Mark Stapp <mjs@cisco.com>
Replace several asserts with error returns, especially in packet-processing paths. Signed-off-by: Mark Stapp <mjs@cisco.com>
Contributor
Author
|
cleaned up a couple of greptile comments |
Contributor
Author
|
@greptileai review |
Member
|
@Mergifyio backport stable/10.6 stable/10.5 stable/10.4 stable/10.3 stable/10.2 |
β Backports have been createdDetails
|
Jafaral
approved these changes
Mar 19, 2026
This was referenced Mar 20, 2026
ton31337
added a commit
that referenced
this pull request
Mar 20, 2026
vrrrpd: improve error handling in several paths (backport #21251)
ton31337
added a commit
that referenced
this pull request
Mar 20, 2026
vrrrpd: improve error handling in several paths (backport #21251)
ton31337
added a commit
that referenced
this pull request
Mar 20, 2026
vrrrpd: improve error handling in several paths (backport #21251)
ton31337
added a commit
that referenced
this pull request
Mar 20, 2026
vrrrpd: improve error handling in several paths (backport #21251)
ton31337
added a commit
that referenced
this pull request
Mar 20, 2026
vrrrpd: improve error handling in several paths (backport #21251)
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.
Improve and harden some error-condition handling in several paths, especially packet-processing. Replace several asserts with logs and/or error returns.