mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 18:18:55 +00:00
build(rust): bump network-types to v0.0.8 (#8811)
This new release includes several patches we have made upstream that allow us to remove some of the vendored types from the crate. All fields that we access from `network-types` are now stored as byte-arrays and thus retain the big-endian byte ordering from the network. Resolves: #8686 Related: https://github.com/vadorovsky/network-types/pull/34 Related: https://github.com/vadorovsky/network-types/pull/36 Related: https://github.com/vadorovsky/network-types/pull/38
This commit is contained in:
4
rust/Cargo.lock
generated
4
rust/Cargo.lock
generated
@@ -4214,9 +4214,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "network-types"
|
||||
version = "0.0.7"
|
||||
version = "0.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e82e9f64c09f56aa7c80c3fa087997bd99a913f91d9c74d36cf5fd75dd5773e6"
|
||||
checksum = "f2df15b1cb023b9d205ae287d5dbe74510ae4d62b5131ceec516f4913ed05230"
|
||||
|
||||
[[package]]
|
||||
name = "new_debug_unreachable"
|
||||
|
||||
@@ -102,7 +102,7 @@ lru = "0.12.5"
|
||||
mio = "1.0.3"
|
||||
moka = "0.12.10"
|
||||
native-dialog = "0.7.0"
|
||||
network-types = "0.0.7"
|
||||
network-types = "0.0.8"
|
||||
nix = "0.29.0"
|
||||
nu-ansi-term = "0.50"
|
||||
num_cpus = "1.16.0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::{Error, ref_mut_at::ref_mut_at, udp::UdpHdr};
|
||||
use crate::{Error, ref_mut_at::ref_mut_at};
|
||||
use aya_ebpf::programs::XdpContext;
|
||||
use network_types::eth::EthHdr;
|
||||
use network_types::{eth::EthHdr, udp::UdpHdr};
|
||||
|
||||
/// Represents a channel-data header within our packet.
|
||||
pub struct ChannelData<'a> {
|
||||
|
||||
@@ -3,7 +3,10 @@ use core::net::Ipv4Addr;
|
||||
use crate::{Error, checksum::ChecksumUpdate, ref_mut_at::ref_mut_at};
|
||||
use aya_ebpf::programs::XdpContext;
|
||||
use aya_log_ebpf::debug;
|
||||
use network_types::{eth::EthHdr, ip::IpProto};
|
||||
use network_types::{
|
||||
eth::EthHdr,
|
||||
ip::{IpProto, Ipv4Hdr},
|
||||
};
|
||||
|
||||
/// Represents an IPv4 header within our packet.
|
||||
pub struct Ip4<'a> {
|
||||
@@ -81,51 +84,3 @@ impl<'a> Ip4<'a> {
|
||||
ip_pseudo_header
|
||||
}
|
||||
}
|
||||
|
||||
// Copied from `network-types` but uses byte-arrays instead of `u32` and `u16`
|
||||
// See <https://github.com/vadorovsky/network-types/issues/32>.
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct Ipv4Hdr {
|
||||
pub version_ihl: u8,
|
||||
pub tos: u8,
|
||||
pub tot_len: [u8; 2],
|
||||
pub id: [u8; 2],
|
||||
pub frag_off: [u8; 2],
|
||||
pub ttl: u8,
|
||||
pub proto: IpProto,
|
||||
pub check: [u8; 2],
|
||||
pub src_addr: [u8; 4],
|
||||
pub dst_addr: [u8; 4],
|
||||
}
|
||||
|
||||
impl Ipv4Hdr {
|
||||
pub const LEN: usize = core::mem::size_of::<Self>();
|
||||
|
||||
pub fn ihl(&self) -> u8 {
|
||||
self.version_ihl & 0b00001111
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn ihl() {
|
||||
let ipv4_hdr = Ipv4Hdr {
|
||||
version_ihl: 0b0100_0101,
|
||||
tos: Default::default(),
|
||||
tot_len: Default::default(),
|
||||
id: Default::default(),
|
||||
frag_off: Default::default(),
|
||||
ttl: Default::default(),
|
||||
proto: IpProto::Udp,
|
||||
check: Default::default(),
|
||||
src_addr: Default::default(),
|
||||
dst_addr: Default::default(),
|
||||
};
|
||||
|
||||
assert_eq!(ipv4_hdr.ihl(), 0b0101); // The lower 4 bits of `version_ihl` are the IHL,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,10 @@ use core::net::Ipv6Addr;
|
||||
use crate::{Error, checksum::ChecksumUpdate, ref_mut_at::ref_mut_at};
|
||||
use aya_ebpf::programs::XdpContext;
|
||||
use aya_log_ebpf::debug;
|
||||
use network_types::{eth::EthHdr, ip::IpProto};
|
||||
use network_types::{
|
||||
eth::EthHdr,
|
||||
ip::{IpProto, Ipv6Hdr},
|
||||
};
|
||||
|
||||
/// Represents an IPv6 header within our packet.
|
||||
pub struct Ip6<'a> {
|
||||
@@ -63,16 +66,3 @@ impl<'a> Ip6<'a> {
|
||||
ip_pseudo_header
|
||||
}
|
||||
}
|
||||
|
||||
// Copied from `network-types` but uses byte-arrays instead of `u32` and `u16`
|
||||
// See <https://github.com/vadorovsky/network-types/issues/32>.
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Ipv6Hdr {
|
||||
pub version_traffic_class_flow_label: [u8; 4],
|
||||
pub payload_len: [u8; 2],
|
||||
pub next_hdr: IpProto,
|
||||
pub hop_limit: u8,
|
||||
pub src_addr: [u8; 16],
|
||||
pub dst_addr: [u8; 16],
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ use channel_data::{CdHdr, ChannelData};
|
||||
use ebpf_shared::{ClientAndChannelV4, ClientAndChannelV6, PortAndPeerV4, PortAndPeerV6};
|
||||
use error::{SupportedChannel, UnsupportedChannel};
|
||||
use eth::Eth;
|
||||
use ip4::{Ip4, Ipv4Hdr};
|
||||
use ip4::Ip4;
|
||||
use ip6::Ip6;
|
||||
use move_headers::{
|
||||
add_channel_data_header_ipv4, add_channel_data_header_ipv6, remove_channel_data_header_ipv4,
|
||||
@@ -21,9 +21,10 @@ use move_headers::{
|
||||
};
|
||||
use network_types::{
|
||||
eth::EtherType,
|
||||
ip::{IpProto, Ipv6Hdr},
|
||||
ip::{IpProto, Ipv4Hdr, Ipv6Hdr},
|
||||
udp::UdpHdr,
|
||||
};
|
||||
use udp::{Udp, UdpHdr};
|
||||
use udp::Udp;
|
||||
|
||||
mod channel_data;
|
||||
mod checksum;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{Error, checksum::ChecksumUpdate, ref_mut_at::ref_mut_at};
|
||||
use aya_ebpf::programs::XdpContext;
|
||||
use aya_log_ebpf::debug;
|
||||
use network_types::eth::EthHdr;
|
||||
use network_types::{eth::EthHdr, udp::UdpHdr};
|
||||
|
||||
/// Represents a UDP header within our packet.
|
||||
pub struct Udp<'a> {
|
||||
@@ -93,18 +93,3 @@ impl<'a> Udp<'a> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Copied from `network-types` but uses byte-arrays instead of `u32` and `u16`
|
||||
// See <https://github.com/vadorovsky/network-types/issues/32>.
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct UdpHdr {
|
||||
pub source: [u8; 2],
|
||||
pub dest: [u8; 2],
|
||||
pub len: [u8; 2],
|
||||
pub check: [u8; 2],
|
||||
}
|
||||
|
||||
impl UdpHdr {
|
||||
pub const LEN: usize = core::mem::size_of::<Self>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user