Skip to content

Commit ec44bd2

Browse files
authored
Merge pull request #4482 from kostikbel/ktls
FreeBSD: Support kernel-offloaded TLS TCP
2 parents 6f475e5 + db4dba7 commit ec44bd2

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

libc-test/build.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,6 +2444,8 @@ fn test_freebsd(target: &str) {
24442444
"sys/sem.h",
24452445
"sys/shm.h",
24462446
"sys/socket.h",
2447+
"sys/socketvar.h",
2448+
"netinet/in_pcb.h", // must be after sys/socketvar.h
24472449
"sys/stat.h",
24482450
"sys/statvfs.h",
24492451
"sys/sysctl.h",
@@ -2846,6 +2848,10 @@ fn test_freebsd(target: &str) {
28462848
// `splice` introduced in FreeBSD 14.2
28472849
"splice" if Some(14) > freebsd_ver => true,
28482850

2851+
// Those are introduced in FreeBSD 15.
2852+
"xktls_session_onedir" | "xktls_session"
2853+
if Some(15) > freebsd_ver => true,
2854+
28492855
_ => false,
28502856
}
28512857
});

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ pub type fixpt_t = __fixpt_t;
1111
pub type __lwpid_t = i32;
1212
pub type lwpid_t = __lwpid_t;
1313
pub type blksize_t = i32;
14+
pub type ksize_t = u64;
15+
pub type inp_gen_t = u64;
16+
pub type so_gen_t = u64;
1417
pub type clockid_t = c_int;
1518
pub type sem_t = _sem;
1619
pub type timer_t = *mut __c_anonymous__timer;
@@ -1722,6 +1725,73 @@ s_no_extra_traits! {
17221725
pub uc_flags: c_int,
17231726
__spare__: [c_int; 4],
17241727
}
1728+
1729+
#[repr(align(8))]
1730+
pub struct xinpgen {
1731+
pub xig_len: ksize_t,
1732+
pub xig_count: u32,
1733+
_xig_spare32: u32,
1734+
pub xig_gen: inp_gen_t,
1735+
pub xig_sogen: so_gen_t,
1736+
_xig_spare64: [u64; 4],
1737+
}
1738+
1739+
pub struct in_addr_4in6 {
1740+
_ia46_pad32: [u32; 3],
1741+
pub ia46_addr4: crate::in_addr,
1742+
}
1743+
1744+
pub union in_dependaddr {
1745+
pub id46_addr: crate::in_addr_4in6,
1746+
pub id6_addr: crate::in6_addr,
1747+
}
1748+
1749+
pub struct in_endpoints {
1750+
pub ie_fport: u16,
1751+
pub ie_lport: u16,
1752+
pub ie_dependfaddr: crate::in_dependaddr,
1753+
pub ie_dependladdr: crate::in_dependaddr,
1754+
pub ie6_zoneid: u32,
1755+
}
1756+
1757+
pub struct in_conninfo {
1758+
pub inc_flags: u8,
1759+
pub inc_len: u8,
1760+
pub inc_fibnum: u16,
1761+
pub inc_ie: crate::in_endpoints,
1762+
}
1763+
1764+
pub struct xktls_session_onedir {
1765+
pub gennum: u64,
1766+
_rsrv1: [u64; 8],
1767+
_rsrv2: [u32; 8],
1768+
pub iv: [u8; 32],
1769+
pub cipher_algorithm: i32,
1770+
pub auth_algorithm: i32,
1771+
pub cipher_key_len: u16,
1772+
pub iv_len: u16,
1773+
pub auth_key_len: u16,
1774+
pub max_frame_len: u16,
1775+
pub tls_vmajor: u8,
1776+
pub tls_vminor: u8,
1777+
pub tls_hlen: u8,
1778+
pub tls_tlen: u8,
1779+
pub tls_bs: u8,
1780+
pub flags: u8,
1781+
pub drv_st_len: u16,
1782+
pub ifnet: [u8; 16],
1783+
}
1784+
1785+
pub struct xktls_session {
1786+
pub tsz: u32,
1787+
pub fsz: u32,
1788+
pub inp_gencnt: u64,
1789+
pub so_pcb: kvaddr_t,
1790+
pub coninf: crate::in_conninfo,
1791+
pub rx_vlan_id: c_ushort,
1792+
pub rcv: crate::xktls_session_onedir,
1793+
pub snd: crate::xktls_session_onedir,
1794+
}
17251795
}
17261796

17271797
cfg_if! {
@@ -4592,6 +4662,10 @@ pub const RB_POWERCYCLE: c_int = 0x400000;
45924662
pub const RB_PROBE: c_int = 0x10000000;
45934663
pub const RB_MULTIPLE: c_int = 0x20000000;
45944664

4665+
// netinet/in_pcb.h
4666+
pub const INC_ISIPV6: c_uchar = 0x01;
4667+
pub const INC_IPV6MINMTU: c_uchar = 0x02;
4668+
45954669
// sys/time.h
45964670
pub const CLOCK_BOOTTIME: crate::clockid_t = crate::CLOCK_UPTIME;
45974671
pub const CLOCK_REALTIME_COARSE: crate::clockid_t = crate::CLOCK_REALTIME_FAST;

0 commit comments

Comments
 (0)