Skip to content

Ktls #4482

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Ktls #4482

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2444,6 +2444,8 @@ fn test_freebsd(target: &str) {
"sys/sem.h",
"sys/shm.h",
"sys/socket.h",
"sys/socketvar.h",
"netinet/in_pcb.h", // must be after sys/socketvar.h
"sys/stat.h",
"sys/statvfs.h",
"sys/sysctl.h",
Expand Down Expand Up @@ -2846,6 +2848,10 @@ fn test_freebsd(target: &str) {
// `splice` introduced in FreeBSD 14.2
"splice" if Some(14) > freebsd_ver => true,

// Those are introduced in FreeBSD 15.
"xktls_session_onedir" | "xktls_session"
if Some(15) > freebsd_ver => true,

_ => false,
}
});
Expand Down
73 changes: 73 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ pub type fixpt_t = __fixpt_t;
pub type __lwpid_t = i32;
pub type lwpid_t = __lwpid_t;
pub type blksize_t = i32;
pub type ksize_t = u64;
pub type inp_gen_t = u64;
pub type so_gen_t = u64;
pub type clockid_t = c_int;
pub type sem_t = _sem;
pub type timer_t = *mut __c_anonymous__timer;
Expand Down Expand Up @@ -1720,6 +1723,72 @@ s_no_extra_traits! {
pub uc_flags: c_int,
__spare__: [c_int; 4],
}

pub struct xinpgen {
pub xig_len: ksize_t,
pub xig_count: u32,
pub _xig_spare32: u32,
pub xig_gen: inp_gen_t,
pub xig_sogen: so_gen_t,
pub _xig_spare64: [u64; 4],
Comment on lines +1730 to +1733
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention used elsewhere in libc is to make spare and padding fields private. The forces consumers to initialize with mem::zeroed, but it also makes it easier for future versions of libc to replace those spare fields with no backwards-compatibility problems.

Suggested change
pub _xig_spare32: u32,
pub xig_gen: inp_gen_t,
pub xig_sogen: so_gen_t,
pub _xig_spare64: [u64; 4],
_xig_spare32: u32,
pub xig_gen: inp_gen_t,
pub xig_sogen: so_gen_t,
_xig_spare64: [u64; 4],

}

pub struct in_addr_4in6 {
pub ia46_pad32: [u32; 3],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub ia46_pad32: [u32; 3],
ia46_pad32: [u32; 3],

pub ia46_addr4: crate::in_addr,
}

pub union in_dependaddr {
pub id46_addr: crate::in_addr_4in6,
pub id6_addr: crate::in6_addr,
}

pub struct in_endpoints {
pub ie_fport: u16,
pub ie_lport: u16,
pub ie_dependfaddr: crate::in_dependaddr,
pub ie_dependladdr: crate::in_dependaddr,
pub ie6_zoneid: u32,
}

pub struct in_conninfo {
pub inc_flags: u8,
pub inc_len: u8,
pub inc_fibnum: u16,
pub inc_ie: crate::in_endpoints,
}

pub struct xktls_session_onedir {
pub gennum: u64,
pub rsrv1: [u64; 8],
pub rsrv2: [u32; 8],
pub iv: [u8; 32],
pub cipher_algorithm: i32,
pub auth_algorithm: i32,
pub cipher_key_len: u16,
pub iv_len: u16,
pub auth_key_len: u16,
pub max_frame_len: u16,
pub tls_vmajor: u8,
pub tls_vminor: u8,
pub tls_hlen: u8,
pub tls_tlen: u8,
pub tls_bs: u8,
pub flags: u8,
pub drv_st_len: u16,
pub ifnet: [u8; 16],
}

pub struct xktls_session {
pub tsz: u32,
pub fsz: u32,
pub inp_gencnt: u64,
pub so_pcb: kvaddr_t,
pub coninf: crate::in_conninfo,
pub rx_vlan_id: c_short,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub rx_vlan_id: c_short,
pub rx_vlan_id: c_ushort,

pub rcv: crate::xktls_session_onedir,
pub snd: crate::xktls_session_onedir,
}
}

cfg_if! {
Expand Down Expand Up @@ -4590,6 +4659,10 @@ pub const RB_POWERCYCLE: c_int = 0x400000;
pub const RB_PROBE: c_int = 0x10000000;
pub const RB_MULTIPLE: c_int = 0x20000000;

// netinet/in_pcb.h
pub const INC_ISIPV6: c_uchar = 0x01;
pub const INC_IPV6MINMTU: c_uchar = 0x02;

// sys/time.h
pub const CLOCK_BOOTTIME: crate::clockid_t = crate::CLOCK_UPTIME;
pub const CLOCK_REALTIME_COARSE: crate::clockid_t = crate::CLOCK_REALTIME_FAST;
Expand Down