Repository navigation
snapshot: support ip address literals, more docs - #403
Open
rcgoodfellow wants to merge 1 commit into
Open
rcgoodfellow wants to merge 1 commit into
rcgoodfellow wants to merge 1 commit into
Conversation
rcgoodfellow
commented
Oct 14, 2026
Collaborator
- Add more documentation on how to use the snapshot command.
- Add support for specifying literal IP addresses as triggers since doing this in a hex/mask was very tedious.
rcgoodfellow
force-pushed
the
ry/snapshot-improvements
branch
6 times, most recently
from
October 14, 2026 03:57
e4c911f to
92462de
Compare
rcgoodfellow
force-pushed
the
ry/snapshot-improvements
branch
from
October 14, 2026 04:01
92462de to
b28e1ab
Compare
cfzimmerman
approved these changes
Oct 16, 2026
cfzimmerman
left a comment
Contributor
There was a problem hiding this comment.
Gut reaction is to ask for an expectorate test for every swadm change, but this one would be pretty tricky to test in CI, right? No pressure if so. Overall looks great.
Comment on lines
+41
to
+55
| fn from(value: Trigger) -> Self { | ||
| let (val, mask) = match value.value { | ||
| TriggerValue::Ip { ip } => match ip { | ||
| IpAddr::V4(v4) => ( | ||
| format!("0x{:08x}", u32::from(v4)), | ||
| format!("0x{:x}", u32::MAX), | ||
| ), | ||
| IpAddr::V6(v6) => ( | ||
| format!("0x{:032x}", u128::from(v6)), | ||
| format!("0x{:x}", u128::MAX), | ||
| ), | ||
| }, | ||
| TriggerValue::Hex { value, mask } => (value, mask), | ||
| }; | ||
| types::SnapshotTrigger { field: value.field, mask, value: val } |
Contributor
There was a problem hiding this comment.
Might be more readable to un-nest the matches.
fn from(value: Trigger) -> Self {
let (val, mask) = match value.value {
TriggerValue::Ip { ip: IpAddr::V4(v4) } => (
format!("0x{:08x}", u32::from(v4)),
format!("0x{:x}", u32::MAX),
),
TriggerValue::Ip { ip: IpAddr::V6(v6) } => (
format!("0x{:032x}", u128::from(v6)),
format!("0x{:x}", u128::MAX),
),
TriggerValue::Hex { value, mask } => (value, mask),
};
types::SnapshotTrigger { field: value.field, mask, value: val }
}|
|
||
| /// Parse a trigger spec: "field=value/mask" where value and mask are hex. | ||
| fn parse_trigger(s: &str) -> Result<types::SnapshotTrigger> { | ||
| fn parse_trigger(s: &str) -> Result<Trigger> { |
Comment on lines
+112
to
+113
| /// This flag may be specified multiple times to specify multiple | ||
| /// triggers. Multiple triggers are joined together as a logical AND. |
Contributor
There was a problem hiding this comment.
Should we say "multiple unique triggers" or even enforce uniqueness? For example, I think
-t hdr.ethernet.dst_addr=A -t hdr.ethernet.dst_addr=B
only captures "B". Does that sound right to you? Might be confusing if left unstated. This is based on reading tofino sde code, so its very possible I'm incorrect.
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.