-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aya-log: Allow logging core::net::Ipv4Addr
and core::net::Ipv6Addr
#966
Conversation
✅ Deploy Preview for aya-rs-docs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
ce46c19
to
6f95b89
Compare
Hey @alessandrod, this pull request changes the Aya Public API and requires your review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 4 of 4 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 10 unresolved discussions (waiting on @alessandrod and @vadorovsky)
aya-log/src/lib.rs
line 322 at r1 (raw file):
Some(DisplayHint::LowerMac) => Err(()), Some(DisplayHint::UpperMac) => Err(()), _ => Ok(Ipv4Formatter::format(*self)),
are these arms just None? can we s/_/None/ everywhere?
aya-log/src/lib.rs
line 839 at r1 (raw file):
len += "ipv4: ".write(&mut input[len..]).unwrap().get(); len += DisplayHint::Ip.write(&mut input[len..]).unwrap().get(); Ipv4Addr::new(10, 0, 0, 1)
len +=
aya-log/src/lib.rs
line 862 at r1 (raw file):
len += "ipv4: ".write(&mut input[len..]).unwrap().get(); len += DisplayHint::Ip.write(&mut input[len..]).unwrap().get(); IpAddr::V4(Ipv4Addr::new(10, 0, 0, 1))
len +=
aya-log/src/lib.rs
line 906 at r1 (raw file):
len += "ipv6: ".write(&mut input[len..]).unwrap().get(); len += DisplayHint::Ip.write(&mut input[len..]).unwrap().get(); Ipv6Addr::new(
len+=
aya-log/src/lib.rs
line 931 at r1 (raw file):
len += "ipv6: ".write(&mut input[len..]).unwrap().get(); len += DisplayHint::Ip.write(&mut input[len..]).unwrap().get(); IpAddr::V6(Ipv6Addr::new(
len+=
test/integration-ebpf/src/log.rs
line 22 at r1 (raw file):
let ipv4 = Ipv4Addr::new(10, 0, 0, 1); let ipv6 = Ipv6Addr::new(8193, 3512, 0, 0, 0, 0, 0, 1); info!(&ctx, "ip structs: ipv4: {:i}, ipv6: {:i}", ipv4, ipv6); // 2001:db8::1
comment in wrong place?
test/integration-ebpf/src/log.rs
line 23 at r1 (raw file):
let ipv6 = Ipv6Addr::new(8193, 3512, 0, 0, 0, 0, 0, 1); info!(&ctx, "ip structs: ipv4: {:i}, ipv6: {:i}", ipv4, ipv6); // 2001:db8::1 let ipv4 = IpAddr::V4(Ipv4Addr::new(10, 0, 0, 1));
use ipv4
from above?
test/integration-ebpf/src/log.rs
line 24 at r1 (raw file):
info!(&ctx, "ip structs: ipv4: {:i}, ipv6: {:i}", ipv4, ipv6); // 2001:db8::1 let ipv4 = IpAddr::V4(Ipv4Addr::new(10, 0, 0, 1)); let ipv6 = IpAddr::V6(Ipv6Addr::new(8193, 3512, 0, 0, 0, 0, 0, 1));
use ipv6
from above?
test/integration-ebpf/src/log.rs
line 26 at r1 (raw file):
let ipv6 = IpAddr::V6(Ipv6Addr::new(8193, 3512, 0, 0, 0, 0, 0, 1)); info!(&ctx, "ip enums: ipv4: {:i}, ipv6: {:i}", ipv4, ipv6); let ipv4 = 167772161u32; // 10.0.0.1
we're on nightly here, we can use https://doc.rust-lang.org/stable/std/net/struct.Ipv4Addr.html#method.to_bits to avoid the repetition
or use https://doc.rust-lang.org/stable/std/net/struct.Ipv4Addr.html#method.octets
test/integration-ebpf/src/log.rs
line 27 at r1 (raw file):
info!(&ctx, "ip enums: ipv4: {:i}, ipv6: {:i}", ipv4, ipv6); let ipv4 = 167772161u32; // 10.0.0.1 let ipv6 = [
https://doc.rust-lang.org/stable/std/net/struct.Ipv6Addr.html#method.octets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 5 files reviewed, 10 unresolved discussions (waiting on @alessandrod and @tamird)
aya-log/src/lib.rs
line 322 at r1 (raw file):
Previously, tamird (Tamir Duberstein) wrote…
are these arms just None? can we s/_/None/ everywhere?
Done.
aya-log/src/lib.rs
line 839 at r1 (raw file):
Previously, tamird (Tamir Duberstein) wrote…
len +=
Done.
aya-log/src/lib.rs
line 862 at r1 (raw file):
Previously, tamird (Tamir Duberstein) wrote…
len +=
Done.
aya-log/src/lib.rs
line 906 at r1 (raw file):
Previously, tamird (Tamir Duberstein) wrote…
len+=
Done.
aya-log/src/lib.rs
line 931 at r1 (raw file):
Previously, tamird (Tamir Duberstein) wrote…
len+=
Done.
test/integration-ebpf/src/log.rs
line 22 at r1 (raw file):
Previously, tamird (Tamir Duberstein) wrote…
comment in wrong place?
Done.
test/integration-ebpf/src/log.rs
line 23 at r1 (raw file):
Previously, tamird (Tamir Duberstein) wrote…
use
ipv4
from above?
Done.
test/integration-ebpf/src/log.rs
line 24 at r1 (raw file):
Previously, tamird (Tamir Duberstein) wrote…
use
ipv6
from above?
Done.
test/integration-ebpf/src/log.rs
line 26 at r1 (raw file):
Previously, tamird (Tamir Duberstein) wrote…
we're on nightly here, we can use https://doc.rust-lang.org/stable/std/net/struct.Ipv4Addr.html#method.to_bits to avoid the repetition
or use https://doc.rust-lang.org/stable/std/net/struct.Ipv4Addr.html#method.octets
Done.
test/integration-ebpf/src/log.rs
line 27 at r1 (raw file):
Previously, tamird (Tamir Duberstein) wrote…
https://doc.rust-lang.org/stable/std/net/struct.Ipv6Addr.html#method.octets
Done.
IP address types are available in `core`, so they can be used also in eBPF programs. This change adds support of these types in aya-log. * Add implementation of `WriteTuBuf` to these types. * Support these types in `Ipv4Formatter` and `Ipv6Formatter`. * Support them with `DisplayHint::Ip`. * Add support for formatting `[u8; 4]`, to be able to handle `Ipv4Addr::octets`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful.
Reviewed 5 of 5 files at r3, 4 of 4 files at r5, 1 of 1 files at r6, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @alessandrod)
IP address types are available in
core
, so they can be used also in eBPF programs. This change adds support of these types in aya-log.WriteTuBuf
to these types.Ipv4Formatter
andIpv6Formatter
.DisplayHint::Ip
.This change is