Repository navigation
fix(inputs/pcap): look up iface by name unless it is an address - #802
Conversation
PcapInputStream::start assigned the iface string to both an IPv4Address and an IPv6Address. Since PcapPlusPlus 24.09 those constructors throw std::invalid_argument on a string that is not an address, so live capture failed for every value: "eth0", "auto" and an IPv4 literal with "Not a valid IPv4/IPv6 address". Parse the value as an address only when it is one, as the flow and netprobe inputs already do; anything else is looked up by name, as with PcapPlusPlus 23.09. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
AI Code Review — risk tier: Advisory only. A human owns the merge decision. Summary — Net-positive, targeted fix: 🤖 AI Code Review · run · prompts: |
LCOV of commit
|
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Live capture has failed for every
ifacevalue since the PcapPlusPlus upgrade in #763 (23.09 to 24.09, 2026-04-08):eth0,lo0, orautoonce it resolves to a name fails withNot a valid IPv4 address: eth0;Not a valid IPv6 address: 192.0.2.1;Not a valid IPv4 address: 2001:db8::1.Cause.
PcapInputStream::start()assigns theifacestring to both anIPv4Addressand anIPv6Address. PcapPlusPlus 23.09 turned an invalid string into the zero address, which sent names to the name lookup. From 24.09 on, both constructors throwstd::invalid_argumentinstead. Theaf_packetsource goes through the same assignments before it opens the interface by name, so it was broken too.Fix. Parse the value as an address only when
isValidIPv4AddressorisValidIPv6Addresssays it is one; anything else is looked up by name. The flow handler, the netprobe input andmatch_subnetalready guard this way. No string is valid as both an IPv4 and an IPv6 address, so this picks the same lookup as 23.09 for every input:0.0.0.0and::still go to the name lookup;fe80::1%en0is handled as before (it was never supported).Who is affected. No pktvisor release tag contains #763. orb-agent images copy pktvisord from the develop build, though, so they are affected. On the released orb-agent 2.17.0 image (pktvisor
4.5.0-develop-ca3f081),pktvisord eth0exits withNot a valid IPv4 address: eth0.Tests
New
src/inputs/pcap/tests/test_iface.cpp: it checks that pktvisor's own lookup error comes back, not PcapPlusPlus's. It needs no capture privileges, because each lookup fails before a capture opens. The four cases:0.0.0.0, which is looked up as a name.The first three failed on develop with the PcapPlusPlus messages.
Suite: all 25 ctest targets pass on macOS (Release).
pktvisord on macOS:
lo0, develop's binary stops atNot a valid IPv4 address: lo0;lo0and with127.0.0.1. The open then fails withCannot open interface for packet capture, because BPF is root-only on that machine.PolicyManager::loadcatches onlystd::runtime_error, so thisstd::invalid_argumentalso skipped the policy rollback, and a retry got 409. With this fix, a badifaceno longer throws it. #801 makesPolicy::startstop its handlers whatever the exception;loadstill rolls back only on astd::runtime_error.🤖 Generated with Claude Code